int configfd = -1;
char *configfd_name = NULL;
bool releaseaddr = false;
+ bool teardowncgroup = false;
int backend = hostdev->source.subsys.u.pci.backend;
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
break;
}
+ if (qemuSetupHostdevCGroup(vm, hostdev) < 0)
+ goto error;
+ teardowncgroup = true;
+
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
goto error;
return 0;
error:
+ if (teardowncgroup && qemuTeardownHostdevCgroup(vm, hostdev) < 0)
+ VIR_WARN("Unable to remove host device cgroup ACL on hotplug fail");
+
if (releaseaddr)
qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL);
virUSBDevicePtr usb = NULL;
char *devstr = NULL;
bool added = false;
+ bool teardowncgroup = false;
int ret = -1;
if (qemuFindHostdevUSBDevice(hostdev, true, &usb) < 0)
added = true;
virUSBDeviceListSteal(list, usb);
+ if (qemuSetupHostdevCGroup(vm, hostdev) < 0)
+ goto cleanup;
+ teardowncgroup = true;
+
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
goto cleanup;
ret = 0;
cleanup:
+ if (ret < 0 &&
+ teardowncgroup &&
+ qemuTeardownHostdevCgroup(vm, hostdev) < 0)
+ VIR_WARN("Unable to remove host device cgroup ACL on hotplug fail");
if (added)
virUSBDeviceListSteal(driver->activeUsbHostdevs, usb);
virUSBDeviceFree(usb);
qemuDomainObjPrivatePtr priv = vm->privateData;
char *devstr = NULL;
char *drvstr = NULL;
+ bool teardowncgroup = false;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE) ||
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) ||
return -1;
}
+ if (qemuSetupHostdevCGroup(vm, hostdev) < 0)
+ goto cleanup;
+ teardowncgroup = true;
+
if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
goto cleanup;
ret = 0;
cleanup:
- if (ret < 0)
+ if (ret < 0) {
qemuDomainReAttachHostScsiDevices(driver, vm->def->name, &hostdev, 1);
+ if (teardowncgroup && qemuTeardownHostdevCgroup(vm, hostdev) < 0)
+ VIR_WARN("Unable to remove host device cgroup ACL on hotplug fail");
+ }
VIR_FREE(drvstr);
VIR_FREE(devstr);
return ret;
return -1;
}
- if (qemuSetupHostdevCGroup(vm, hostdev) < 0)
- return -1;
-
if (virSecurityManagerSetHostdevLabel(driver->securityManager,
vm->def, hostdev, NULL) < 0)
- goto cleanup;
+ return -1;
switch (hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
if (virSecurityManagerRestoreHostdevLabel(driver->securityManager,
vm->def, hostdev, NULL) < 0)
VIR_WARN("Unable to restore host device labelling on hotplug fail");
-
-cleanup:
- if (qemuTeardownHostdevCgroup(vm, hostdev) < 0)
- VIR_WARN("Unable to remove host device cgroup ACL on hotplug fail");
return -1;
}