[PATCH 06/10] qemuDomain{Attach, Detach}Device NS helpers: Don't relabel devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After previous commit this has become redundant step.
Also setting up devices in namespace and setting their label
later on are two different steps and should be not done at once.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 112 +------------------------------------------------
 1 file changed, 2 insertions(+), 110 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c67604222..0f45f753e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7565,58 +7565,6 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
     }
 #endif
 
-    switch ((virDomainDeviceType) data->devDef->type) {
-    case VIR_DOMAIN_DEVICE_DISK: {
-        virDomainDiskDefPtr def = data->devDef->data.disk;
-        char *tmpsrc = def->src->path;
-        def->src->path = (char *) data->file;
-        if (virSecurityManagerSetDiskLabel(data->driver->securityManager,
-                                           data->vm->def, def) < 0) {
-            def->src->path = tmpsrc;
-            goto cleanup;
-        }
-        def->src->path = tmpsrc;
-    }   break;
-
-    case VIR_DOMAIN_DEVICE_HOSTDEV: {
-        virDomainHostdevDefPtr def = data->devDef->data.hostdev;
-        if (virSecurityManagerSetHostdevLabel(data->driver->securityManager,
-                                              data->vm->def, def, NULL) < 0)
-            goto cleanup;
-    }   break;
-
-    case VIR_DOMAIN_DEVICE_CHR:
-    case VIR_DOMAIN_DEVICE_RNG:
-        /* No labelling. */
-        break;
-
-    case VIR_DOMAIN_DEVICE_NONE:
-    case VIR_DOMAIN_DEVICE_LEASE:
-    case VIR_DOMAIN_DEVICE_FS:
-    case VIR_DOMAIN_DEVICE_NET:
-    case VIR_DOMAIN_DEVICE_INPUT:
-    case VIR_DOMAIN_DEVICE_SOUND:
-    case VIR_DOMAIN_DEVICE_VIDEO:
-    case VIR_DOMAIN_DEVICE_WATCHDOG:
-    case VIR_DOMAIN_DEVICE_CONTROLLER:
-    case VIR_DOMAIN_DEVICE_GRAPHICS:
-    case VIR_DOMAIN_DEVICE_HUB:
-    case VIR_DOMAIN_DEVICE_REDIRDEV:
-    case VIR_DOMAIN_DEVICE_SMARTCARD:
-    case VIR_DOMAIN_DEVICE_MEMBALLOON:
-    case VIR_DOMAIN_DEVICE_NVRAM:
-    case VIR_DOMAIN_DEVICE_SHMEM:
-    case VIR_DOMAIN_DEVICE_TPM:
-    case VIR_DOMAIN_DEVICE_PANIC:
-    case VIR_DOMAIN_DEVICE_MEMORY:
-    case VIR_DOMAIN_DEVICE_IOMMU:
-    case VIR_DOMAIN_DEVICE_LAST:
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Unexpected device type %d"),
-                       data->devDef->type);
-        goto cleanup;
-    }
-
     ret = 0;
  cleanup:
     if (ret < 0 && delDevice)
@@ -7707,67 +7655,11 @@ qemuDomainDetachDeviceUnlinkHelper(pid_t pid ATTRIBUTE_UNUSED,
 
 
 static int
-qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver,
+qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
                              virDomainObjPtr vm,
-                             virDomainDeviceDefPtr dev,
+                             virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
                              const char *file)
 {
-    /* Technically, this is not needed. Yet. But in the future
-     * security managers might do some reference counting over
-     * Set/Restore label and thus for every SetLabel() there
-     * should be corresponding RestoreLabel(). */
-    switch ((virDomainDeviceType) dev->type) {
-    case VIR_DOMAIN_DEVICE_DISK: {
-        virDomainDiskDefPtr def = dev->data.disk;
-        char *tmpsrc = def->src->path;
-        def->src->path = (char *) file;
-        if (virSecurityManagerRestoreDiskLabel(driver->securityManager,
-                                               vm->def, def) < 0) {
-            def->src->path = tmpsrc;
-            return -1;
-        }
-        def->src->path = tmpsrc;
-    }   break;
-
-    case VIR_DOMAIN_DEVICE_HOSTDEV: {
-        virDomainHostdevDefPtr def = dev->data.hostdev;
-        if (virSecurityManagerRestoreHostdevLabel(driver->securityManager,
-                                                  vm->def, def, NULL) < 0)
-            return -1;
-    }   break;
-
-    case VIR_DOMAIN_DEVICE_CHR:
-    case VIR_DOMAIN_DEVICE_RNG:
-        /* No labelling. */
-        break;
-
-    case VIR_DOMAIN_DEVICE_NONE:
-    case VIR_DOMAIN_DEVICE_LEASE:
-    case VIR_DOMAIN_DEVICE_FS:
-    case VIR_DOMAIN_DEVICE_NET:
-    case VIR_DOMAIN_DEVICE_INPUT:
-    case VIR_DOMAIN_DEVICE_SOUND:
-    case VIR_DOMAIN_DEVICE_VIDEO:
-    case VIR_DOMAIN_DEVICE_WATCHDOG:
-    case VIR_DOMAIN_DEVICE_CONTROLLER:
-    case VIR_DOMAIN_DEVICE_GRAPHICS:
-    case VIR_DOMAIN_DEVICE_HUB:
-    case VIR_DOMAIN_DEVICE_REDIRDEV:
-    case VIR_DOMAIN_DEVICE_SMARTCARD:
-    case VIR_DOMAIN_DEVICE_MEMBALLOON:
-    case VIR_DOMAIN_DEVICE_NVRAM:
-    case VIR_DOMAIN_DEVICE_SHMEM:
-    case VIR_DOMAIN_DEVICE_TPM:
-    case VIR_DOMAIN_DEVICE_PANIC:
-    case VIR_DOMAIN_DEVICE_MEMORY:
-    case VIR_DOMAIN_DEVICE_IOMMU:
-    case VIR_DOMAIN_DEVICE_LAST:
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Unexpected device type %d"),
-                       dev->type);
-        return -1;
-    }
-
     if (virProcessRunInMountNamespace(vm->pid,
                                       qemuDomainDetachDeviceUnlinkHelper,
                                       (void *)file) < 0)
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux