qemu: remove unneeded cleanup labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2019-11-12 17:46:27 -03:00 committed by Michal Privoznik
parent f4db846c32
commit 6c63adc4a0
9 changed files with 169 additions and 311 deletions

View File

@ -1076,7 +1076,6 @@ qemuSetupCgroup(virDomainObjPtr vm,
int *nicindexes) int *nicindexes)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
if (!vm->pid) { if (!vm->pid) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -1091,23 +1090,21 @@ qemuSetupCgroup(virDomainObjPtr vm,
return 0; return 0;
if (qemuSetupDevicesCgroup(vm) < 0) if (qemuSetupDevicesCgroup(vm) < 0)
goto cleanup; return -1;
if (qemuSetupBlkioCgroup(vm) < 0) if (qemuSetupBlkioCgroup(vm) < 0)
goto cleanup; return -1;
if (qemuSetupMemoryCgroup(vm) < 0) if (qemuSetupMemoryCgroup(vm) < 0)
goto cleanup; return -1;
if (qemuSetupCpuCgroup(vm) < 0) if (qemuSetupCpuCgroup(vm) < 0)
goto cleanup; return -1;
if (qemuSetupCpusetCgroup(vm) < 0) if (qemuSetupCpusetCgroup(vm) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
int int

View File

@ -2293,7 +2293,6 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
{ {
g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf); g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
int ret = -1;
if (src->nodestorage || src->nodeformat) { if (src->nodestorage || src->nodeformat) {
virBufferAddLit(buf, "<nodenames>\n"); virBufferAddLit(buf, "<nodenames>\n");
@ -2308,7 +2307,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias); virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias);
if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0) if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
goto cleanup; return -1;
if (srcPriv) { if (srcPriv) {
qemuStorageSourcePrivateDataFormatSecinfo(&tmp, srcPriv->secinfo, "auth"); qemuStorageSourcePrivateDataFormatSecinfo(&tmp, srcPriv->secinfo, "auth");
@ -2320,10 +2319,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virXMLFormatElement(buf, "objects", NULL, &tmp); virXMLFormatElement(buf, "objects", NULL, &tmp);
ret = 0; return 0;
cleanup:
return ret;
} }
@ -2598,7 +2594,6 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
{ {
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
int ret = -1;
virBufferAsprintf(&attrBuf, " type='%s' format='%s'", virBufferAsprintf(&attrBuf, " type='%s' format='%s'",
virStorageTypeToString(src->type), virStorageTypeToString(src->type),
@ -2606,14 +2601,11 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false, if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false,
VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0) VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
goto cleanup; return -1;
virXMLFormatElement(buf, "migrationSource", &attrBuf, &childBuf); virXMLFormatElement(buf, "migrationSource", &attrBuf, &childBuf);
ret = 0; return 0;
cleanup:
return ret;
} }
@ -2625,7 +2617,6 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
size_t i; size_t i;
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
qemuDomainDiskPrivatePtr diskPriv; qemuDomainDiskPrivatePtr diskPriv;
int ret = -1;
for (i = 0; i < vm->def->ndisks; i++) { for (i = 0; i < vm->def->ndisks; i++) {
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
@ -2640,15 +2631,12 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf, qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf,
diskPriv->migrSource, diskPriv->migrSource,
priv->driver->xmlopt) < 0) priv->driver->xmlopt) < 0)
goto cleanup; return -1;
virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); virXMLFormatElement(buf, "disk", &attrBuf, &childBuf);
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -2660,7 +2648,6 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
qemuDomainJob job = priv->job.active; qemuDomainJob job = priv->job.active;
int ret = -1;
if (!qemuDomainTrackJob(job)) if (!qemuDomainTrackJob(job))
job = QEMU_JOB_NONE; job = QEMU_JOB_NONE;
@ -2684,17 +2671,14 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT && if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm) < 0) qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm) < 0)
goto cleanup; return -1;
if (priv->job.migParams) if (priv->job.migParams)
qemuMigrationParamsFormat(&childBuf, priv->job.migParams); qemuMigrationParamsFormat(&childBuf, priv->job.migParams);
virXMLFormatElement(buf, "job", &attrBuf, &childBuf); virXMLFormatElement(buf, "job", &attrBuf, &childBuf);
ret = 0; return 0;
cleanup:
return ret;
} }
@ -4013,11 +3997,10 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
bool addDefaultUSBKBD = false; bool addDefaultUSBKBD = false;
bool addDefaultUSBMouse = false; bool addDefaultUSBMouse = false;
bool addPanicDevice = false; bool addPanicDevice = false;
int ret = -1;
/* add implicit input devices */ /* add implicit input devices */
if (qemuDomainDefAddImplicitInputDevice(def) < 0) if (qemuDomainDefAddImplicitInputDevice(def) < 0)
goto cleanup; return -1;
/* Add implicit PCI root controller if the machine has one */ /* Add implicit PCI root controller if the machine has one */
switch (def->os.arch) { switch (def->os.arch) {
@ -4130,12 +4113,12 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
if (addDefaultUSB && if (addDefaultUSB &&
virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0 && virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0 &&
virDomainDefAddUSBController(def, 0, usbModel) < 0) virDomainDefAddUSBController(def, 0, usbModel) < 0)
goto cleanup; return -1;
if (addImplicitSATA && if (addImplicitSATA &&
virDomainDefMaybeAddController( virDomainDefMaybeAddController(
def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0) def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0)
goto cleanup; return -1;
pciRoot = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0); pciRoot = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
@ -4150,11 +4133,11 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
"model='pci-root' for this machine type, " "model='pci-root' for this machine type, "
"but model='%s' was found instead"), "but model='%s' was found instead"),
virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model)); virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model));
goto cleanup; return -1;
} }
} else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0, } else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)) { VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)) {
goto cleanup; return -1;
} }
} }
@ -4173,18 +4156,18 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
"model='pcie-root' for this machine type, " "model='pcie-root' for this machine type, "
"but model='%s' was found instead"), "but model='%s' was found instead"),
virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model)); virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model));
goto cleanup; return -1;
} }
} else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0, } else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) { VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) {
goto cleanup; return -1;
} }
} }
if (addDefaultMemballoon && !def->memballoon) { if (addDefaultMemballoon && !def->memballoon) {
virDomainMemballoonDefPtr memballoon; virDomainMemballoonDefPtr memballoon;
if (VIR_ALLOC(memballoon) < 0) if (VIR_ALLOC(memballoon) < 0)
goto cleanup; return -1;
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO; memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO;
def->memballoon = memballoon; def->memballoon = memballoon;
@ -4219,14 +4202,14 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
virDomainDefMaybeAddInput(def, virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_KBD, VIR_DOMAIN_INPUT_TYPE_KBD,
VIR_DOMAIN_INPUT_BUS_USB) < 0) VIR_DOMAIN_INPUT_BUS_USB) < 0)
goto cleanup; return -1;
if (addDefaultUSBMouse && if (addDefaultUSBMouse &&
def->ngraphics > 0 && def->ngraphics > 0 &&
virDomainDefMaybeAddInput(def, virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_BUS_USB) < 0) VIR_DOMAIN_INPUT_BUS_USB) < 0)
goto cleanup; return -1;
if (addPanicDevice) { if (addPanicDevice) {
size_t j; size_t j;
@ -4245,14 +4228,12 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
VIR_APPEND_ELEMENT_COPY(def->panics, VIR_APPEND_ELEMENT_COPY(def->panics,
def->npanics, panic) < 0) { def->npanics, panic) < 0) {
VIR_FREE(panic); VIR_FREE(panic);
goto cleanup; return -1;
} }
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -13338,19 +13319,16 @@ qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
{ {
const char *const *devices = (const char *const *) cfg->cgroupDeviceACL; const char *const *devices = (const char *const *) cfg->cgroupDeviceACL;
size_t i; size_t i;
int ret = -1;
if (!devices) if (!devices)
devices = defaultDeviceACL; devices = defaultDeviceACL;
for (i = 0; devices[i]; i++) { for (i = 0; devices[i]; i++) {
if (qemuDomainCreateDevice(devices[i], data, true) < 0) if (qemuDomainCreateDevice(devices[i], data, true) < 0)
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -13699,7 +13677,6 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
const struct qemuDomainCreateDeviceData *data) const struct qemuDomainCreateDeviceData *data)
{ {
virDomainLoaderDefPtr loader = vm->def->os.loader; virDomainLoaderDefPtr loader = vm->def->os.loader;
int ret = -1;
VIR_DEBUG("Setting up loader"); VIR_DEBUG("Setting up loader");
@ -13707,16 +13684,16 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
switch ((virDomainLoader) loader->type) { switch ((virDomainLoader) loader->type) {
case VIR_DOMAIN_LOADER_TYPE_ROM: case VIR_DOMAIN_LOADER_TYPE_ROM:
if (qemuDomainCreateDevice(loader->path, data, false) < 0) if (qemuDomainCreateDevice(loader->path, data, false) < 0)
goto cleanup; return -1;
break; break;
case VIR_DOMAIN_LOADER_TYPE_PFLASH: case VIR_DOMAIN_LOADER_TYPE_PFLASH:
if (qemuDomainCreateDevice(loader->path, data, false) < 0) if (qemuDomainCreateDevice(loader->path, data, false) < 0)
goto cleanup; return -1;
if (loader->nvram && if (loader->nvram &&
qemuDomainCreateDevice(loader->nvram, data, false) < 0) qemuDomainCreateDevice(loader->nvram, data, false) < 0)
goto cleanup; return -1;
break; break;
case VIR_DOMAIN_LOADER_TYPE_NONE: case VIR_DOMAIN_LOADER_TYPE_NONE:
@ -13726,9 +13703,7 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
} }
VIR_DEBUG("Setup loader"); VIR_DEBUG("Setup loader");
ret = 0; return 0;
cleanup:
return ret;
} }
@ -14318,7 +14293,6 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver G_GNUC_UNUSED,
char * const *devMountsPath, char * const *devMountsPath,
size_t ndevMountsPath) size_t ndevMountsPath)
{ {
int ret = -1;
size_t i; size_t i;
if (STRPREFIX(file, QEMU_DEVPREFIX)) { if (STRPREFIX(file, QEMU_DEVPREFIX)) {
@ -14333,13 +14307,11 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver G_GNUC_UNUSED,
if (virProcessRunInMountNamespace(vm->pid, if (virProcessRunInMountNamespace(vm->pid,
qemuDomainDetachDeviceUnlinkHelper, qemuDomainDetachDeviceUnlinkHelper,
(void *)file) < 0) (void *)file) < 0)
goto cleanup; return -1;
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -223,7 +223,6 @@ static int
qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
{ {
size_t i; size_t i;
int ret = -1;
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */ /* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
@ -234,7 +233,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0) if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0)
goto cleanup; return -1;
} }
for (i = 0; i < def->ncontrollers; i++) { for (i = 0; i < def->ncontrollers; i++) {
@ -246,7 +245,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
} }
if (qemuDomainAssignSpaprVIOAddress(def, &cont->info, if (qemuDomainAssignSpaprVIOAddress(def, &cont->info,
VIO_ADDR_SCSI) < 0) { VIO_ADDR_SCSI) < 0) {
goto cleanup; return -1;
} }
} }
@ -257,7 +256,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
} }
if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info, if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
VIO_ADDR_SERIAL) < 0) VIO_ADDR_SERIAL) < 0)
goto cleanup; return -1;
} }
if (def->nvram) { if (def->nvram) {
@ -265,15 +264,12 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &def->nvram->info, if (qemuDomainAssignSpaprVIOAddress(def, &def->nvram->info,
VIO_ADDR_NVRAM) < 0) VIO_ADDR_NVRAM) < 0)
goto cleanup; return -1;
} }
/* No other devices are currently supported on spapr-vio */ /* No other devices are currently supported on spapr-vio */
ret = 0; return 0;
cleanup:
return ret;
} }
@ -1376,7 +1372,6 @@ static int
qemuDomainSetupIsolationGroups(virDomainDefPtr def) qemuDomainSetupIsolationGroups(virDomainDefPtr def)
{ {
int idx; int idx;
int ret = -1;
/* Only pSeries guests care about isolation groups at the moment */ /* Only pSeries guests care about isolation groups at the moment */
if (!qemuDomainIsPSeries(def)) if (!qemuDomainIsPSeries(def))
@ -1384,7 +1379,7 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def)
idx = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0); idx = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
if (idx < 0) if (idx < 0)
goto cleanup; return -1;
/* We want to prevent hostdevs from being plugged into the default PHB: /* We want to prevent hostdevs from being plugged into the default PHB:
* we can make sure that doesn't happen by locking its isolation group */ * we can make sure that doesn't happen by locking its isolation group */
@ -1394,13 +1389,10 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def)
if (virDomainDeviceInfoIterate(def, if (virDomainDeviceInfoIterate(def,
qemuDomainFillDeviceIsolationGroupIter, qemuDomainFillDeviceIsolationGroupIter,
NULL) < 0) { NULL) < 0) {
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -1500,7 +1492,6 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED,
void *opaque) void *opaque)
{ {
virDomainPCIAddressSetPtr addrs = opaque; virDomainPCIAddressSetPtr addrs = opaque;
int ret = -1;
virPCIDeviceAddressPtr addr = &info->addr.pci; virPCIDeviceAddressPtr addr = &info->addr.pci;
if (!virDeviceInfoPCIAddressIsPresent(info) || if (!virDeviceInfoPCIAddressIsPresent(info) ||
@ -1577,12 +1568,10 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED,
if (virDomainPCIAddressReserveAddr(addrs, addr, if (virDomainPCIAddressReserveAddr(addrs, addr,
info->pciConnectFlags, info->pciConnectFlags,
info->isolationGroup) < 0) { info->isolationGroup) < 0) {
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int

View File

@ -3661,7 +3661,6 @@ static int
qemuDumpWaitForCompletion(virDomainObjPtr vm) qemuDumpWaitForCompletion(virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
VIR_DEBUG("Waiting for dump completion"); VIR_DEBUG("Waiting for dump completion");
while (!priv->job.dumpCompleted && !priv->job.abortJob) { while (!priv->job.dumpCompleted && !priv->job.abortJob) {
@ -3678,14 +3677,11 @@ qemuDumpWaitForCompletion(virDomainObjPtr vm)
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("memory-only dump failed for unknown reason")); _("memory-only dump failed for unknown reason"));
goto cleanup; return -1;
} }
qemuDomainJobInfoUpdateTime(priv->job.current); qemuDomainJobInfoUpdateTime(priv->job.current);
ret = 0; return 0;
cleanup:
return ret;
} }
@ -3727,21 +3723,19 @@ qemuDumpToFd(virQEMUDriverPtr driver,
_("unsupported dumpformat '%s' " _("unsupported dumpformat '%s' "
"for this QEMU binary"), "for this QEMU binary"),
dumpformat); dumpformat);
ret = -1;
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
goto cleanup; return -1;
} }
} }
ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach); ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach);
if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0) if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0)
goto cleanup; return -1;
if (detach) if (detach)
ret = qemuDumpWaitForCompletion(vm); ret = qemuDumpWaitForCompletion(vm);
cleanup:
return ret; return ret;
} }
@ -7404,13 +7398,12 @@ static int qemuConnectListDefinedDomains(virConnectPtr conn,
int ret = -1; int ret = -1;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0) if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
goto cleanup; return -1;
ret = virDomainObjListGetInactiveNames(driver->domains, names, nnames, ret = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
virConnectListDefinedDomainsCheckACL, virConnectListDefinedDomainsCheckACL,
conn); conn);
cleanup:
return ret; return ret;
} }
@ -7420,13 +7413,12 @@ static int qemuConnectNumOfDefinedDomains(virConnectPtr conn)
int ret = -1; int ret = -1;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0) if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
goto cleanup; return -1;
ret = virDomainObjListNumOfDomains(driver->domains, false, ret = virDomainObjListNumOfDomains(driver->domains, false,
virConnectNumOfDefinedDomainsCheckACL, virConnectNumOfDefinedDomainsCheckACL,
conn); conn);
cleanup:
return ret; return ret;
} }
@ -7962,22 +7954,21 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
virDomainDiskDefPtr disk = dev->data.disk; virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL; virDomainDiskDefPtr orig_disk = NULL;
virDomainDeviceDef oldDev = { .type = dev->type }; virDomainDeviceDef oldDev = { .type = dev->type };
int ret = -1;
if (!(orig_disk = virDomainDiskByTarget(vm->def, disk->dst))) { if (!(orig_disk = virDomainDiskByTarget(vm->def, disk->dst))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("disk '%s' not found"), disk->dst); _("disk '%s' not found"), disk->dst);
goto cleanup; return -1;
} }
oldDev.data.disk = orig_disk; oldDev.data.disk = orig_disk;
if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev, if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev,
VIR_DOMAIN_DEVICE_ACTION_UPDATE, VIR_DOMAIN_DEVICE_ACTION_UPDATE,
true) < 0) true) < 0)
goto cleanup; return -1;
if (!qemuDomainDiskChangeSupported(disk, orig_disk)) if (!qemuDomainDiskChangeSupported(disk, orig_disk))
goto cleanup; return -1;
if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) { if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) {
/* Disk source can be changed only for removable devices */ /* Disk source can be changed only for removable devices */
@ -7986,12 +7977,12 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk source can be changed only in removable " _("disk source can be changed only in removable "
"drives")); "drives"));
goto cleanup; return -1;
} }
if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk, if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
dev->data.disk->src, force) < 0) dev->data.disk->src, force) < 0)
goto cleanup; return -1;
dev->data.disk->src = NULL; dev->data.disk->src = NULL;
} }
@ -7999,9 +7990,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
orig_disk->startupPolicy = dev->data.disk->startupPolicy; orig_disk->startupPolicy = dev->data.disk->startupPolicy;
orig_disk->snapshot = dev->data.disk->snapshot; orig_disk->snapshot = dev->data.disk->snapshot;
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -12327,20 +12316,16 @@ qemuConnectDomainEventRegister(virConnectPtr conn,
virFreeCallback freecb) virFreeCallback freecb)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectDomainEventRegisterEnsureACL(conn) < 0) if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virDomainEventStateRegister(conn, if (virDomainEventStateRegister(conn,
driver->domainEventState, driver->domainEventState,
callback, opaque, freecb) < 0) callback, opaque, freecb) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -12349,20 +12334,16 @@ qemuConnectDomainEventDeregister(virConnectPtr conn,
virConnectDomainEventCallback callback) virConnectDomainEventCallback callback)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectDomainEventDeregisterEnsureACL(conn) < 0) if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virDomainEventStateDeregister(conn, if (virDomainEventStateDeregister(conn,
driver->domainEventState, driver->domainEventState,
callback) < 0) callback) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -12378,7 +12359,7 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
int ret = -1; int ret = -1;
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0) if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virDomainEventStateRegisterID(conn, if (virDomainEventStateRegisterID(conn,
driver->domainEventState, driver->domainEventState,
@ -12386,7 +12367,6 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
callback, opaque, freecb, &ret) < 0) callback, opaque, freecb, &ret) < 0)
ret = -1; ret = -1;
cleanup:
return ret; return ret;
} }
@ -12396,20 +12376,16 @@ qemuConnectDomainEventDeregisterAny(virConnectPtr conn,
int callbackID) int callbackID)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0) if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virObjectEventStateDeregisterID(conn, if (virObjectEventStateDeregisterID(conn,
driver->domainEventState, driver->domainEventState,
callbackID, true) < 0) callbackID, true) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -15029,7 +15005,6 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
int ret = -1;
size_t i; size_t i;
bool active = virDomainObjIsActive(vm); bool active = virDomainObjIsActive(vm);
bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0; bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
@ -15043,7 +15018,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
if (disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && if (disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_NONE &&
qemuDomainDiskBlockJobIsActive(dom_disk)) qemuDomainDiskBlockJobIsActive(dom_disk))
goto cleanup; return -1;
switch ((virDomainSnapshotLocation) disk->snapshot) { switch ((virDomainSnapshotLocation) disk->snapshot) {
case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL: case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL:
@ -15054,12 +15029,12 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
_("active qemu domains require external disk " _("active qemu domains require external disk "
"snapshots; disk %s requested internal"), "snapshots; disk %s requested internal"),
disk->name); disk->name);
goto cleanup; return -1;
} }
if (qemuDomainSnapshotPrepareDiskInternal(dom_disk, if (qemuDomainSnapshotPrepareDiskInternal(dom_disk,
active) < 0) active) < 0)
goto cleanup; return -1;
if (vm->def->disks[i]->src->format > 0 && if (vm->def->disks[i]->src->format > 0 &&
vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) { vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) {
@ -15069,7 +15044,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
disk->name, disk->name,
virStorageFileFormatTypeToString( virStorageFileFormatTypeToString(
vm->def->disks[i]->src->format)); vm->def->disks[i]->src->format));
goto cleanup; return -1;
} }
break; break;
@ -15083,12 +15058,12 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
"is unsupported: %s"), "is unsupported: %s"),
disk->name, disk->name,
virStorageFileFormatTypeToString(disk->src->format)); virStorageFileFormatTypeToString(disk->src->format));
goto cleanup; return -1;
} }
if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk, if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk,
active, reuse, blockdev) < 0) active, reuse, blockdev) < 0)
goto cleanup; return -1;
external++; external++;
break; break;
@ -15104,7 +15079,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST: case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path")); _("unexpected code path"));
goto cleanup; return -1;
} }
} }
@ -15112,7 +15087,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nothing selected for snapshot")); _("nothing selected for snapshot"));
goto cleanup; return -1;
} }
/* internal snapshot requires a disk image to store the memory image to, and /* internal snapshot requires a disk image to store the memory image to, and
@ -15122,7 +15097,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("internal and full system snapshots require all " _("internal and full system snapshots require all "
"disks to be selected for snapshot")); "disks to be selected for snapshot"));
goto cleanup; return -1;
} }
/* disk snapshot requires at least one disk */ /* disk snapshot requires at least one disk */
@ -15130,7 +15105,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk-only snapshots require at least " _("disk-only snapshots require at least "
"one disk to be selected for snapshot")); "one disk to be selected for snapshot"));
goto cleanup; return -1;
} }
/* For now, we don't allow mixing internal and external disks. /* For now, we don't allow mixing internal and external disks.
@ -15142,7 +15117,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("mixing internal and external targets for a snapshot " _("mixing internal and external targets for a snapshot "
"is not yet supported")); "is not yet supported"));
goto cleanup; return -1;
} }
/* internal snapshots + pflash based loader have the following problems: /* internal snapshots + pflash based loader have the following problems:
@ -15159,17 +15134,14 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("internal snapshots of a VM with pflash based " _("internal snapshots of a VM with pflash based "
"firmware are not supported")); "firmware are not supported"));
goto cleanup; return -1;
} }
/* Alter flags to let later users know what we learned. */ /* Alter flags to let later users know what we learned. */
if (external && !active) if (external && !active)
*flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY; *flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -17440,7 +17412,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
case QEMU_BLOCKJOB_TYPE_LAST: case QEMU_BLOCKJOB_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid job type '%d'"), job->type); _("invalid job type '%d'"), job->type);
goto cleanup; return -1;
case QEMU_BLOCKJOB_TYPE_PULL: case QEMU_BLOCKJOB_TYPE_PULL:
case QEMU_BLOCKJOB_TYPE_COMMIT: case QEMU_BLOCKJOB_TYPE_COMMIT:
@ -17449,7 +17421,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("job type '%s' does not support pivot"), _("job type '%s' does not support pivot"),
qemuBlockjobTypeToString(job->type)); qemuBlockjobTypeToString(job->type));
goto cleanup; return -1;
case QEMU_BLOCKJOB_TYPE_COPY: case QEMU_BLOCKJOB_TYPE_COPY:
case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
@ -17460,7 +17432,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
_("block job '%s' not ready for pivot yet"), _("block job '%s' not ready for pivot yet"),
job->name); job->name);
goto cleanup; return -1;
} }
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
@ -17468,20 +17440,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
ret = qemuMonitorJobComplete(priv->mon, job->name); ret = qemuMonitorJobComplete(priv->mon, job->name);
else else
ret = qemuMonitorDrivePivot(priv->mon, job->name); ret = qemuMonitorDrivePivot(priv->mon, job->name);
if (qemuDomainObjExitMonitor(driver, vm) < 0) { if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1; return -1;
goto cleanup;
}
/* The pivot failed. The block job in QEMU remains in the synchronised state */ /* The pivot failed. The block job in QEMU remains in the synchronised state */
if (ret < 0) if (ret < 0)
goto cleanup; return -1;
if (disk && disk->mirror) if (disk && disk->mirror)
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT;
job->state = QEMU_BLOCKJOB_STATE_PIVOTING; job->state = QEMU_BLOCKJOB_STATE_PIVOTING;
cleanup:
return ret; return ret;
} }
@ -19826,18 +19795,14 @@ qemuConnectListAllDomains(virConnectPtr conn,
unsigned int flags) unsigned int flags)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1); virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0) if (virConnectListAllDomainsEnsureACL(conn) < 0)
goto cleanup; return -1;
ret = virDomainObjListExport(driver->domains, conn, domains, return virDomainObjListExport(driver->domains, conn, domains,
virConnectListAllDomainsCheckACL, flags); virConnectListAllDomainsCheckACL, flags);
cleanup:
return ret;
} }
static char * static char *
@ -19899,7 +19864,7 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
int ret = -1; int ret = -1;
if (virConnectDomainQemuMonitorEventRegisterEnsureACL(conn) < 0) if (virConnectDomainQemuMonitorEventRegisterEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virDomainQemuMonitorEventStateRegisterID(conn, if (virDomainQemuMonitorEventStateRegisterID(conn,
driver->domainEventState, driver->domainEventState,
@ -19908,7 +19873,6 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
&ret) < 0) &ret) < 0)
ret = -1; ret = -1;
cleanup:
return ret; return ret;
} }
@ -19918,19 +19882,15 @@ qemuConnectDomainQemuMonitorEventDeregister(virConnectPtr conn,
int callbackID) int callbackID)
{ {
virQEMUDriverPtr driver = conn->privateData; virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectDomainQemuMonitorEventDeregisterEnsureACL(conn) < 0) if (virConnectDomainQemuMonitorEventDeregisterEnsureACL(conn) < 0)
goto cleanup; return -1;
if (virObjectEventStateDeregisterID(conn, driver->domainEventState, if (virObjectEventStateDeregisterID(conn, driver->domainEventState,
callbackID, true) < 0) callbackID, true) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -20812,13 +20772,12 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver G_GNUC_UNUSED,
{ {
size_t i; size_t i;
struct _virDomainInterfaceStats tmp; struct _virDomainInterfaceStats tmp;
int ret = -1;
if (!virDomainObjIsActive(dom)) if (!virDomainObjIsActive(dom))
return 0; return 0;
if (virTypedParamListAddUInt(params, dom->def->nnets, "net.count") < 0) if (virTypedParamListAddUInt(params, dom->def->nnets, "net.count") < 0)
goto cleanup; return -1;
/* Check the path is one of the domain's network interfaces. */ /* Check the path is one of the domain's network interfaces. */
for (i = 0; i < dom->def->nnets; i++) { for (i = 0; i < dom->def->nnets; i++) {
@ -20833,7 +20792,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver G_GNUC_UNUSED,
actualType = virDomainNetGetActualType(net); actualType = virDomainNetGetActualType(net);
if (virTypedParamListAddString(params, net->ifname, "net.%zu.name", i) < 0) if (virTypedParamListAddString(params, net->ifname, "net.%zu.name", i) < 0)
goto cleanup; return -1;
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
if (virNetDevOpenvswitchInterfaceStats(net->ifname, &tmp) < 0) { if (virNetDevOpenvswitchInterfaceStats(net->ifname, &tmp) < 0) {
@ -20866,9 +20825,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver G_GNUC_UNUSED,
"tx.drop", tmp.tx_drop); "tx.drop", tmp.tx_drop);
} }
ret = 0; return 0;
cleanup:
return ret;
} }
#undef QEMU_ADD_NET_PARAM #undef QEMU_ADD_NET_PARAM

View File

@ -3325,7 +3325,7 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
if (!oldbridge || !newbridge) { if (!oldbridge || !newbridge) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing bridge name")); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing bridge name"));
return ret; return -1;
} }
VIR_DEBUG("Change bridge for interface %s: %s -> %s", VIR_DEBUG("Change bridge for interface %s: %s -> %s",
@ -3334,7 +3334,7 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
if (virNetDevExists(newbridge) != 1) { if (virNetDevExists(newbridge) != 1) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("bridge %s doesn't exist"), newbridge); _("bridge %s doesn't exist"), newbridge);
return ret; return -1;
} }
ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname); ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname);
@ -4003,20 +4003,19 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
const char *type = virDomainGraphicsTypeToString(dev->type); const char *type = virDomainGraphicsTypeToString(dev->type);
size_t i; size_t i;
int ret = -1;
if (!olddev) { if (!olddev) {
virReportError(VIR_ERR_DEVICE_MISSING, virReportError(VIR_ERR_DEVICE_MISSING,
_("cannot find existing graphics device to modify of " _("cannot find existing graphics device to modify of "
"type '%s'"), type); "type '%s'"), type);
return ret; return -1;
} }
if (dev->nListens != olddev->nListens) { if (dev->nListens != olddev->nListens) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change the number of listen addresses " _("cannot change the number of listen addresses "
"on '%s' graphics"), type); "on '%s' graphics"), type);
return ret; return -1;
} }
for (i = 0; i < dev->nListens; i++) { for (i = 0; i < dev->nListens; i++) {
@ -4027,7 +4026,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change the type of listen address " _("cannot change the type of listen address "
"on '%s' graphics"), type); "on '%s' graphics"), type);
return ret; return -1;
} }
switch (newlisten->type) { switch (newlisten->type) {
@ -4036,7 +4035,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting " _("cannot change listen address setting "
"on '%s' graphics"), type); "on '%s' graphics"), type);
return ret; return -1;
} }
break; break;
@ -4046,7 +4045,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting " _("cannot change listen address setting "
"on '%s' graphics"), type); "on '%s' graphics"), type);
return ret; return -1;
} }
break; break;
@ -4056,7 +4055,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen socket setting " _("cannot change listen socket setting "
"on '%s' graphics"), type); "on '%s' graphics"), type);
return ret; return -1;
} }
break; break;
@ -4074,12 +4073,12 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
(olddev->data.vnc.port != dev->data.vnc.port))) { (olddev->data.vnc.port != dev->data.vnc.port))) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change port settings on vnc graphics")); _("cannot change port settings on vnc graphics"));
return ret; return -1;
} }
if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) { if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change keymap setting on vnc graphics")); _("cannot change keymap setting on vnc graphics"));
return ret; return -1;
} }
/* If a password lifetime was, or is set, or action if connected has /* If a password lifetime was, or is set, or action if connected has
@ -4092,13 +4091,12 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
dev->data.vnc.auth.passwd)) { dev->data.vnc.auth.passwd)) {
VIR_DEBUG("Updating password on VNC server %p %p", VIR_DEBUG("Updating password on VNC server %p %p",
dev->data.vnc.auth.passwd, cfg->vncPassword); dev->data.vnc.auth.passwd, cfg->vncPassword);
ret = qemuDomainChangeGraphicsPasswords(driver, vm, if (qemuDomainChangeGraphicsPasswords(driver, vm,
VIR_DOMAIN_GRAPHICS_TYPE_VNC, VIR_DOMAIN_GRAPHICS_TYPE_VNC,
&dev->data.vnc.auth, &dev->data.vnc.auth,
cfg->vncPassword, cfg->vncPassword,
QEMU_ASYNC_JOB_NONE); QEMU_ASYNC_JOB_NONE) < 0)
if (ret < 0) return -1;
return ret;
/* Steal the new dev's char * reference */ /* Steal the new dev's char * reference */
VIR_FREE(olddev->data.vnc.auth.passwd); VIR_FREE(olddev->data.vnc.auth.passwd);
@ -4107,8 +4105,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo; olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo;
olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires; olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires;
olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected; olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected;
} else {
ret = 0;
} }
break; break;
@ -4120,13 +4116,13 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
(olddev->data.spice.tlsPort != dev->data.spice.tlsPort))) { (olddev->data.spice.tlsPort != dev->data.spice.tlsPort))) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change port settings on spice graphics")); _("cannot change port settings on spice graphics"));
return ret; return -1;
} }
if (STRNEQ_NULLABLE(olddev->data.spice.keymap, if (STRNEQ_NULLABLE(olddev->data.spice.keymap,
dev->data.spice.keymap)) { dev->data.spice.keymap)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change keymap setting on spice graphics")); _("cannot change keymap setting on spice graphics"));
return ret; return -1;
} }
/* We must reset the password if it has changed but also if: /* We must reset the password if it has changed but also if:
@ -4143,14 +4139,12 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
dev->data.spice.auth.passwd)) { dev->data.spice.auth.passwd)) {
VIR_DEBUG("Updating password on SPICE server %p %p", VIR_DEBUG("Updating password on SPICE server %p %p",
dev->data.spice.auth.passwd, cfg->spicePassword); dev->data.spice.auth.passwd, cfg->spicePassword);
ret = qemuDomainChangeGraphicsPasswords(driver, vm, if (qemuDomainChangeGraphicsPasswords(driver, vm,
VIR_DOMAIN_GRAPHICS_TYPE_SPICE, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
&dev->data.spice.auth, &dev->data.spice.auth,
cfg->spicePassword, cfg->spicePassword,
QEMU_ASYNC_JOB_NONE); QEMU_ASYNC_JOB_NONE) < 0)
return -1;
if (ret < 0)
return ret;
/* Steal the new dev's char * reference */ /* Steal the new dev's char * reference */
VIR_FREE(olddev->data.spice.auth.passwd); VIR_FREE(olddev->data.spice.auth.passwd);
@ -4161,7 +4155,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
olddev->data.spice.auth.connected = dev->data.spice.auth.connected; olddev->data.spice.auth.connected = dev->data.spice.auth.connected;
} else { } else {
VIR_DEBUG("Not updating since password didn't change"); VIR_DEBUG("Not updating since password didn't change");
ret = 0;
} }
break; break;
@ -4178,7 +4171,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
break; break;
} }
return ret; return 0;
} }

View File

@ -53,7 +53,6 @@ VIR_LOG_INIT("qemu.qemu_interface");
int int
qemuInterfaceStartDevice(virDomainNetDefPtr net) qemuInterfaceStartDevice(virDomainNetDefPtr net)
{ {
int ret = -1;
virDomainNetType actualType = virDomainNetGetActualType(net); virDomainNetType actualType = virDomainNetGetActualType(net);
switch (actualType) { switch (actualType) {
@ -71,7 +70,7 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
if (virNetDevBridgeFDBAdd(&net->mac, net->ifname, if (virNetDevBridgeFDBAdd(&net->mac, net->ifname,
VIR_NETDEVBRIDGE_FDB_FLAG_MASTER | VIR_NETDEVBRIDGE_FDB_FLAG_MASTER |
VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0) VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0)
goto cleanup; return -1;
} }
break; break;
@ -84,9 +83,9 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
* some sort of "blip" in the physdev's status. * some sort of "blip" in the physdev's status.
*/ */
if (physdev && virNetDevGetOnline(physdev, &isOnline) < 0) if (physdev && virNetDevGetOnline(physdev, &isOnline) < 0)
goto cleanup; return -1;
if (!isOnline && virNetDevSetOnline(physdev, true) < 0) if (!isOnline && virNetDevSetOnline(physdev, true) < 0)
goto cleanup; return -1;
/* macvtap devices share their MAC address with the guest /* macvtap devices share their MAC address with the guest
* domain, and if they are set online prior to the domain CPUs * domain, and if they are set online prior to the domain CPUs
@ -101,13 +100,13 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
* we are starting the domain CPUs. * we are starting the domain CPUs.
*/ */
if (virNetDevSetOnline(net->ifname, true) < 0) if (virNetDevSetOnline(net->ifname, true) < 0)
goto cleanup; return -1;
break; break;
} }
case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0) if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0)
goto cleanup; return -1;
break; break;
@ -124,9 +123,7 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
break; break;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
/** /**
@ -159,7 +156,6 @@ qemuInterfaceStartDevices(virDomainDefPtr def)
int int
qemuInterfaceStopDevice(virDomainNetDefPtr net) qemuInterfaceStopDevice(virDomainNetDefPtr net)
{ {
int ret = -1;
virDomainNetType actualType = virDomainNetGetActualType(net); virDomainNetType actualType = virDomainNetGetActualType(net);
switch (actualType) { switch (actualType) {
@ -173,7 +169,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
if (virNetDevBridgeFDBDel(&net->mac, net->ifname, if (virNetDevBridgeFDBDel(&net->mac, net->ifname,
VIR_NETDEVBRIDGE_FDB_FLAG_MASTER | VIR_NETDEVBRIDGE_FDB_FLAG_MASTER |
VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0) VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0)
goto cleanup; return -1;
} }
break; break;
@ -186,7 +182,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
* on this network. * on this network.
*/ */
if (virNetDevSetOnline(net->ifname, false) < 0) if (virNetDevSetOnline(net->ifname, false) < 0)
goto cleanup; return -1;
/* also mark the physdev down for passthrough macvtap, as the /* also mark the physdev down for passthrough macvtap, as the
* physdev has the same MAC address as the macvtap device. * physdev has the same MAC address as the macvtap device.
@ -194,7 +190,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
if (virDomainNetGetActualDirectMode(net) == if (virDomainNetGetActualDirectMode(net) ==
VIR_NETDEV_MACVLAN_MODE_PASSTHRU && VIR_NETDEV_MACVLAN_MODE_PASSTHRU &&
physdev && virNetDevSetOnline(physdev, false) < 0) physdev && virNetDevSetOnline(physdev, false) < 0)
goto cleanup; return -1;
break; break;
} }
@ -212,9 +208,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
break; break;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
/** /**

View File

@ -1768,7 +1768,6 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
qemuMigrationCookiePtr cookie) qemuMigrationCookiePtr cookie)
{ {
virDomainNetDefPtr netptr; virDomainNetDefPtr netptr;
int ret = -1;
size_t i; size_t i;
for (i = 0; i < cookie->network->nnets; i++) { for (i = 0; i < cookie->network->nnets; i++) {
@ -1785,7 +1784,7 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to run command to set OVS port data for " _("Unable to run command to set OVS port data for "
"interface %s"), netptr->ifname); "interface %s"), netptr->ifname);
goto cleanup; return -1;
} }
break; break;
default: default:
@ -1793,9 +1792,7 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -1846,7 +1843,6 @@ qemuMigrationDstRun(virQEMUDriverPtr driver,
qemuDomainAsyncJob asyncJob) qemuDomainAsyncJob asyncJob)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
int rv; int rv;
VIR_DEBUG("Setting up incoming migration with URI %s", uri); VIR_DEBUG("Setting up incoming migration with URI %s", uri);
@ -1857,21 +1853,17 @@ qemuMigrationDstRun(virQEMUDriverPtr driver,
rv = qemuMonitorMigrateIncoming(priv->mon, uri); rv = qemuMonitorMigrateIncoming(priv->mon, uri);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
goto cleanup; return -1;
if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) { if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) {
/* qemuMigrationDstWaitForCompletion is called from the Finish phase */ /* qemuMigrationDstWaitForCompletion is called from the Finish phase */
ret = 0; return 0;
goto cleanup;
} }
if (qemuMigrationDstWaitForCompletion(driver, vm, asyncJob, false) < 0) if (qemuMigrationDstWaitForCompletion(driver, vm, asyncJob, false) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -4657,9 +4649,9 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) { if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
flags) < 0) flags) < 0)
goto cleanup; return ret;
} else if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_OUT)) { } else if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_OUT)) {
goto cleanup; return ret;
} }
qemuMigrationJobStartPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3); qemuMigrationJobStartPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3);
@ -4694,7 +4686,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
if (!virDomainObjIsActive(vm)) if (!virDomainObjIsActive(vm))
qemuDomainRemoveInactiveJob(driver, vm); qemuDomainRemoveInactiveJob(driver, vm);
cleanup:
return ret; return ret;
} }
@ -5318,7 +5309,6 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
bool storage = false; bool storage = false;
size_t i; size_t i;
int ret = -1;
VIR_DEBUG("Canceling unfinished outgoing migration of domain %s", VIR_DEBUG("Canceling unfinished outgoing migration of domain %s",
vm->def->name); vm->def->name);
@ -5326,7 +5316,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ignore_value(qemuMonitorMigrateCancel(priv->mon)); ignore_value(qemuMonitorMigrateCancel(priv->mon));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup; return -1;
for (i = 0; i < vm->def->ndisks; i++) { for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i]; virDomainDiskDefPtr disk = vm->def->disks[i];
@ -5348,12 +5338,9 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
if (storage && if (storage &&
qemuMigrationSrcNBDCopyCancel(driver, vm, false, qemuMigrationSrcNBDCopyCancel(driver, vm, false,
QEMU_ASYNC_JOB_NONE, NULL) < 0) QEMU_ASYNC_JOB_NONE, NULL) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -2243,24 +2243,21 @@ qemuProcessRefreshPRManagerState(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMonitorPRManagerInfoPtr prManagerInfo; qemuMonitorPRManagerInfoPtr prManagerInfo;
const char *managedAlias = qemuDomainGetManagedPRAlias(); const char *managedAlias = qemuDomainGetManagedPRAlias();
int ret = -1;
if (!(prManagerInfo = virHashLookup(info, managedAlias))) { if (!(prManagerInfo = virHashLookup(info, managedAlias))) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("missing info on pr-manager %s"), _("missing info on pr-manager %s"),
managedAlias); managedAlias);
goto cleanup; return -1;
} }
priv->prDaemonRunning = prManagerInfo->connected; priv->prDaemonRunning = prManagerInfo->connected;
if (!priv->prDaemonRunning && if (!priv->prDaemonRunning &&
qemuProcessStartManagedPRDaemon(vm) < 0) qemuProcessStartManagedPRDaemon(vm) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -4982,16 +4979,15 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics; virDomainGraphicsDefPtr graphics;
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
size_t i; size_t i;
int ret = -1;
for (i = 0; i < vm->def->ngraphics; i++) { for (i = 0; i < vm->def->ngraphics; i++) {
graphics = vm->def->graphics[i]; graphics = vm->def->graphics[i];
if (qemuProcessGraphicsSetupRenderNode(graphics, qemuCaps) < 0) if (qemuProcessGraphicsSetupRenderNode(graphics, qemuCaps) < 0)
goto cleanup; return -1;
if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0) if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0)
goto cleanup; return -1;
} }
if (allocate) { if (allocate) {
@ -4999,7 +4995,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
graphics = vm->def->graphics[i]; graphics = vm->def->graphics[i];
if (qemuProcessGraphicsReservePorts(graphics, false) < 0) if (qemuProcessGraphicsReservePorts(graphics, false) < 0)
goto cleanup; return -1;
} }
} }
@ -5007,13 +5003,10 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
graphics = vm->def->graphics[i]; graphics = vm->def->graphics[i];
if (qemuProcessGraphicsAllocatePorts(driver, graphics, allocate) < 0) if (qemuProcessGraphicsAllocatePorts(driver, graphics, allocate) < 0)
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -5114,20 +5107,15 @@ qemuProcessMakeDir(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *path) const char *path)
{ {
int ret = -1;
if (virFileMakePathWithMode(path, 0750) < 0) { if (virFileMakePathWithMode(path, 0750) < 0) {
virReportSystemError(errno, _("Cannot create directory '%s'"), path); virReportSystemError(errno, _("Cannot create directory '%s'"), path);
goto cleanup; return -1;
} }
if (qemuSecurityDomainSetPathLabel(driver, vm, path, true) < 0) if (qemuSecurityDomainSetPathLabel(driver, vm, path, true) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -8443,7 +8431,6 @@ static int
qemuProcessQMPInit(qemuProcessQMPPtr proc) qemuProcessQMPInit(qemuProcessQMPPtr proc)
{ {
char *template = NULL; char *template = NULL;
int ret = -1;
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary); VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
@ -8454,11 +8441,11 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
_("Failed to create unique directory with " _("Failed to create unique directory with "
"template '%s' for probing QEMU"), "template '%s' for probing QEMU"),
template); template);
goto cleanup; return -1;
} }
if (qemuProcessQEMULabelUniqPath(proc) < 0) if (qemuProcessQEMULabelUniqPath(proc) < 0)
goto cleanup; return -1;
proc->monpath = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.monitor"); proc->monpath = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.monitor");
@ -8471,10 +8458,7 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
*/ */
proc->pidfile = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.pid"); proc->pidfile = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.pid");
ret = 0; return 0;
cleanup:
return ret;
} }
@ -8483,7 +8467,6 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
{ {
const char *machine; const char *machine;
int status = 0; int status = 0;
int ret = -1;
int rc; int rc;
if (proc->forceTCG) if (proc->forceTCG)
@ -8527,7 +8510,7 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
virCommandSetErrorBuffer(proc->cmd, &(proc->stdErr)); virCommandSetErrorBuffer(proc->cmd, &(proc->stdErr));
if (virCommandRun(proc->cmd, &status) < 0) if (virCommandRun(proc->cmd, &status) < 0)
goto cleanup; return -1;
if (status != 0) { if (status != 0) {
VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status); VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status);
@ -8535,18 +8518,15 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
_("Failed to start QEMU binary %s for probing: %s"), _("Failed to start QEMU binary %s for probing: %s"),
proc->binary, proc->binary,
proc->stdErr ? proc->stdErr : _("unknown error")); proc->stdErr ? proc->stdErr : _("unknown error"));
goto cleanup; return -1;
} }
if ((rc = virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) { if ((rc = virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) {
virReportSystemError(-rc, _("Failed to read pidfile %s"), proc->pidfile); virReportSystemError(-rc, _("Failed to read pidfile %s"), proc->pidfile);
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -8619,21 +8599,16 @@ qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
int int
qemuProcessQMPStart(qemuProcessQMPPtr proc) qemuProcessQMPStart(qemuProcessQMPPtr proc)
{ {
int ret = -1;
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary); VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
if (qemuProcessQMPInit(proc) < 0) if (qemuProcessQMPInit(proc) < 0)
goto cleanup; return -1;
if (qemuProcessQMPLaunch(proc) < 0) if (qemuProcessQMPLaunch(proc) < 0)
goto cleanup; return -1;
if (qemuProcessQMPConnectMonitor(proc) < 0) if (qemuProcessQMPConnectMonitor(proc) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -314,8 +314,6 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
uid_t qemu_user, uid_t qemu_user,
const char *shortName) const char *shortName)
{ {
int ret = -1;
if (virTPMEmulatorInit() < 0) if (virTPMEmulatorInit() < 0)
return -1; return -1;
@ -326,7 +324,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
/* ... and adjust ownership */ /* ... and adjust ownership */
if (virDirCreate(logDir, 0730, swtpm_user, swtpm_group, if (virDirCreate(logDir, 0730, swtpm_user, swtpm_group,
VIR_DIR_CREATE_ALLOW_EXIST) < 0) VIR_DIR_CREATE_ALLOW_EXIST) < 0)
goto cleanup; return -1;
/* create logfile name ... */ /* create logfile name ... */
if (!tpm->data.emulator.logfile) if (!tpm->data.emulator.logfile)
@ -334,7 +332,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
if (!virFileExists(tpm->data.emulator.logfile) && if (!virFileExists(tpm->data.emulator.logfile) &&
virFileTouch(tpm->data.emulator.logfile, 0644) < 0) { virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
goto cleanup; return -1;
} }
/* ... and make sure it can be accessed by swtpm_user */ /* ... and make sure it can be accessed by swtpm_user */
@ -342,7 +340,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
virReportSystemError(errno, virReportSystemError(errno,
_("Could not chown on swtpm logfile %s"), _("Could not chown on swtpm logfile %s"),
tpm->data.emulator.logfile); tpm->data.emulator.logfile);
goto cleanup; return -1;
} }
/* /*
@ -354,20 +352,16 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
*/ */
if (virDirCreate(swtpmStateDir, 0770, qemu_user, swtpm_group, if (virDirCreate(swtpmStateDir, 0770, qemu_user, swtpm_group,
VIR_DIR_CREATE_ALLOW_EXIST) < 0) VIR_DIR_CREATE_ALLOW_EXIST) < 0)
goto cleanup; return -1;
/* create the socket filename */ /* create the socket filename */
if (!tpm->data.emulator.source.data.nix.path && if (!tpm->data.emulator.source.data.nix.path &&
!(tpm->data.emulator.source.data.nix.path = !(tpm->data.emulator.source.data.nix.path =
qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName))) qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName)))
goto cleanup; return -1;
tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_UNIX; tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
ret = 0; return 0;
cleanup:
return ret;
} }
/* /*