[PATCH 1/2] virt-host-validade-common: move virHostKernelModuleIsLoaded to virkmod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function will be used in a later patch by QEMU code. Rename
it to virKModIsLoaded to be compliant with the other helpers.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/libvirt_private.syms          |  1 +
 src/util/virkmod.c                | 34 +++++++++++++++++++++++++++++++
 src/util/virkmod.h                |  1 +
 tools/virt-host-validate-common.c | 27 ------------------------
 tools/virt-host-validate-common.h |  2 --
 tools/virt-host-validate-qemu.c   |  3 ++-
 6 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 42f8d7c222..b86d7e3cb0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2404,6 +2404,7 @@ virKeycodeValueTranslate;
 # util/virkmod.h
 virKModConfig;
 virKModIsBlacklisted;
+virKModIsLoaded;
 virKModLoad;
 virKModUnload;
 
diff --git a/src/util/virkmod.c b/src/util/virkmod.c
index 12cb5920e8..3110f3bf8b 100644
--- a/src/util/virkmod.c
+++ b/src/util/virkmod.c
@@ -24,6 +24,7 @@
 #include "virkmod.h"
 #include "vircommand.h"
 #include "virstring.h"
+#include "virfile.h"
 
 static int
 doModprobe(const char *opts, const char *module, char **outbuf, char **errbuf)
@@ -60,6 +61,39 @@ doRmmod(const char *module, char **errbuf)
     return 0;
 }
 
+
+/**
+ * virKModModuleIsLoaded:
+ *
+ * Returns true if the module is loaded, false otherwise.
+ */
+bool virKModIsLoaded(const char *module)
+{
+    FILE *fp;
+    bool ret = false;
+
+    if (!(fp = fopen("/proc/modules", "r")))
+        return false;
+
+    do {
+        char line[1024];
+
+        if (!fgets(line, sizeof(line), fp))
+            break;
+
+        if (STRPREFIX(line, module)) {
+            ret = true;
+            break;
+        }
+
+    } while (1);
+
+    VIR_FORCE_FCLOSE(fp);
+
+    return ret;
+}
+
+
 /**
  * virKModConfig:
  *
diff --git a/src/util/virkmod.h b/src/util/virkmod.h
index f05cf83cf6..db0d4aabe3 100644
--- a/src/util/virkmod.h
+++ b/src/util/virkmod.h
@@ -24,6 +24,7 @@
 #include "internal.h"
 
 char *virKModConfig(void);
+bool virKModIsLoaded(const char *);
 char *virKModLoad(const char *, bool)
     ATTRIBUTE_NONNULL(1);
 char *virKModUnload(const char *)
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index f68c9c7c96..5986c26a0d 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -417,33 +417,6 @@ int virHostValidateIOMMU(const char *hvname,
 }
 
 
-bool virHostKernelModuleIsLoaded(const char *module)
-{
-    FILE *fp;
-    bool ret = false;
-
-    if (!(fp = fopen("/proc/modules", "r")))
-        return false;
-
-    do {
-        char line[1024];
-
-        if (!fgets(line, sizeof(line), fp))
-            break;
-
-        if (STRPREFIX(line, module)) {
-            ret = true;
-            break;
-        }
-
-    } while (1);
-
-    VIR_FORCE_FCLOSE(fp);
-
-    return ret;
-}
-
-
 int virHostValidateSecureGuests(const char *hvname,
                                 virHostValidateLevel level)
 {
diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h
index 3df5ea0c7e..87aeefe2bb 100644
--- a/tools/virt-host-validate-common.h
+++ b/tools/virt-host-validate-common.h
@@ -87,5 +87,3 @@ int virHostValidateIOMMU(const char *hvname,
 
 int virHostValidateSecureGuests(const char *hvname,
                                 virHostValidateLevel level);
-
-bool virHostKernelModuleIsLoaded(const char *module);
diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c
index ea7f172790..e590057c9c 100644
--- a/tools/virt-host-validate-qemu.c
+++ b/tools/virt-host-validate-qemu.c
@@ -27,6 +27,7 @@
 #include "virarch.h"
 #include "virbitmap.h"
 #include "vircgroup.h"
+#include "virkmod.h"
 
 int virHostValidateQEMU(void)
 {
@@ -92,7 +93,7 @@ int virHostValidateQEMU(void)
     if (arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE) {
         virHostMsgCheck("QEMU", "%s", _("for PowerPC KVM module loaded"));
 
-        if (!virHostKernelModuleIsLoaded("kvm_hv"))
+        if (!virKModIsLoaded("kvm_hv"))
             virHostMsgFail(VIR_HOST_VALIDATE_WARN,
                           _("Load kvm_hv for better performance"));
         else
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux