qemu: Drop some 'cleanup' labels

Previous patches rendered some of 'cleanup' labels needless.
Drop them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Michal Privoznik 2019-09-17 11:57:04 +02:00
parent 3a4787a301
commit cfce298042
2 changed files with 29 additions and 46 deletions

View File

@ -377,13 +377,13 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
g_autofree char *path = NULL; g_autofree char *path = NULL;
int perms; int perms;
int rv, ret = -1; int rv;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
return 0; return 0;
if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0) if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0)
goto cleanup; return -1;
VIR_DEBUG("Cgroup allow %s perms=%d", path, perms); VIR_DEBUG("Cgroup allow %s perms=%d", path, perms);
rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false); rv = virCgroupAllowDevicePath(priv->cgroup, path, perms, false);
@ -391,7 +391,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
virCgroupGetDevicePermsString(perms), virCgroupGetDevicePermsString(perms),
rv); rv);
if (rv < 0) if (rv < 0)
goto cleanup; return -1;
if (qemuHostdevNeedsVFIO(dev)) { if (qemuHostdevNeedsVFIO(dev)) {
VIR_DEBUG("Cgroup allow %s perms=%d", QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW); VIR_DEBUG("Cgroup allow %s perms=%d", QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW);
@ -400,13 +400,10 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
QEMU_DEV_VFIO, "rw", rv); QEMU_DEV_VFIO, "rw", rv);
if (rv < 0) if (rv < 0)
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -427,13 +424,13 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
g_autofree char *path = NULL; g_autofree char *path = NULL;
int rv, ret = -1; int rv;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
return 0; return 0;
if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
goto cleanup; return -1;
VIR_DEBUG("Cgroup deny %s", path); VIR_DEBUG("Cgroup deny %s", path);
rv = virCgroupDenyDevicePath(priv->cgroup, path, rv = virCgroupDenyDevicePath(priv->cgroup, path,
@ -441,7 +438,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
virDomainAuditCgroupPath(vm, priv->cgroup, virDomainAuditCgroupPath(vm, priv->cgroup,
"deny", path, "rwm", rv); "deny", path, "rwm", rv);
if (rv < 0) if (rv < 0)
goto cleanup; return -1;
if (qemuHostdevNeedsVFIO(dev) && if (qemuHostdevNeedsVFIO(dev) &&
!qemuDomainNeedsVFIO(vm->def)) { !qemuDomainNeedsVFIO(vm->def)) {
@ -451,12 +448,10 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
virDomainAuditCgroupPath(vm, priv->cgroup, "deny", virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
QEMU_DEV_VFIO, "rwm", rv); QEMU_DEV_VFIO, "rwm", rv);
if (rv < 0) if (rv < 0)
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }

View File

@ -13840,7 +13840,6 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
char **path, char **path,
int *perms) int *perms)
{ {
int ret = -1;
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb; virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci; virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
@ -13864,10 +13863,10 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
pcisrc->addr.slot, pcisrc->addr.slot,
pcisrc->addr.function); pcisrc->addr.function);
if (!pci) if (!pci)
goto cleanup; return -1;
if (!(tmpPath = virPCIDeviceGetIOMMUGroupDev(pci))) if (!(tmpPath = virPCIDeviceGetIOMMUGroupDev(pci)))
goto cleanup; return -1;
perm = VIR_CGROUP_DEVICE_RW; perm = VIR_CGROUP_DEVICE_RW;
} }
@ -13880,7 +13879,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
usbsrc->device, usbsrc->device,
NULL); NULL);
if (!usb) if (!usb)
goto cleanup; return -1;
tmpPath = g_strdup(virUSBDeviceGetPath(usb)); tmpPath = g_strdup(virUSBDeviceGetPath(usb));
perm = VIR_CGROUP_DEVICE_RW; perm = VIR_CGROUP_DEVICE_RW;
@ -13901,7 +13900,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
dev->shareable); dev->shareable);
if (!scsi) if (!scsi)
goto cleanup; return -1;
tmpPath = g_strdup(virSCSIDeviceGetPath(scsi)); tmpPath = g_strdup(virSCSIDeviceGetPath(scsi));
perm = virSCSIDeviceGetReadonly(scsi) ? perm = virSCSIDeviceGetReadonly(scsi) ?
@ -13913,7 +13912,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
if (hostsrc->protocol == if (hostsrc->protocol ==
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST) { VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST) {
if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn))) if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
goto cleanup; return -1;
tmpPath = g_strdup(virSCSIVHostDeviceGetPath(host)); tmpPath = g_strdup(virSCSIVHostDeviceGetPath(host));
perm = VIR_CGROUP_DEVICE_RW; perm = VIR_CGROUP_DEVICE_RW;
@ -13923,7 +13922,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr)))
goto cleanup; return -1;
perm = VIR_CGROUP_DEVICE_RW; perm = VIR_CGROUP_DEVICE_RW;
break; break;
@ -13941,9 +13940,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
*path = g_steal_pointer(&tmpPath); *path = g_steal_pointer(&tmpPath);
if (perms) if (perms)
*perms = perm; *perms = perm;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -14442,22 +14439,19 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,
const struct qemuDomainCreateDeviceData *data) const struct qemuDomainCreateDeviceData *data)
{ {
int ret = -1;
g_autofree char *path = NULL; g_autofree char *path = NULL;
if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0)
goto cleanup; return -1;
if (qemuDomainCreateDevice(path, data, false) < 0) if (qemuDomainCreateDevice(path, data, false) < 0)
goto cleanup; return -1;
if (qemuHostdevNeedsVFIO(dev) && if (qemuHostdevNeedsVFIO(dev) &&
qemuDomainCreateDevice(QEMU_DEV_VFIO, data, false) < 0) qemuDomainCreateDevice(QEMU_DEV_VFIO, data, false) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -15490,23 +15484,20 @@ int
qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm, qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
virDomainHostdevDefPtr hostdev) virDomainHostdevDefPtr hostdev)
{ {
int ret = -1;
g_autofree char *path = NULL; g_autofree char *path = NULL;
if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0)
goto cleanup; return -1;
if (qemuDomainNamespaceMknodPath(vm, path) < 0) if (qemuDomainNamespaceMknodPath(vm, path) < 0)
goto cleanup; return -1;
if (qemuHostdevNeedsVFIO(hostdev) && if (qemuHostdevNeedsVFIO(hostdev) &&
!qemuDomainNeedsVFIO(vm->def) && !qemuDomainNeedsVFIO(vm->def) &&
qemuDomainNamespaceMknodPath(vm, QEMU_DEV_VFIO) < 0) qemuDomainNamespaceMknodPath(vm, QEMU_DEV_VFIO) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -15525,23 +15516,20 @@ int
qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm, qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
virDomainHostdevDefPtr hostdev) virDomainHostdevDefPtr hostdev)
{ {
int ret = -1;
g_autofree char *path = NULL; g_autofree char *path = NULL;
if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0)
goto cleanup; return -1;
if (qemuDomainNamespaceUnlinkPath(vm, path) < 0) if (qemuDomainNamespaceUnlinkPath(vm, path) < 0)
goto cleanup; return -1;
if (qemuHostdevNeedsVFIO(hostdev) && if (qemuHostdevNeedsVFIO(hostdev) &&
!qemuDomainNeedsVFIO(vm->def) && !qemuDomainNeedsVFIO(vm->def) &&
qemuDomainNamespaceUnlinkPath(vm, QEMU_DEV_VFIO) < 0) qemuDomainNamespaceUnlinkPath(vm, QEMU_DEV_VFIO) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }