]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDevMapperGetTargetsImpl: Be tolerant to kernels without DM support
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Jul 2018 12:31:16 +0000 (14:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Jul 2018 14:01:05 +0000 (16:01 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1591732

If kernel is compiled without CONFIG_BLK_DEV_DM enabled, there is
no /dev/mapper/control device and since dm_task_create() actually
does some ioctl() over it creating a task may fail.
To cope with this handle ENOENT and ENODEV gracefully.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virdevmapper.c

index b365f20145f7568befb06b29f0f76baad776e858..7da0dba911bf7b9d5d18d1618278abcbf5d6c335 100644 (file)
@@ -87,8 +87,14 @@ virDevMapperGetTargetsImpl(const char *path,
         return ret;
     }
 
-    if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
+    if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) {
+        if (errno == ENOENT || errno == ENODEV) {
+            /* It's okay. Kernel is probably built without
+             * devmapper support. */
+            ret = 0;
+        }
         return ret;
+    }
 
     if (!dm_task_set_name(dmt, path)) {
         if (errno == ENOENT) {