提交 343969ba 编写于 作者: P Peter Krempa

qemu: monitor: Allow using 'qdev' instead of 'device' for getting disk throttling

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 52096e23
......@@ -18601,7 +18601,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)
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册