From a6cfd2e03c77fb54c384d66681900e32a80efdb7 Mon Sep 17 00:00:00 2001 Message-Id: From: Michal Privoznik Date: Mon, 11 May 2020 16:40:11 +0200 Subject: [PATCH] virDevMapperGetTargetsImpl: Be tolerant to kernels without DM support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko (cherry picked from commit 170d1e31df064108d064910c77f6316eb6726985) https://bugzilla.redhat.com/show_bug.cgi?id=1823976 Signed-off-by: Michal Privoznik Message-Id: <46a1c183bae2cf5070b54883d7a7540124822049.1589207928.git.mprivozn@redhat.com> Reviewed-by: Jiri Denemark --- src/util/virdevmapper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index b365f20145..7da0dba911 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -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) { -- 2.26.2