qmp: add migrate set arguments

It allows to set migration arguments so that callers can control how
migration is done.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-05-07 18:19:17 +08:00
parent a03d4968e1
commit 8aeca15388
2 changed files with 26 additions and 0 deletions

View File

@ -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)
}

View File

@ -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
}