提交 5af3ce82 编写于 作者: M Martin Kletzander

Fix blkdeviotune for shutoff domain

Function qemuDomainSetBlockIoTune() was checking QEMU capabilities
even when !(flags & VIR_DOMAIN_AFFECT_LIVE) and the domain was
shutoff, resulting in the following problem:

 virsh # domstate asdf; blkdeviotune asdf vda --write-bytes-sec 100
 shut off

 error: Unable to change block I/O throttle
 error: unsupported configuration: block I/O throttling not supported with this QEMU binary

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=965016
上级 eb21408f
...@@ -13918,26 +13918,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -13918,26 +13918,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
return -1; return -1;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
priv = vm->privateData; priv = vm->privateData;
cfg = virQEMUDriverGetConfig(driver); cfg = virQEMUDriverGetConfig(driver);
if (!(caps = virQEMUDriverGetCapabilities(driver, false))) if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup; goto endjob;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("block I/O throttling not supported with this "
"QEMU binary"));
goto cleanup;
}
device = qemuDiskPathToAlias(vm, disk, &idx);
if (!device) {
goto cleanup;
}
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) if (!(device = qemuDiskPathToAlias(vm, disk, &idx)))
goto cleanup; goto endjob;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0) &persistentDef) < 0)
...@@ -13987,6 +13978,13 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -13987,6 +13978,13 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("block I/O throttling not supported with this "
"QEMU binary"));
goto endjob;
}
/* If the user didn't specify bytes limits, inherit previous /* If the user didn't specify bytes limits, inherit previous
* values; likewise if the user didn't specify iops * values; likewise if the user didn't specify iops
* limits. */ * limits. */
...@@ -14011,9 +14009,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -14011,9 +14009,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef); sa_assert(persistentDef);
idx = virDomainDiskIndexByName(persistentDef, disk, true);
if (idx < 0)
goto endjob;
oldinfo = &persistentDef->disks[idx]->blkdeviotune; oldinfo = &persistentDef->disks[idx]->blkdeviotune;
if (!set_bytes) { if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec; info.total_bytes_sec = oldinfo->total_bytes_sec;
...@@ -14035,7 +14030,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -14035,7 +14030,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
} }
endjob: endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) if (!qemuDomainObjEndJob(driver, vm))
vm = NULL; vm = NULL;
cleanup: cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册