diff --git a/qemu/qmp.go b/qemu/qmp.go index 8a2b4bc1ff..9e37821814 100644 --- a/qemu/qmp.go +++ b/qemu/qmp.go @@ -837,3 +837,12 @@ func (q *QMP) ExecSetMigrationCaps(ctx context.Context, caps []map[string]interf return q.executeCommand(ctx, "migrate-set-capabilities", args, nil) } + +// ExecSetMigrateArguments sets the command line used for migration +func (q *QMP) ExecSetMigrateArguments(ctx context.Context, url string) error { + args := map[string]interface{}{ + "uri": url, + } + + return q.executeCommand(ctx, "migrate", args, nil) +} diff --git a/qemu/qmp_test.go b/qemu/qmp_test.go index 62018675cd..9b471d6c63 100644 --- a/qemu/qmp_test.go +++ b/qemu/qmp_test.go @@ -910,3 +910,20 @@ func TestExecSetMigrationCaps(t *testing.T) { q.Shutdown() <-disconnectedCh } + +// Checks that migrate arguments can be set +func TestExecSetMigrateArguments(t *testing.T) { + connectedCh := make(chan *QMPVersion) + disconnectedCh := make(chan struct{}) + buf := newQMPTestCommandBuffer(t) + buf.AddCommand("migrate", nil, "return", nil) + cfg := QMPConfig{Logger: qmpTestLogger{}} + q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh) + checkVersion(t, connectedCh) + err := q.ExecSetMigrateArguments(context.Background(), "exec:foobar") + if err != nil { + t.Fatalf("Unexpected error: %v\n", err) + } + q.Shutdown() + <-disconnectedCh +}