From 92aa53bd73780647e269b9d207c04aefafa4b9a15b6d014ebbc1eaca529c337e Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Wed, 19 Aug 2020 21:53:01 +0000 Subject: [PATCH] add another device mapper fix OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=838 --- 53d9af1e-ignore-devmapper-open-errors.patch | 74 +++++++++++++++++++++ libvirt.changes | 3 +- libvirt.spec | 2 + 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 53d9af1e-ignore-devmapper-open-errors.patch diff --git a/53d9af1e-ignore-devmapper-open-errors.patch b/53d9af1e-ignore-devmapper-open-errors.patch new file mode 100644 index 0000000..965f9f3 --- /dev/null +++ b/53d9af1e-ignore-devmapper-open-errors.patch @@ -0,0 +1,74 @@ +commit 53d9af1e7924757e3b5f661131dd707d7110d094 +Author: Michal Prívozník +Date: Wed Aug 19 13:35:55 2020 +0200 + + virdevmapper: Ignore all errors when opening /dev/mapper/control + + So far, only ENOENT is ignored (to deal with kernels without + devmapper). However, as reported on the list, under certain + scenarios a different error can occur. For instance, when libvirt + is running inside a container which doesn't have permissions to + talk to the devmapper. If this is the case, then open() returns + -1 and sets errno=EPERM. + + Assuming that multipath devices are fairly narrow use case and + using them in a restricted container is even more narrow the best + fix seems to be to ignore all open errors BUT produce a warning + on failure. To avoid flooding logs with warnings on kernels + without devmapper the level is reduced to a plain debug message. + + Reported-by: Christian Ehrhardt + Reviewed-by: Christian Ehrhardt + Signed-off-by: Michal Privoznik + +Index: libvirt-6.6.0/src/util/virdevmapper.c +=================================================================== +--- libvirt-6.6.0.orig/src/util/virdevmapper.c ++++ libvirt-6.6.0/src/util/virdevmapper.c +@@ -35,9 +35,12 @@ + # include "viralloc.h" + # include "virstring.h" + # include "virfile.h" ++# include "virlog.h" + + # define VIR_FROM_THIS VIR_FROM_STORAGE + ++VIR_LOG_INIT("util.virdevmapper"); ++ + # define PROC_DEVICES "/proc/devices" + # define DM_NAME "device-mapper" + # define DEV_DM_DIR "/dev/" DM_DIR +@@ -130,11 +133,15 @@ virDMOpen(void) + memset(&dm, 0, sizeof(dm)); + + if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) { +- if (errno == ENOENT) +- return -2; +- +- virReportSystemError(errno, _("Unable to open %s"), CONTROL_PATH); +- return -1; ++ /* We can't talk to devmapper. Produce a warning and let ++ * the caller decide what to do next. */ ++ if (errno == ENOENT) { ++ VIR_DEBUG("device mapper not available"); ++ } else { ++ VIR_WARN("unable to open %s: %s", ++ CONTROL_PATH, g_strerror(errno)); ++ } ++ return -2; + } + + if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) { +@@ -310,9 +317,9 @@ virDevMapperGetTargets(const char *path, + + if ((controlFD = virDMOpen()) < 0) { + if (controlFD == -2) { +- /* The CONTROL_PATH doesn't exist. Probably the +- * module isn't loaded, yet. Don't error out, just +- * exit. */ ++ /* The CONTROL_PATH doesn't exist or is unusable. ++ * Probably the module isn't loaded, yet. Don't error ++ * out, just exit. */ + return 0; + } + diff --git a/libvirt.changes b/libvirt.changes index e57170e..e18642d 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -3,7 +3,8 @@ Wed Aug 19 19:36:52 UTC 2020 - James Fehlig - virdevmapper: Handle kernel without device-mapper support 82bb167f-dont-cache-devmapper-major.patch, - feb8564a-handle-no-devmapper.patch + feb8564a-handle-no-devmapper.patch, + 53d9af1e-ignore-devmapper-open-errors.patch boo#1175465 ------------------------------------------------------------------- diff --git a/libvirt.spec b/libvirt.spec index 8e2f6c2..9267ba4 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -339,6 +339,7 @@ Source100: %{name}-rpmlintrc Patch0: 2edd63a0-fix-virFileSetCOW-logic.patch Patch1: 82bb167f-dont-cache-devmapper-major.patch Patch2: feb8564a-handle-no-devmapper.patch +Patch3: 53d9af1e-ignore-devmapper-open-errors.patch # Patches pending upstream review Patch100: libxl-dom-reset.patch Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch @@ -881,6 +882,7 @@ libvirt plugin for NSS for translating domain names into IP addresses. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %patch100 -p1 %patch101 -p1 %patch150 -p1