[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/30] hmp: Allow using qdev ID for qemu-io command
From: |
Kevin Wolf |
Subject: |
[PULL 29/30] hmp: Allow using qdev ID for qemu-io command |
Date: |
Thu, 19 Dec 2019 18:24:40 +0100 |
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 <address@hidden>
---
monitor/hmp-cmds.c | 28 ++++++++++++++++++----------
hmp-commands.hx | 8 +++++---
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index b2551c16d1..5f8941d298 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -2468,23 +2468,31 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
{
BlockBackend *blk;
BlockBackend *local_blk = NULL;
+ bool qdev = qdict_get_try_bool(qdict, "qdev", false);
const char* device = qdict_get_str(qdict, "device");
const char* command = qdict_get_str(qdict, "command");
Error *err = NULL;
int ret;
- blk = blk_by_name(device);
- if (!blk) {
- BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
- if (bs) {
- blk = local_blk = blk_new(bdrv_get_aio_context(bs),
- 0, BLK_PERM_ALL);
- ret = blk_insert_bs(blk, bs, &err);
- if (ret < 0) {
+ if (qdev) {
+ blk = blk_by_qdev_id(device, &err);
+ if (!blk) {
+ goto fail;
+ }
+ } else {
+ blk = blk_by_name(device);
+ if (!blk) {
+ BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
+ if (bs) {
+ blk = local_blk = blk_new(bdrv_get_aio_context(bs),
+ 0, BLK_PERM_ALL);
+ ret = blk_insert_bs(blk, bs, &err);
+ if (ret < 0) {
+ goto fail;
+ }
+ } else {
goto fail;
}
- } else {
- goto fail;
}
}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index cfcc044ce4..dc23185de4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1875,9 +1875,11 @@ ETEXI
{
.name = "qemu-io",
- .args_type = "device:B,command:s",
- .params = "[device] \"[command]\"",
- .help = "run a qemu-io command on a block device",
+ .args_type = "qdev:-d,device:B,command:s",
+ .params = "[-d] [device] \"[command]\"",
+ .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,
},
--
2.20.1
- [PULL 19/30] iotests: 255: Drop blockdev_create(), (continued)
- [PULL 19/30] iotests: 255: Drop blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 20/30] iotests: 206: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 21/30] iotests: 210: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 22/30] iotests: 212: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 23/30] iotests: 213: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 28/30] block: Activate recursively even for already active nodes, Kevin Wolf, 2019/12/19
- [PULL 30/30] iotests: Test external snapshot with VM state, Kevin Wolf, 2019/12/19
- [PULL 24/30] iotests: 237: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 27/30] iotests: 211: Remove duplication with VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 25/30] iotests: 266: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 29/30] hmp: Allow using qdev ID for qemu-io command,
Kevin Wolf <=
- [PULL 26/30] iotests: 207: Remove duplication with VM.blockdev_create(), Kevin Wolf, 2019/12/19