qemu: Replace virDomainLiveConfigHelperMethod in qemuDomainGetBlockIoTune

Use virDomainObjGetDefs since the API guarantees that both live and
config are never set together.
This commit is contained in:
Peter Krempa 2016-05-20 08:59:18 +02:00
parent 2fde4e724e
commit 6448356f27

View File

@ -17790,12 +17790,12 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
qemuDomainObjPrivatePtr priv = NULL; qemuDomainObjPrivatePtr priv = NULL;
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo reply; virDomainBlockIoTuneInfo reply;
char *device = NULL; char *device = NULL;
int ret = -1; int ret = -1;
size_t i; size_t i;
virCapsPtr caps = NULL;
bool supportMaxOptions = true; bool supportMaxOptions = true;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@ -17808,27 +17808,21 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
return -1; return -1;
if (virDomainGetBlockIoTuneEnsureACL(dom->conn, vm->def) < 0) priv = vm->privateData;
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false))) if (virDomainGetBlockIoTuneEnsureACL(dom->conn, vm->def) < 0)
goto cleanup; goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup; goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, /* the API check guarantees that only one of the definitions will be set */
&persistentDef) < 0) if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto endjob; goto endjob;
sa_assert((flags & VIR_DOMAIN_AFFECT_LIVE) ||
(flags & VIR_DOMAIN_AFFECT_CONFIG));
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (def) {
/* If the VM is running, we can check if the current VM can use /* If the VM is running, we can check if the current VM can use
* optional parameters or not. We didn't made this check sooner * optional parameters or not. */
* because we need vm->privateData which need
* virDomainLiveConfigHelperMethod to do so. */
priv = vm->privateData;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) { if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("block I/O throttling not supported with this " _("block I/O throttling not supported with this "
@ -17845,8 +17839,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
goto endjob; goto endjob;
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (def) {
if (!(disk = qemuDomainDiskByName(vm->def, path))) if (!(disk = qemuDomainDiskByName(def, path)))
goto endjob; goto endjob;
if (!(device = qemuAliasFromDisk(disk))) if (!(device = qemuAliasFromDisk(disk)))
@ -17859,7 +17853,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
goto endjob; goto endjob;
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (persistentDef) {
if (!(disk = virDomainDiskByName(persistentDef, path, true))) { if (!(disk = virDomainDiskByName(persistentDef, path, true))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("disk '%s' was not found in the domain config"), _("disk '%s' was not found in the domain config"),
@ -17981,7 +17975,6 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
cleanup: cleanup:
VIR_FREE(device); VIR_FREE(device);
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps);
return ret; return ret;
} }