提交 52096e23 编写于 作者: P Peter Krempa

qemu: monitor: Allow using 'id' instead of 'device' for 'block_set_io_throttle'

The 'device' argument matches only the legacy drive alias. For blockdev
we need to set the throttling for a QOM id and thus we'll need to use
the 'id' field.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 e7e2bbdc
...@@ -18472,7 +18472,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -18472,7 +18472,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
* via the JSON error code from the block_set_io_throttle call */ * via the JSON error code from the block_set_io_throttle call */
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, NULL,
&info, supportMaxOptions, &info, supportMaxOptions,
set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME, set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME,
supportMaxLengthOptions); supportMaxLengthOptions);
......
...@@ -3444,17 +3444,19 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon, ...@@ -3444,17 +3444,19 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
int int
qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device, const char *drivealias,
const char *qomid,
virDomainBlockIoTuneInfoPtr info, virDomainBlockIoTuneInfoPtr info,
bool supportMaxOptions, bool supportMaxOptions,
bool supportGroupNameOption, bool supportGroupNameOption,
bool supportMaxLengthOptions) bool supportMaxLengthOptions)
{ {
VIR_DEBUG("device=%p, info=%p", device, info); VIR_DEBUG("drivealias=%s, qomid=%s, info=%p",
NULLSTR(drivealias), NULLSTR(qomid), info);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONSetBlockIoThrottle(mon, device, info, return qemuMonitorJSONSetBlockIoThrottle(mon, drivealias, qomid, info,
supportMaxOptions, supportMaxOptions,
supportGroupNameOption, supportGroupNameOption,
supportMaxLengthOptions); supportMaxLengthOptions);
......
...@@ -932,7 +932,8 @@ int qemuMonitorOpenGraphics(qemuMonitorPtr mon, ...@@ -932,7 +932,8 @@ int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
bool skipauth); bool skipauth);
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device, const char *drivealias,
const char *qomid,
virDomainBlockIoTuneInfoPtr info, virDomainBlockIoTuneInfoPtr info,
bool supportMaxOptions, bool supportMaxOptions,
bool supportGroupNameOption, bool supportGroupNameOption,
......
...@@ -4897,7 +4897,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, ...@@ -4897,7 +4897,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle,
#undef GET_THROTTLE_STATS_OPTIONAL #undef GET_THROTTLE_STATS_OPTIONAL
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device, const char *drivealias,
const char *qomid,
virDomainBlockIoTuneInfoPtr info, virDomainBlockIoTuneInfoPtr info,
bool supportMaxOptions, bool supportMaxOptions,
bool supportGroupNameOption, bool supportGroupNameOption,
...@@ -4907,12 +4908,17 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, ...@@ -4907,12 +4908,17 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
virJSONValuePtr cmd = NULL; virJSONValuePtr cmd = NULL;
virJSONValuePtr result = NULL; virJSONValuePtr result = NULL;
virJSONValuePtr args = NULL; virJSONValuePtr args = NULL;
const char *errdev = drivealias;
if (!errdev)
errdev = qomid;
if (!(cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle", NULL))) if (!(cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle", NULL)))
return -1; return -1;
if (virJSONValueObjectCreate(&args, if (virJSONValueObjectCreate(&args,
"s:device", device, "S:device", drivealias,
"S:id", qomid,
"U:bps", info->total_bytes_sec, "U:bps", info->total_bytes_sec,
"U:bps_rd", info->read_bytes_sec, "U:bps_rd", info->read_bytes_sec,
"U:bps_wr", info->write_bytes_sec, "U:bps_wr", info->write_bytes_sec,
...@@ -4967,10 +4973,10 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, ...@@ -4967,10 +4973,10 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
if (virJSONValueObjectHasKey(result, "error")) { if (virJSONValueObjectHasKey(result, "error")) {
if (qemuMonitorJSONHasError(result, "DeviceNotActive")) { if (qemuMonitorJSONHasError(result, "DeviceNotActive")) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("No active operation on device: %s"), device); _("No active operation on device: %s"), errdev);
} else if (qemuMonitorJSONHasError(result, "NotSupported")) { } else if (qemuMonitorJSONHasError(result, "NotSupported")) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("Operation is not supported for device: %s"), device); _("Operation is not supported for device: %s"), errdev);
} else { } else {
virJSONValuePtr error = virJSONValueObjectGet(result, "error"); virJSONValuePtr error = virJSONValueObjectGet(result, "error");
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
......
...@@ -327,7 +327,8 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, ...@@ -327,7 +327,8 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
bool skipauth); bool skipauth);
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon, int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device, const char *drivealias,
const char *qomid,
virDomainBlockIoTuneInfoPtr info, virDomainBlockIoTuneInfoPtr info,
bool supportMaxOptions, bool supportMaxOptions,
bool supportGroupNameOption, bool supportGroupNameOption,
......
...@@ -2146,7 +2146,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data) ...@@ -2146,7 +2146,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data)
goto cleanup; goto cleanup;
if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test), if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
"drive-virtio-disk1", &info, true, "drive-virtio-disk1", NULL, &info, true,
true, true) < 0) true, true) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册