{
qemuDomainObjPrivate *priv = vm->privateData;
int stopFlags;
- virCPUDef *origCPU = NULL;
- int ret = -1;
+ g_autoptr(virCPUDef) origCPU = NULL;
VIR_DEBUG("vm=%p name=%s id=%d migration=%d",
vm, vm->def->name, vm->def->id, migration);
if (virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("VM is already active"));
- goto cleanup;
+ return -1;
}
/* in case when the post parse callback failed we need to re-run it on the
/* we don't have the private copy of qemuCaps at this point */
if (virDomainDefPostParse(vm->def, 0, driver->xmlopt, NULL) < 0)
- goto cleanup;
+ return -1;
}
VIR_DEBUG("Determining emulator version");
if (qemuProcessPrepareQEMUCaps(vm, driver->qemuCapsCache) < 0)
- goto cleanup;
+ return -1;
if (qemuDomainUpdateCPU(vm, updatedCPU, &origCPU) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, flags) < 0)
- goto cleanup;
+ return -1;
/* Do this upfront, so any part of the startup process can add
* runtime state to vm->def that won't be persisted. This let's us
*/
VIR_DEBUG("Setting current domain def as transient");
if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < 0)
- goto cleanup;
+ return -1;
if (flags & VIR_QEMU_PROCESS_START_PRETEND) {
if (qemuDomainSetPrivatePaths(driver, vm) < 0) {
virDomainObjRemoveTransientDef(vm);
- goto cleanup;
+ return -1;
}
} else {
vm->def->id = qemuDriverAllocateID(driver);
priv->origCPU = g_steal_pointer(&origCPU);
}
- ret = 0;
-
- cleanup:
- virCPUDefFree(origCPU);
- return ret;
+ return 0;
stop:
stopFlags = VIR_QEMU_PROCESS_STOP_NO_RELABEL;
if (migration)
stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJob, stopFlags);
- goto cleanup;
+ return -1;
}