hmp: Allow using qdev ID for qemu-io command
In order to issue requests on an existing BlockBackend with the 'qemu-io' HMP command, allow specifying the BlockBackend not only with a BlockBackend name, but also with a qdev ID/QOM path for a device that owns the (possibly anonymous) BlockBackend. Because qdev names could be conflicting with BlockBackend and node names, introduce a -d option to explicitly address a device. If the option is not given, a BlockBackend or a node is addressed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
7bb4941ace
commit
89b6fc4561
@ -1875,9 +1875,11 @@ ETEXI
|
|||||||
|
|
||||||
{
|
{
|
||||||
.name = "qemu-io",
|
.name = "qemu-io",
|
||||||
.args_type = "device:B,command:s",
|
.args_type = "qdev:-d,device:B,command:s",
|
||||||
.params = "[device] \"[command]\"",
|
.params = "[-d] [device] \"[command]\"",
|
||||||
.help = "run a qemu-io command on a block device",
|
.help = "run a qemu-io command on a block device\n\t\t\t"
|
||||||
|
"-d: [device] is a device ID rather than a "
|
||||||
|
"drive ID or node name",
|
||||||
.cmd = hmp_qemu_io,
|
.cmd = hmp_qemu_io,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2468,11 +2468,18 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
|
|||||||
{
|
{
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
BlockBackend *local_blk = NULL;
|
BlockBackend *local_blk = NULL;
|
||||||
|
bool qdev = qdict_get_try_bool(qdict, "qdev", false);
|
||||||
const char* device = qdict_get_str(qdict, "device");
|
const char* device = qdict_get_str(qdict, "device");
|
||||||
const char* command = qdict_get_str(qdict, "command");
|
const char* command = qdict_get_str(qdict, "command");
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (qdev) {
|
||||||
|
blk = blk_by_qdev_id(device, &err);
|
||||||
|
if (!blk) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
blk = blk_by_name(device);
|
blk = blk_by_name(device);
|
||||||
if (!blk) {
|
if (!blk) {
|
||||||
BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
|
BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
|
||||||
@ -2487,6 +2494,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notably absent: Proper permission management. This is sad, but it seems
|
* Notably absent: Proper permission management. This is sad, but it seems
|
||||||
|
Loading…
x
Reference in New Issue
Block a user