Blob Blame History Raw
From 16b26f917f445c837127c786c7b641e1e38f93fe Mon Sep 17 00:00:00 2001
Message-Id: <16b26f917f445c837127c786c7b641e1e38f93fe@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 19 Jun 2020 17:44:08 +0200
Subject: [PATCH] util: Move virIsDevMapperDevice() to virdevmapper.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't
realize there is a function that calls in devmapper. The function
is called virIsDevMapperDevice() and lives in virutil.c. Now that
we have a special file for handling devmapper move it there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit dfa0e118f745fe3f4fe95975c6100f0fc6d788be)

https://bugzilla.redhat.com/show_bug.cgi?id=1849095

Conflicts:
- src/util/virutil.c - Context, becasue v6.0.0-206-gfc920f704c is
  not backported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <84be146c2e7fc097da7189a7bf270577ffba18b2.1592581422.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/libvirt_private.syms           |  2 +-
 src/storage/parthelper.c           |  2 +-
 src/storage/storage_backend_disk.c |  1 +
 src/util/virdevmapper.c            | 24 ++++++++++++++++++++++++
 src/util/virdevmapper.h            |  3 +++
 src/util/virutil.c                 | 24 ------------------------
 src/util/virutil.h                 |  2 --
 7 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ac5527ef01..a3fe49ae33 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1871,6 +1871,7 @@ virDBusSetSharedBus;
 
 # util/virdevmapper.h
 virDevMapperGetTargets;
+virIsDevMapperDevice;
 
 
 # util/virdnsmasq.h
@@ -3394,7 +3395,6 @@ virHexToBin;
 virHostGetDRMRenderNode;
 virHostHasIOMMU;
 virIndexToDiskName;
-virIsDevMapperDevice;
 virMemoryLimitIsSet;
 virMemoryLimitTruncate;
 virMemoryMaxValue;
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index 761a7f93fc..812e90d3cb 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -36,10 +36,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "virutil.h"
 #include "virfile.h"
 #include "virstring.h"
 #include "virgettext.h"
+#include "virdevmapper.h"
 
 /* we don't need to include the full internal.h just for this */
 #define STREQ(a, b) (strcmp(a, b) == 0)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 00e8b1aa13..90c57af59b 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -31,6 +31,7 @@
 #include "virfile.h"
 #include "configmake.h"
 #include "virstring.h"
+#include "virdevmapper.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
index f000979ce0..23b2a16057 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -214,3 +214,27 @@ virDevMapperGetTargets(const char *path G_GNUC_UNUSED,
     return -1;
 }
 #endif /* ! WITH_DEVMAPPER */
+
+
+#if WITH_DEVMAPPER
+bool
+virIsDevMapperDevice(const char *dev_name)
+{
+    struct stat buf;
+
+    if (!stat(dev_name, &buf) &&
+        S_ISBLK(buf.st_mode) &&
+        dm_is_dm_major(major(buf.st_rdev)))
+            return true;
+
+    return false;
+}
+
+#else /* ! WITH_DEVMAPPER */
+
+bool
+virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
+{
+    return false;
+}
+#endif /* ! WITH_DEVMAPPER */
diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h
index 87bbc63cfd..834900692e 100644
--- a/src/util/virdevmapper.h
+++ b/src/util/virdevmapper.h
@@ -25,3 +25,6 @@
 int
 virDevMapperGetTargets(const char *path,
                        char ***devPaths) G_GNUC_NO_INLINE;
+
+bool
+virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 4198473fce..261b2d2af6 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -37,10 +37,6 @@
 #include <sys/types.h>
 #include <termios.h>
 
-#if WITH_DEVMAPPER
-# include <libdevmapper.h>
-#endif
-
 #include <netdb.h>
 #ifdef HAVE_GETPWUID_R
 # include <pwd.h>
@@ -1327,26 +1323,6 @@ void virWaitForDevices(void)
     ignore_value(virCommandRun(cmd, &exitstatus));
 }
 
-#if WITH_DEVMAPPER
-bool
-virIsDevMapperDevice(const char *dev_name)
-{
-    struct stat buf;
-
-    if (!stat(dev_name, &buf) &&
-        S_ISBLK(buf.st_mode) &&
-        dm_is_dm_major(major(buf.st_rdev)))
-            return true;
-
-    return false;
-}
-#else
-bool virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
-{
-    return false;
-}
-#endif
-
 bool
 virValidateWWN(const char *wwn)
 {
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 58c45a6447..0dcaff79ac 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -116,8 +116,6 @@ bool virDoesUserExist(const char *name);
 bool virDoesGroupExist(const char *name);
 
 
-bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
-
 bool virValidateWWN(const char *wwn);
 
 int virGetDeviceID(const char *path,
-- 
2.27.0