mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qmp: Update block device deletion for newer versions of qemu
blockdev-del command has been added in qemu 2.9 to replace x-blockdev-del command used earlier for deleting block devices. Update ExecuteXBlockdevDel() to use this updated qmp command. Rename ExecuteXBlockdevDel to ExecuteBlockdevDel as this no longer executes x-block-del command for qemu>=2.9. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
e74aeef1ad
commit
1fbe6c5d1d
14
qmp.go
14
qmp.go
@ -642,13 +642,19 @@ func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, b
|
||||
return q.executeCommand(ctx, "device_add", args, nil)
|
||||
}
|
||||
|
||||
// ExecuteXBlockdevDel deletes a block device by sending a x-blockdev-del command.
|
||||
// ExecuteBlockdevDel deletes a block device by sending a x-blockdev-del command
|
||||
// for qemu versions < 2.9. It sends the updated blockdev-del command for qemu>=2.9.
|
||||
// blockdevID is the id of the block device to be deleted. Typically, this will
|
||||
// match the id passed to ExecuteBlockdevAdd. It must be a valid QMP id.
|
||||
func (q *QMP) ExecuteXBlockdevDel(ctx context.Context, blockdevID string) error {
|
||||
args := map[string]interface{}{
|
||||
"id": blockdevID,
|
||||
func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error {
|
||||
args := map[string]interface{}{}
|
||||
|
||||
if q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 9) {
|
||||
args["node-name"] = blockdevID
|
||||
return q.executeCommand(ctx, "blockdev-del", args, nil)
|
||||
}
|
||||
|
||||
args["id"] = blockdevID
|
||||
return q.executeCommand(ctx, "x-blockdev-del", args, nil)
|
||||
}
|
||||
|
||||
|
@ -406,8 +406,8 @@ func TestQMPXBlockdevDel(t *testing.T) {
|
||||
buf.AddCommand("x-blockdev-del", nil, "return", nil)
|
||||
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||
checkVersion(t, connectedCh)
|
||||
err := q.ExecuteXBlockdevDel(context.Background(),
|
||||
q.version = checkVersion(t, connectedCh)
|
||||
err := q.ExecuteBlockdevDel(context.Background(),
|
||||
fmt.Sprintf("drive_%s", testutil.VolumeUUID))
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user