render / rpms / libvirt

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