Blob Blame History Raw
From a7197541f467bfd39d5504c438a90ef00ef0bc1e Mon Sep 17 00:00:00 2001
Message-Id: <a7197541f467bfd39d5504c438a90ef00ef0bc1e@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 19 Jun 2020 11:43:14 +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=1839992

Conflicts:
- src/libvirt_private.syms: Context, the downstream still has
  virIsSUID() which was removed in upstream commit of v5.7.0-rc1~351
- src/util/virdevmapper.h: Context, the downstream code hasn't
  switched to #pragma once and still uses #endif.
- src/util/virutil.c: Again, context.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <31b696f526d21c5ce61b10ebe2c77c8fd0557ccc.1592559697.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            |  2 ++
 src/util/virutil.c                 | 23 -----------------------
 src/util/virutil.h                 |  2 --
 7 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3e5448af94..ef78b290db 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1716,6 +1716,7 @@ virDBusSetSharedBus;
 
 # util/virdevmapper.h
 virDevMapperGetTargets;
+virIsDevMapperDevice;
 
 
 # util/virdnsmasq.h
@@ -3132,7 +3133,6 @@ virHexToBin;
 virHostGetDRMRenderNode;
 virHostHasIOMMU;
 virIndexToDiskName;
-virIsDevMapperDevice;
 virIsSUID;
 virMemoryLimitIsSet;
 virMemoryLimitTruncate;
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index afdaa1cee2..d098356164 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -40,11 +40,11 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "virutil.h"
 #include "virfile.h"
 #include "c-ctype.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 c638e2db25..742510d986 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -36,6 +36,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 a360c3e677..944baad562 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -218,3 +218,27 @@ virDevMapperGetTargets(const char *path ATTRIBUTE_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 42a7828fde..78dc47e888 100644
--- a/src/util/virdevmapper.h
+++ b/src/util/virdevmapper.h
@@ -30,4 +30,6 @@ int
 virDevMapperGetTargets(const char *path,
                        char ***devPaths);
 
+bool
+virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
 #endif /* __VIR_DEVMAPPER_H__ */
diff --git a/src/util/virutil.c b/src/util/virutil.c
index fd70df120b..e803fee993 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -44,9 +44,6 @@
 #include <string.h>
 #include <termios.h>
 
-#if WITH_DEVMAPPER
-# include <libdevmapper.h>
-#endif
 
 #include <netdb.h>
 #ifdef HAVE_GETPWUID_R
@@ -1620,26 +1617,6 @@ void virWaitForDevices(void)
 {}
 #endif
 
-#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 ATTRIBUTE_UNUSED)
-{
-    return false;
-}
-#endif
-
 bool
 virValidateWWN(const char *wwn)
 {
diff --git a/src/util/virutil.h b/src/util/virutil.h
index b0ee8329e2..dbd6a40bce 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -152,8 +152,6 @@ int virGetUserID(const char *name,
 int virGetGroupID(const char *name,
                   gid_t *gid) ATTRIBUTE_RETURN_CHECK;
 
-bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
-
 bool virValidateWWN(const char *wwn);
 
 int virGetDeviceID(const char *path,
-- 
2.27.0