hmp: Allow using a qdev id in block_set_io_throttle
PATCH 1/1 hmp: Allow using a qdev id in block_set_io_throttle
The QMP version of this command can take a qdev ID since 7a9877a02635, but the HMP version is still using the deprecated block device name so there's no way to refer to a block device added like this:
-blockdev node-name=disk0,driver=qcow2,file.driver=file,file.filename=hd.qcow2 -device virtio-blk-pci,id=virtio-blk-pci0,drive=disk0
This patch works around this problem by using the specified name as a qdev ID if the block device name is not found.
--- hmp-commands.hx | 3 ++- hmp.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-)
hmp-commands.hx +2 -1
@@ -1645,7 +1645,8 @@ ETEXI STEXI @item block_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} @findex block_set_io_throttle -Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}. +@var{device} can be a block device name, a qdev ID or a QOM path. ETEXI {
hmp.c +12 -2
@@ -1774,9 +1774,8 @@ void hmp_change(Monitor *mon, const QDict *qdict)void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict) {Error *err =NULL ; +char *device = (char *)qdict_get_str (qdict,"device" );BlockIOThrottle throttle = { - .has_device = true, - .device = (char *)qdict_get_str (qdict,"device" ), .bps =qdict_get_int (qdict,"bps" ), .bps_rd =qdict_get_int (qdict,"bps_rd" ), .bps_wr =qdict_get_int (qdict,"bps_wr" ),
@@ -1785,6 +1784,17 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) .iops_wr = qdict_get_int(qdict, "iops_wr"), }; +/* qmp_block_set_io_throttle has separate parameters for the +* (deprecated) block device name and the qdev ID but the HMP +* version has only one, so we must decide which one to pass. */ +if (blk_by_name (device)) { + throttle.has_device = true; + throttle.device = device; + }else { + throttle.has_id = true; + throttle.id = device; + } +qmp_block_set_io_throttle (&throttle, &err);hmp_handle_error (mon, &err); }
Signature · 1 line
2.11.0
Quoted 7 lines · Alberto Garcia
The QMP version of this command can take a qdev ID since
7a9877a02635, but the HMP version is still using the deprecated block device name so there's no way to refer to a block device added like this:-blockdev node-name=disk0,driver=qcow2,file.driver=file,file.filename=hd.qcow2 -device virtio-blk-pci,id=virtio-blk-pci0,drive=disk0
Quoted 9 lines
This patch works around this problem by using the specified name as a qdev ID if the block device name is not found.
Signed-off-by Alberto Garcia <[email protected]>--- hmp-commands.hx | 3 ++- hmp.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Kevin Wolf
AppliedAm 09.03.2018 um 15:11 hat Alberto Garcia geschrieben:
Quoted 11 lines
The QMP version of this command can take a qdev ID since
7a9877a02635, but the HMP version is still using the deprecated block device name so there's no way to refer to a block device added like this:-blockdev node-name=disk0,driver=qcow2,file.driver=file,file.filename=hd.qcow2 -device virtio-blk-pci,id=virtio-blk-pci0,drive=disk0
This patch works around this problem by using the specified name as a qdev ID if the block device name is not found.
Signed-off-by Alberto Garcia <[email protected]>
Thanks, applied to the block branch.
Kevin