mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 17:37:20 +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:
		| @@ -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) | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user