qmp_test: Add TestExecMemdevAdd and TestExecQomSet
Add TestExecMemdevAdd and TestExecQomSet to qmp_test.go.
They can test ExecMemdevAdd and ExecQomSet.
@@ -1294,6 +1294,24 @@ func TestExecSetMigrateArguments(t *testing.T) {
<-disconnectedCh
}
+// Checks add memory device
+func TestExecMemdevAdd(t *testing.T) {
+ connectedCh := make(chan *QMPVersion)
+ disconnectedCh := make(chan struct{})
+ buf := newQMPTestCommandBuffer(t)
+ buf.AddCommand("object-add", nil, "return", nil)
+ buf.AddCommand("device_add", nil, "return", nil)
+ cfg := QMPConfig{Logger: qmpTestLogger{}}
+ q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
+ checkVersion(t, connectedCh)
+ err := q.ExecMemdevAdd(context.Background(), "memory-backend-ram", "mem0", "", 128, true, "virtio-mem-pci", "virtiomem0")
+ if err != nil {
+ t.Fatalf("Unexpected error: %v", err)
+ }
+ q.Shutdown()
+ <-disconnectedCh
+}
+
// Checks hotplug memory
func TestExecHotplugMemory(t *testing.T) {
connectedCh := make(chan *QMPVersion)
@@ -1692,3 +1710,20 @@ func TestQMPExecQueryQmpStatus(t *testing.T) {
q.Shutdown()
<-disconnectedCh
}
+
+// Checks qom-set
+func TestExecQomSet(t *testing.T) {
+ connectedCh := make(chan *QMPVersion)
+ disconnectedCh := make(chan struct{})
+ buf := newQMPTestCommandBuffer(t)
+ buf.AddCommand("qom-set", nil, "return", nil)
+ cfg := QMPConfig{Logger: qmpTestLogger{}}
+ q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
+ checkVersion(t, connectedCh)
+ err := q.ExecQomSet(context.Background(), "virtiomem0", "requested-size", 1024)
+ if err != nil {
+ t.Fatalf("Unexpected error: %v", err)
+ }
+ q.Shutdown()
+ <-disconnectedCh
+}
