render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
984721
From a7197541f467bfd39d5504c438a90ef00ef0bc1e Mon Sep 17 00:00:00 2001
984721
Message-Id: <a7197541f467bfd39d5504c438a90ef00ef0bc1e@dist-git>
984721
From: Michal Privoznik <mprivozn@redhat.com>
984721
Date: Fri, 19 Jun 2020 11:43:14 +0200
984721
Subject: [PATCH] util: Move virIsDevMapperDevice() to virdevmapper.c
984721
MIME-Version: 1.0
984721
Content-Type: text/plain; charset=UTF-8
984721
Content-Transfer-Encoding: 8bit
984721
984721
When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't
984721
realize there is a function that calls in devmapper. The function
984721
is called virIsDevMapperDevice() and lives in virutil.c. Now that
984721
we have a special file for handling devmapper move it there.
984721
984721
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
984721
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
984721
(cherry picked from commit dfa0e118f745fe3f4fe95975c6100f0fc6d788be)
984721
984721
https://bugzilla.redhat.com/show_bug.cgi?id=1839992
984721
984721
Conflicts:
984721
- src/libvirt_private.syms: Context, the downstream still has
984721
  virIsSUID() which was removed in upstream commit of v5.7.0-rc1~351
984721
- src/util/virdevmapper.h: Context, the downstream code hasn't
984721
  switched to #pragma once and still uses #endif.
984721
- src/util/virutil.c: Again, context.
984721
984721
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
984721
Message-Id: <31b696f526d21c5ce61b10ebe2c77c8fd0557ccc.1592559697.git.mprivozn@redhat.com>
984721
Reviewed-by: Ján Tomko <jtomko@redhat.com>
984721
---
984721
 src/libvirt_private.syms           |  2 +-
984721
 src/storage/parthelper.c           |  2 +-
984721
 src/storage/storage_backend_disk.c |  1 +
984721
 src/util/virdevmapper.c            | 24 ++++++++++++++++++++++++
984721
 src/util/virdevmapper.h            |  2 ++
984721
 src/util/virutil.c                 | 23 -----------------------
984721
 src/util/virutil.h                 |  2 --
984721
 7 files changed, 29 insertions(+), 27 deletions(-)
984721
984721
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
984721
index 3e5448af94..ef78b290db 100644
984721
--- a/src/libvirt_private.syms
984721
+++ b/src/libvirt_private.syms
984721
@@ -1716,6 +1716,7 @@ virDBusSetSharedBus;
984721
 
984721
 # util/virdevmapper.h
984721
 virDevMapperGetTargets;
984721
+virIsDevMapperDevice;
984721
 
984721
 
984721
 # util/virdnsmasq.h
984721
@@ -3132,7 +3133,6 @@ virHexToBin;
984721
 virHostGetDRMRenderNode;
984721
 virHostHasIOMMU;
984721
 virIndexToDiskName;
984721
-virIsDevMapperDevice;
984721
 virIsSUID;
984721
 virMemoryLimitIsSet;
984721
 virMemoryLimitTruncate;
984721
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
984721
index afdaa1cee2..d098356164 100644
984721
--- a/src/storage/parthelper.c
984721
+++ b/src/storage/parthelper.c
984721
@@ -40,11 +40,11 @@
984721
 #include <sys/stat.h>
984721
 #include <unistd.h>
984721
 
984721
-#include "virutil.h"
984721
 #include "virfile.h"
984721
 #include "c-ctype.h"
984721
 #include "virstring.h"
984721
 #include "virgettext.h"
984721
+#include "virdevmapper.h"
984721
 
984721
 /* we don't need to include the full internal.h just for this */
984721
 #define STREQ(a, b) (strcmp(a, b) == 0)
984721
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
984721
index c638e2db25..742510d986 100644
984721
--- a/src/storage/storage_backend_disk.c
984721
+++ b/src/storage/storage_backend_disk.c
984721
@@ -36,6 +36,7 @@
984721
 #include "virfile.h"
984721
 #include "configmake.h"
984721
 #include "virstring.h"
984721
+#include "virdevmapper.h"
984721
 
984721
 #define VIR_FROM_THIS VIR_FROM_STORAGE
984721
 
984721
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
984721
index a360c3e677..944baad562 100644
984721
--- a/src/util/virdevmapper.c
984721
+++ b/src/util/virdevmapper.c
984721
@@ -218,3 +218,27 @@ virDevMapperGetTargets(const char *path ATTRIBUTE_UNUSED,
984721
     return -1;
984721
 }
984721
 #endif /* ! WITH_DEVMAPPER */
984721
+
984721
+
984721
+#if WITH_DEVMAPPER
984721
+bool
984721
+virIsDevMapperDevice(const char *dev_name)
984721
+{
984721
+    struct stat buf;
984721
+
984721
+    if (!stat(dev_name, &buf) &&
984721
+        S_ISBLK(buf.st_mode) &&
984721
+        dm_is_dm_major(major(buf.st_rdev)))
984721
+            return true;
984721
+
984721
+    return false;
984721
+}
984721
+
984721
+#else /* ! WITH_DEVMAPPER */
984721
+
984721
+bool
984721
+virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
984721
+{
984721
+    return false;
984721
+}
984721
+#endif /* ! WITH_DEVMAPPER */
984721
diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h
984721
index 42a7828fde..78dc47e888 100644
984721
--- a/src/util/virdevmapper.h
984721
+++ b/src/util/virdevmapper.h
984721
@@ -30,4 +30,6 @@ int
984721
 virDevMapperGetTargets(const char *path,
984721
                        char ***devPaths);
984721
 
984721
+bool
984721
+virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
984721
 #endif /* __VIR_DEVMAPPER_H__ */
984721
diff --git a/src/util/virutil.c b/src/util/virutil.c
984721
index fd70df120b..e803fee993 100644
984721
--- a/src/util/virutil.c
984721
+++ b/src/util/virutil.c
984721
@@ -44,9 +44,6 @@
984721
 #include <string.h>
984721
 #include <termios.h>
984721
 
984721
-#if WITH_DEVMAPPER
984721
-# include <libdevmapper.h>
984721
-#endif
984721
 
984721
 #include <netdb.h>
984721
 #ifdef HAVE_GETPWUID_R
984721
@@ -1620,26 +1617,6 @@ void virWaitForDevices(void)
984721
 {}
984721
 #endif
984721
 
984721
-#if WITH_DEVMAPPER
984721
-bool
984721
-virIsDevMapperDevice(const char *dev_name)
984721
-{
984721
-    struct stat buf;
984721
-
984721
-    if (!stat(dev_name, &buf) &&
984721
-        S_ISBLK(buf.st_mode) &&
984721
-        dm_is_dm_major(major(buf.st_rdev)))
984721
-            return true;
984721
-
984721
-    return false;
984721
-}
984721
-#else
984721
-bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED)
984721
-{
984721
-    return false;
984721
-}
984721
-#endif
984721
-
984721
 bool
984721
 virValidateWWN(const char *wwn)
984721
 {
984721
diff --git a/src/util/virutil.h b/src/util/virutil.h
984721
index b0ee8329e2..dbd6a40bce 100644
984721
--- a/src/util/virutil.h
984721
+++ b/src/util/virutil.h
984721
@@ -152,8 +152,6 @@ int virGetUserID(const char *name,
984721
 int virGetGroupID(const char *name,
984721
                   gid_t *gid) ATTRIBUTE_RETURN_CHECK;
984721
 
984721
-bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
984721
-
984721
 bool virValidateWWN(const char *wwn);
984721
 
984721
 int virGetDeviceID(const char *path,
984721
-- 
984721
2.27.0
984721