|
|
a41c76 |
From b38ab86a0a2cf3453d37a5fe96b2e022d8a1d48a Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <b38ab86a0a2cf3453d37a5fe96b2e022d8a1d48a@dist-git>
|
|
|
a41c76 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Date: Tue, 25 Aug 2020 17:16:07 +0200
|
|
|
a41c76 |
Subject: [PATCH] virdevmapper: Ignore all errors when opening
|
|
|
a41c76 |
/dev/mapper/control
|
|
|
a41c76 |
|
|
|
a41c76 |
So far, only ENOENT is ignored (to deal with kernels without
|
|
|
a41c76 |
devmapper). However, as reported on the list, under certain
|
|
|
a41c76 |
scenarios a different error can occur. For instance, when libvirt
|
|
|
a41c76 |
is running inside a container which doesn't have permissions to
|
|
|
a41c76 |
talk to the devmapper. If this is the case, then open() returns
|
|
|
a41c76 |
-1 and sets errno=EPERM.
|
|
|
a41c76 |
|
|
|
a41c76 |
Assuming that multipath devices are fairly narrow use case and
|
|
|
a41c76 |
using them in a restricted container is even more narrow the best
|
|
|
a41c76 |
fix seems to be to ignore all open errors BUT produce a warning
|
|
|
a41c76 |
on failure. To avoid flooding logs with warnings on kernels
|
|
|
a41c76 |
without devmapper the level is reduced to a plain debug message.
|
|
|
a41c76 |
|
|
|
a41c76 |
Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
|
|
|
a41c76 |
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
|
|
|
a41c76 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 53d9af1e7924757e3b5f661131dd707d7110d094)
|
|
|
a41c76 |
|
|
|
a41c76 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1860421
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Message-Id: <e1b69d69e7d242829995208c6d59ed0477208920.1598364552.git.mprivozn@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/util/virdevmapper.c | 23 +++++++++++++++--------
|
|
|
a41c76 |
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
|
|
|
a41c76 |
index a81e2edee4..ee2fab5ae3 100644
|
|
|
a41c76 |
--- a/src/util/virdevmapper.c
|
|
|
a41c76 |
+++ b/src/util/virdevmapper.c
|
|
|
a41c76 |
@@ -35,9 +35,12 @@
|
|
|
a41c76 |
# include "viralloc.h"
|
|
|
a41c76 |
# include "virstring.h"
|
|
|
a41c76 |
# include "virfile.h"
|
|
|
a41c76 |
+# include "virlog.h"
|
|
|
a41c76 |
|
|
|
a41c76 |
# define VIR_FROM_THIS VIR_FROM_STORAGE
|
|
|
a41c76 |
|
|
|
a41c76 |
+VIR_LOG_INIT("util.virdevmapper");
|
|
|
a41c76 |
+
|
|
|
a41c76 |
# define PROC_DEVICES "/proc/devices"
|
|
|
a41c76 |
# define DM_NAME "device-mapper"
|
|
|
a41c76 |
# define DEV_DM_DIR "/dev/" DM_DIR
|
|
|
a41c76 |
@@ -130,11 +133,15 @@ virDMOpen(void)
|
|
|
a41c76 |
memset(&dm, 0, sizeof(dm));
|
|
|
a41c76 |
|
|
|
a41c76 |
if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) {
|
|
|
a41c76 |
- if (errno == ENOENT)
|
|
|
a41c76 |
- return -2;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- virReportSystemError(errno, _("Unable to open %s"), CONTROL_PATH);
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
+ /* We can't talk to devmapper. Produce a warning and let
|
|
|
a41c76 |
+ * the caller decide what to do next. */
|
|
|
a41c76 |
+ if (errno == ENOENT) {
|
|
|
a41c76 |
+ VIR_DEBUG("device mapper not available");
|
|
|
a41c76 |
+ } else {
|
|
|
a41c76 |
+ VIR_WARN("unable to open %s: %s",
|
|
|
a41c76 |
+ CONTROL_PATH, g_strerror(errno));
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+ return -2;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) {
|
|
|
a41c76 |
@@ -310,9 +317,9 @@ virDevMapperGetTargets(const char *path,
|
|
|
a41c76 |
|
|
|
a41c76 |
if ((controlFD = virDMOpen()) < 0) {
|
|
|
a41c76 |
if (controlFD == -2) {
|
|
|
a41c76 |
- /* The CONTROL_PATH doesn't exist. Probably the
|
|
|
a41c76 |
- * module isn't loaded, yet. Don't error out, just
|
|
|
a41c76 |
- * exit. */
|
|
|
a41c76 |
+ /* The CONTROL_PATH doesn't exist or is unusable.
|
|
|
a41c76 |
+ * Probably the module isn't loaded, yet. Don't error
|
|
|
a41c76 |
+ * out, just exit. */
|
|
|
a41c76 |
return 0;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.28.0
|
|
|
a41c76 |
|