The 'device' field reported by 'query-block' is empty when -blockdev is used. Add an argument which will allow matching disk by using the qdev id so we can use this code with -blockdev.
Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_monitor.c | 8 +++++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 21 ++++++++++++++------- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 36ec0a2346..d11e990443 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18603,7 +18603,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (!(device = qemuAliasDiskDriveFromDisk(disk))) goto endjob; qemuDomainObjEnterMonitor(driver, vm); - ret = qemuMonitorGetBlockIoThrottle(priv->mon, device, &reply); + ret = qemuMonitorGetBlockIoThrottle(priv->mon, device, NULL, &reply); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto endjob; if (ret < 0) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2902c3b246..758942ffcb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3465,14 +3465,16 @@ qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon, - const char *device, + const char *drivealias, + const char *qdevid, virDomainBlockIoTuneInfoPtr reply) { - VIR_DEBUG("device=%p, reply=%p", device, reply); + VIR_DEBUG("drivealias=%s, qdevid=%s, reply=%p", + NULLSTR(drivealias), NULLSTR(qdevid), reply); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONGetBlockIoThrottle(mon, device, reply); + return qemuMonitorJSONGetBlockIoThrottle(mon, drivealias, qdevid, reply); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 16fc75819f..60418422e9 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -940,7 +940,8 @@ int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, bool supportMaxLengthOptions); int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon, - const char *device, + const char *drivealias, + const char *qdevid, virDomainBlockIoTuneInfoPtr reply); int qemuMonitorSystemWakeup(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3a1dfb8563..e43447dc53 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4818,7 +4818,8 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, } static int qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, - const char *device, + const char *drivealias, + const char *qdevid, virDomainBlockIoTuneInfoPtr reply) { int ret = -1; @@ -4828,7 +4829,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, for (i = 0; i < virJSONValueArraySize(io_throttle); i++) { virJSONValuePtr temp_dev = virJSONValueArrayGet(io_throttle, i); virJSONValuePtr inserted; - const char *current_dev; + const char *current_drive; + const char *current_qdev; if (!temp_dev || virJSONValueGetType(temp_dev) != VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4837,14 +4839,18 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, goto cleanup; } - if (!(current_dev = virJSONValueObjectGetString(temp_dev, "device"))) { + current_qdev = virJSONValueObjectGetString(temp_dev, "qdev"); + current_drive = virJSONValueObjectGetString(temp_dev, "device"); + + if (!current_drive && !current_qdev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("block_io_throttle device entry " "was not in expected format")); goto cleanup; } - if (STRNEQ(current_dev, device)) + if ((drivealias && STRNEQ(current_drive, drivealias)) || + (qdevid && STRNEQ(current_qdev, qdevid))) continue; found = true; @@ -4885,7 +4891,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, if (!found) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find throttling info for device '%s'"), - device); + drivealias ? drivealias : qdevid); goto cleanup; } ret = 0; @@ -4996,7 +5002,8 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, } int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, - const char *device, + const char *drivealias, + const char *qdevid, virDomainBlockIoTuneInfoPtr reply) { int ret = -1; @@ -5005,7 +5012,7 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, if (!(devices = qemuMonitorJSONQueryBlock(mon))) return -1; - ret = qemuMonitorJSONBlockIoThrottleInfo(devices, device, reply); + ret = qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply); virJSONValueFree(devices); return ret; } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 47635f14b1..4d75e04183 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -335,7 +335,8 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, bool supportMaxLengthOptions); int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, - const char *device, + const char *drivealias, + const char *qdevid, virDomainBlockIoTuneInfoPtr reply); int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index b39d8cd0b8..35d24cfb22 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2139,7 +2139,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data) goto cleanup; if (qemuMonitorJSONGetBlockIoThrottle(qemuMonitorTestGetMonitor(test), - "drive-virtio-disk0", &info) < 0) + "drive-virtio-disk0", NULL, &info) < 0) goto cleanup; if (testValidateGetBlockIoThrottle(&info, &expectedInfo) < 0) -- 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list