diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 87e82bbc81d7611d9899a3b1a1b221f4360577da..7c6e42dbc9ee1002e88dbb7b79c5748bcf6b301d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13598,26 +13598,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (!(vm = qemuDomObjFromDomain(dom))) return -1; + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + priv = vm->privateData; cfg = virQEMUDriverGetConfig(driver); if (!(caps = virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - 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; - } + goto endjob; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; + if (!(device = qemuDiskPathToAlias(vm, disk, &idx))) + goto endjob; if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) @@ -13667,6 +13658,13 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, } 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 * values; likewise if the user didn't specify iops * limits. */ @@ -13691,9 +13689,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { sa_assert(persistentDef); - idx = virDomainDiskIndexByName(persistentDef, disk, true); - if (idx < 0) - goto endjob; oldinfo = &persistentDef->disks[idx]->blkdeviotune; if (!set_bytes) { info.total_bytes_sec = oldinfo->total_bytes_sec; @@ -13715,7 +13710,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, } endjob: - if (qemuDomainObjEndJob(driver, vm) == 0) + if (!qemuDomainObjEndJob(driver, vm)) vm = NULL; cleanup: