From 4d7d1c4bc342d97bff229cde75d057f9824866ff Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 9 Feb 2017 10:16:12 +0100 Subject: [PATCH] qemu_cgroup: Kill qemuSetupHostUSBDeviceCgroup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need for this function. Currently it is passed as a callback to virUSBDeviceFileIterate(). However, USB devices have just one file path. Therefore we can mimic approach used in qemuDomainGetHostdevPath() to get path and call virCgroupAllowDevicePath() directly. Signed-off-by: Michal Privoznik Reviewed-by: Marc-André Lureau --- src/qemu/qemu_cgroup.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 6c90d46d17..7302c43ee8 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -260,23 +260,6 @@ qemuSetupInputCgroup(virDomainObjPtr vm, } -static int -qemuSetupHostUSBDeviceCgroup(virUSBDevicePtr dev ATTRIBUTE_UNUSED, - const char *path, - void *opaque) -{ - virDomainObjPtr vm = opaque; - qemuDomainObjPrivatePtr priv = vm->privateData; - int ret; - - VIR_DEBUG("Process path '%s' for USB device", path); - ret = virCgroupAllowDevicePath(priv->cgroup, path, - VIR_CGROUP_DEVICE_RW, false); - virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, "rw", ret == 0); - - return ret; -} - static int qemuSetupHostSCSIDeviceCgroup(virSCSIDevicePtr dev ATTRIBUTE_UNUSED, const char *path, @@ -333,6 +316,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, virSCSIDevicePtr scsi = NULL; virSCSIVHostDevicePtr host = NULL; char *path = NULL; + int rv; /* currently this only does something for PCI devices using vfio * for device assignment, but it is called for *all* hostdev @@ -347,8 +331,6 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, switch ((virDomainHostdevSubsysType) dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { - int rv; - pci = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, pcisrc->addr.slot, @@ -381,13 +363,15 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, goto cleanup; } - /* oddly, qemuSetupHostUSBDeviceCgroup doesn't ever - * reference the usb object we just created - */ - if (virUSBDeviceFileIterate(usb, qemuSetupHostUSBDeviceCgroup, - vm) < 0) { + if (VIR_STRDUP(path, virUSBDeviceGetPath(usb)) < 0) + goto cleanup; + + VIR_DEBUG("Process path '%s' for USB device", path); + rv = virCgroupAllowDevicePath(priv->cgroup, path, + VIR_CGROUP_DEVICE_RW, false); + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, "rw", rv == 0); + if (rv < 0) goto cleanup; - } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {