mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 07:18:27 +00:00
qmp: support command 'query-qmp-schema'
The upper hyervisor manager application maybe need to wait some QMP event to control boot sequence, but the event we wanted maybe not exist in some older version, so we need query all QMP ABI and check the event is supported or not. related: kata-containers/runtime#1918 Signed-off-by: Ning Bo <ning.bo9@zte.com.cn>
This commit is contained in:
@@ -1588,3 +1588,38 @@ func TestMainLoopEventBeforeGreeting(t *testing.T) {
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
||||
func TestQMPExecQueryQmpSchema(t *testing.T) {
|
||||
connectedCh := make(chan *QMPVersion)
|
||||
disconnectedCh := make(chan struct{})
|
||||
buf := newQMPTestCommandBuffer(t)
|
||||
schemaInfo := []SchemaInfo{
|
||||
{
|
||||
MetaType: "command",
|
||||
Name: "object-add",
|
||||
},
|
||||
{
|
||||
MetaType: "event",
|
||||
Name: "VSOCK_RUNNING",
|
||||
},
|
||||
}
|
||||
buf.AddCommand("query-qmp-schema", nil, "return", schemaInfo)
|
||||
cfg := QMPConfig{
|
||||
Logger: qmpTestLogger{},
|
||||
MaxCapacity: 1024,
|
||||
}
|
||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||
checkVersion(t, connectedCh)
|
||||
info, err := q.ExecQueryQmpSchema(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v\n", err)
|
||||
}
|
||||
if len(schemaInfo) != 2 {
|
||||
t.Fatalf("Expected schema infos length equals to 2\n")
|
||||
}
|
||||
if reflect.DeepEqual(info, schemaInfo) == false {
|
||||
t.Fatalf("Expected %v equals to %v\n", info, schemaInfo)
|
||||
}
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
Reference in New Issue
Block a user