render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
b971b8
From 16b26f917f445c837127c786c7b641e1e38f93fe Mon Sep 17 00:00:00 2001
b971b8
Message-Id: <16b26f917f445c837127c786c7b641e1e38f93fe@dist-git>
b971b8
From: Michal Privoznik <mprivozn@redhat.com>
b971b8
Date: Fri, 19 Jun 2020 17:44:08 +0200
b971b8
Subject: [PATCH] util: Move virIsDevMapperDevice() to virdevmapper.c
b971b8
MIME-Version: 1.0
b971b8
Content-Type: text/plain; charset=UTF-8
b971b8
Content-Transfer-Encoding: 8bit
b971b8
b971b8
When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't
b971b8
realize there is a function that calls in devmapper. The function
b971b8
is called virIsDevMapperDevice() and lives in virutil.c. Now that
b971b8
we have a special file for handling devmapper move it there.
b971b8
b971b8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
b971b8
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
(cherry picked from commit dfa0e118f745fe3f4fe95975c6100f0fc6d788be)
b971b8
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1849095
b971b8
b971b8
Conflicts:
b971b8
- src/util/virutil.c - Context, becasue v6.0.0-206-gfc920f704c is
b971b8
  not backported.
b971b8
b971b8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
b971b8
Message-Id: <84be146c2e7fc097da7189a7bf270577ffba18b2.1592581422.git.mprivozn@redhat.com>
b971b8
Reviewed-by: Ján Tomko <jtomko@redhat.com>
b971b8
---
b971b8
 src/libvirt_private.syms           |  2 +-
b971b8
 src/storage/parthelper.c           |  2 +-
b971b8
 src/storage/storage_backend_disk.c |  1 +
b971b8
 src/util/virdevmapper.c            | 24 ++++++++++++++++++++++++
b971b8
 src/util/virdevmapper.h            |  3 +++
b971b8
 src/util/virutil.c                 | 24 ------------------------
b971b8
 src/util/virutil.h                 |  2 --
b971b8
 7 files changed, 30 insertions(+), 28 deletions(-)
b971b8
b971b8
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
b971b8
index ac5527ef01..a3fe49ae33 100644
b971b8
--- a/src/libvirt_private.syms
b971b8
+++ b/src/libvirt_private.syms
b971b8
@@ -1871,6 +1871,7 @@ virDBusSetSharedBus;
b971b8
 
b971b8
 # util/virdevmapper.h
b971b8
 virDevMapperGetTargets;
b971b8
+virIsDevMapperDevice;
b971b8
 
b971b8
 
b971b8
 # util/virdnsmasq.h
b971b8
@@ -3394,7 +3395,6 @@ virHexToBin;
b971b8
 virHostGetDRMRenderNode;
b971b8
 virHostHasIOMMU;
b971b8
 virIndexToDiskName;
b971b8
-virIsDevMapperDevice;
b971b8
 virMemoryLimitIsSet;
b971b8
 virMemoryLimitTruncate;
b971b8
 virMemoryMaxValue;
b971b8
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
b971b8
index 761a7f93fc..812e90d3cb 100644
b971b8
--- a/src/storage/parthelper.c
b971b8
+++ b/src/storage/parthelper.c
b971b8
@@ -36,10 +36,10 @@
b971b8
 #include <sys/stat.h>
b971b8
 #include <unistd.h>
b971b8
 
b971b8
-#include "virutil.h"
b971b8
 #include "virfile.h"
b971b8
 #include "virstring.h"
b971b8
 #include "virgettext.h"
b971b8
+#include "virdevmapper.h"
b971b8
 
b971b8
 /* we don't need to include the full internal.h just for this */
b971b8
 #define STREQ(a, b) (strcmp(a, b) == 0)
b971b8
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
b971b8
index 00e8b1aa13..90c57af59b 100644
b971b8
--- a/src/storage/storage_backend_disk.c
b971b8
+++ b/src/storage/storage_backend_disk.c
b971b8
@@ -31,6 +31,7 @@
b971b8
 #include "virfile.h"
b971b8
 #include "configmake.h"
b971b8
 #include "virstring.h"
b971b8
+#include "virdevmapper.h"
b971b8
 
b971b8
 #define VIR_FROM_THIS VIR_FROM_STORAGE
b971b8
 
b971b8
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
b971b8
index f000979ce0..23b2a16057 100644
b971b8
--- a/src/util/virdevmapper.c
b971b8
+++ b/src/util/virdevmapper.c
b971b8
@@ -214,3 +214,27 @@ virDevMapperGetTargets(const char *path G_GNUC_UNUSED,
b971b8
     return -1;
b971b8
 }
b971b8
 #endif /* ! WITH_DEVMAPPER */
b971b8
+
b971b8
+
b971b8
+#if WITH_DEVMAPPER
b971b8
+bool
b971b8
+virIsDevMapperDevice(const char *dev_name)
b971b8
+{
b971b8
+    struct stat buf;
b971b8
+
b971b8
+    if (!stat(dev_name, &buf) &&
b971b8
+        S_ISBLK(buf.st_mode) &&
b971b8
+        dm_is_dm_major(major(buf.st_rdev)))
b971b8
+            return true;
b971b8
+
b971b8
+    return false;
b971b8
+}
b971b8
+
b971b8
+#else /* ! WITH_DEVMAPPER */
b971b8
+
b971b8
+bool
b971b8
+virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
b971b8
+{
b971b8
+    return false;
b971b8
+}
b971b8
+#endif /* ! WITH_DEVMAPPER */
b971b8
diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h
b971b8
index 87bbc63cfd..834900692e 100644
b971b8
--- a/src/util/virdevmapper.h
b971b8
+++ b/src/util/virdevmapper.h
b971b8
@@ -25,3 +25,6 @@
b971b8
 int
b971b8
 virDevMapperGetTargets(const char *path,
b971b8
                        char ***devPaths) G_GNUC_NO_INLINE;
b971b8
+
b971b8
+bool
b971b8
+virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
b971b8
diff --git a/src/util/virutil.c b/src/util/virutil.c
b971b8
index 4198473fce..261b2d2af6 100644
b971b8
--- a/src/util/virutil.c
b971b8
+++ b/src/util/virutil.c
b971b8
@@ -37,10 +37,6 @@
b971b8
 #include <sys/types.h>
b971b8
 #include <termios.h>
b971b8
 
b971b8
-#if WITH_DEVMAPPER
b971b8
-# include <libdevmapper.h>
b971b8
-#endif
b971b8
-
b971b8
 #include <netdb.h>
b971b8
 #ifdef HAVE_GETPWUID_R
b971b8
 # include <pwd.h>
b971b8
@@ -1327,26 +1323,6 @@ void virWaitForDevices(void)
b971b8
     ignore_value(virCommandRun(cmd, &exitstatus));
b971b8
 }
b971b8
 
b971b8
-#if WITH_DEVMAPPER
b971b8
-bool
b971b8
-virIsDevMapperDevice(const char *dev_name)
b971b8
-{
b971b8
-    struct stat buf;
b971b8
-
b971b8
-    if (!stat(dev_name, &buf) &&
b971b8
-        S_ISBLK(buf.st_mode) &&
b971b8
-        dm_is_dm_major(major(buf.st_rdev)))
b971b8
-            return true;
b971b8
-
b971b8
-    return false;
b971b8
-}
b971b8
-#else
b971b8
-bool virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
b971b8
-{
b971b8
-    return false;
b971b8
-}
b971b8
-#endif
b971b8
-
b971b8
 bool
b971b8
 virValidateWWN(const char *wwn)
b971b8
 {
b971b8
diff --git a/src/util/virutil.h b/src/util/virutil.h
b971b8
index 58c45a6447..0dcaff79ac 100644
b971b8
--- a/src/util/virutil.h
b971b8
+++ b/src/util/virutil.h
b971b8
@@ -116,8 +116,6 @@ bool virDoesUserExist(const char *name);
b971b8
 bool virDoesGroupExist(const char *name);
b971b8
 
b971b8
 
b971b8
-bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
b971b8
-
b971b8
 bool virValidateWWN(const char *wwn);
b971b8
 
b971b8
 int virGetDeviceID(const char *path,
b971b8
-- 
b971b8
2.27.0
b971b8