render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
03cc27
From a6cfd2e03c77fb54c384d66681900e32a80efdb7 Mon Sep 17 00:00:00 2001
03cc27
Message-Id: <a6cfd2e03c77fb54c384d66681900e32a80efdb7@dist-git>
03cc27
From: Michal Privoznik <mprivozn@redhat.com>
03cc27
Date: Mon, 11 May 2020 16:40:11 +0200
03cc27
Subject: [PATCH] virDevMapperGetTargetsImpl: Be tolerant to kernels without DM
03cc27
 support
03cc27
MIME-Version: 1.0
03cc27
Content-Type: text/plain; charset=UTF-8
03cc27
Content-Transfer-Encoding: 8bit
03cc27
03cc27
https://bugzilla.redhat.com/show_bug.cgi?id=1591732
03cc27
03cc27
If kernel is compiled without CONFIG_BLK_DEV_DM enabled, there is
03cc27
no /dev/mapper/control device and since dm_task_create() actually
03cc27
does some ioctl() over it creating a task may fail.
03cc27
To cope with this handle ENOENT and ENODEV gracefully.
03cc27
03cc27
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
03cc27
Reviewed-by: Ján Tomko <jtomko@redhat.com>
03cc27
(cherry picked from commit 170d1e31df064108d064910c77f6316eb6726985)
03cc27
03cc27
https://bugzilla.redhat.com/show_bug.cgi?id=1823976
03cc27
03cc27
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
03cc27
Message-Id: <46a1c183bae2cf5070b54883d7a7540124822049.1589207928.git.mprivozn@redhat.com>
03cc27
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
03cc27
---
03cc27
 src/util/virdevmapper.c | 8 +++++++-
03cc27
 1 file changed, 7 insertions(+), 1 deletion(-)
03cc27
03cc27
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
03cc27
index b365f20145..7da0dba911 100644
03cc27
--- a/src/util/virdevmapper.c
03cc27
+++ b/src/util/virdevmapper.c
03cc27
@@ -87,8 +87,14 @@ virDevMapperGetTargetsImpl(const char *path,
03cc27
         return ret;
03cc27
     }
03cc27
 
03cc27
-    if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
03cc27
+    if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) {
03cc27
+        if (errno == ENOENT || errno == ENODEV) {
03cc27
+            /* It's okay. Kernel is probably built without
03cc27
+             * devmapper support. */
03cc27
+            ret = 0;
03cc27
+        }
03cc27
         return ret;
03cc27
+    }
03cc27
 
03cc27
     if (!dm_task_set_name(dmt, path)) {
03cc27
         if (errno == ENOENT) {
03cc27
-- 
03cc27
2.26.2
03cc27