From a03d4968e11ed945d045b118eff3b48ad0bbc3c2 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 7 May 2018 18:08:25 +0800 Subject: [PATCH] qmp: add set migration capabilities It allows to set guest migration capabilities. Signed-off-by: Peng Tao --- qemu/qmp.go | 9 +++++++++ qemu/qmp_test.go | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/qemu/qmp.go b/qemu/qmp.go index 8888ad4d4a..8a2b4bc1ff 100644 --- a/qemu/qmp.go +++ b/qemu/qmp.go @@ -828,3 +828,12 @@ func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableC return cpus, nil } + +// ExecSetMigrationCaps sets migration capabilities +func (q *QMP) ExecSetMigrationCaps(ctx context.Context, caps []map[string]interface{}) error { + args := map[string]interface{}{ + "capabilities": caps, + } + + return q.executeCommand(ctx, "migrate-set-capabilities", args, nil) +} diff --git a/qemu/qmp_test.go b/qemu/qmp_test.go index 85850fcb5b..62018675cd 100644 --- a/qemu/qmp_test.go +++ b/qemu/qmp_test.go @@ -887,3 +887,26 @@ func TestQMPExecuteQueryHotpluggableCPUs(t *testing.T) { q.Shutdown() <-disconnectedCh } + +// Checks that migrate capabilities can be set +func TestExecSetMigrationCaps(t *testing.T) { + connectedCh := make(chan *QMPVersion) + disconnectedCh := make(chan struct{}) + buf := newQMPTestCommandBuffer(t) + buf.AddCommand("migrate-set-capabilities", nil, "return", nil) + cfg := QMPConfig{Logger: qmpTestLogger{}} + q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh) + checkVersion(t, connectedCh) + caps := []map[string]interface{}{ + { + "capability": "bypass-shared-memory", + "state": true, + }, + } + err := q.ExecSetMigrationCaps(context.Background(), caps) + if err != nil { + t.Fatalf("Unexpected error: %v\n", err) + } + q.Shutdown() + <-disconnectedCh +}