1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-04-29 12:14:48 +00:00

qmp: add set migration capabilities

It allows to set guest migration capabilities.

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

View File

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

View File

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