]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_ns: Allow /dev/mapper/control for PR
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 9 Apr 2018 12:44:44 +0000 (14:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 May 2018 07:02:56 +0000 (09:02 +0200)
If qemu-pr-helper is compiled with multipath support the first
thing it does is open /dev/mapper/control. Since we're going
to be running it inside qemu namespace we need to create it
there. Unfortunately, we don't know if it was compiled with or
without multipath so we have to create it anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c

index f43b8602ae3462ef3740859e81ad9b5db922b8d4..d107bceb0eb742ec694ad3625364696db8f8a1fc 100644 (file)
@@ -109,6 +109,7 @@ VIR_ENUM_IMPL(qemuDomainNamespace, QEMU_DOMAIN_NS_LAST,
 #define PROC_MOUNTS "/proc/mounts"
 #define DEVPREFIX "/dev/"
 #define DEV_VFIO "/dev/vfio/vfio"
+#define DEVICE_MAPPER_CONTROL_PATH "/dev/mapper/control"
 
 
 struct _qemuDomainLogContext {
@@ -10213,6 +10214,11 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
             goto cleanup;
     }
 
+    /* qemu-pr-helper might require access to /dev/mapper/control. */
+    if (virStoragePRDefIsEnabled(disk->src->pr) &&
+        qemuDomainCreateDevice(DEVICE_MAPPER_CONTROL_PATH, data, true) < 0)
+        goto cleanup;
+
     ret = 0;
  cleanup:
     VIR_FREE(dst);
@@ -11224,6 +11230,7 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
     virStorageSourcePtr next;
     const char **paths = NULL;
     size_t npaths = 0;
+    char *dmPath = NULL;
     int ret = -1;
 
     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
@@ -11240,11 +11247,18 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
             goto cleanup;
     }
 
+    /* qemu-pr-helper might require access to /dev/mapper/control. */
+    if (virStoragePRDefIsEnabled(src->pr) &&
+        (VIR_STRDUP(dmPath, DEVICE_MAPPER_CONTROL_PATH) < 0 ||
+         VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0))
+        goto cleanup;
+
     if (qemuDomainNamespaceMknodPaths(vm, paths, npaths) < 0)
         goto cleanup;
 
     ret = 0;
  cleanup:
+    VIR_FREE(dmPath);
     VIR_FREE(paths);
     return ret;
 }