mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 08:17:37 +00:00
qmp: support command 'chardev-remove'
So that caller can remove hotremove chardev via qmp Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
This commit is contained in:
parent
dfb6cf6041
commit
13aeba09d5
11
qemu/qmp.go
11
qemu/qmp.go
@ -946,6 +946,17 @@ func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error {
|
|||||||
return q.executeCommand(ctx, "x-blockdev-del", args, nil)
|
return q.executeCommand(ctx, "x-blockdev-del", args, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExecuteChardevDel deletes a char device by sending a chardev-remove command.
|
||||||
|
// chardevID is the id of the char device to be deleted. Typically, this will
|
||||||
|
// match the id passed to ExecuteCharDevUnixSocketAdd. It must be a valid QMP id.
|
||||||
|
func (q *QMP) ExecuteChardevDel(ctx context.Context, chardevID string) error {
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"id": chardevID,
|
||||||
|
}
|
||||||
|
|
||||||
|
return q.executeCommand(ctx, "chardev-remove", args, nil)
|
||||||
|
}
|
||||||
|
|
||||||
// ExecuteNetdevAdd adds a Net device to a QEMU instance
|
// ExecuteNetdevAdd adds a Net device to a QEMU instance
|
||||||
// using the netdev_add command. netdevID is the id of the device to add.
|
// using the netdev_add command. netdevID is the id of the device to add.
|
||||||
// Must be valid QMP identifier.
|
// Must be valid QMP identifier.
|
||||||
|
@ -638,6 +638,28 @@ func TestQMPBlockdevDel(t *testing.T) {
|
|||||||
<-disconnectedCh
|
<-disconnectedCh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks that the chardev-remove command is correctly sent.
|
||||||
|
//
|
||||||
|
// We start a QMPLoop, send the chardev-remove command and stop the loop.
|
||||||
|
//
|
||||||
|
// The chardev-remove command should be correctly sent and the QMP loop should
|
||||||
|
// exit gracefully.
|
||||||
|
func TestQMPChardevDel(t *testing.T) {
|
||||||
|
connectedCh := make(chan *QMPVersion)
|
||||||
|
disconnectedCh := make(chan struct{})
|
||||||
|
buf := newQMPTestCommandBuffer(t)
|
||||||
|
buf.AddCommand("chardev-remove", nil, "return", nil)
|
||||||
|
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||||
|
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||||
|
q.version = checkVersion(t, connectedCh)
|
||||||
|
err := q.ExecuteChardevDel(context.Background(), "chardev-0")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unexpected error %v", err)
|
||||||
|
}
|
||||||
|
q.Shutdown()
|
||||||
|
<-disconnectedCh
|
||||||
|
}
|
||||||
|
|
||||||
// Checks that the device_del command is correctly sent.
|
// Checks that the device_del command is correctly sent.
|
||||||
//
|
//
|
||||||
// We start a QMPLoop, send the device_del command and wait for it to complete.
|
// We start a QMPLoop, send the device_del command and wait for it to complete.
|
||||||
|
Loading…
Reference in New Issue
Block a user