[PATCH]util: Helper function for checking existence of hook files for specific driver

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

 



From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>

We refresh the status of hook scripts
only when start/restart libvirt or reloads its configuration.
But hooks scripts may be changed.
This function will help to check its existence.
And we do not need to start/restart libvirt if
we add/remove hook files.

Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
---
 src/util/virhook.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/util/virhook.c b/src/util/virhook.c
index 159efdb..c4a1a15 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -129,6 +129,12 @@ virHookCheck(int no, const char *driver) {
     return ret;
 }
 
+static int
+virHookDriverCheck(int driver) {
+    return virHookCheck(driver,
+                        virHookDriverTypeToString(driver));
+}
+
 /*
  * virHookInitialize:
  *
@@ -170,11 +176,12 @@ virHookPresent(int driver) {
     if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
         (driver >= VIR_HOOK_DRIVER_LAST))
         return 0;
-    if (virHooksFound == -1)
+    if (virHookDriverCheck(driver) != 1) {
+        VIR_DEBUG("Driver %s hooks files not found",
+                  virHookDriverTypeToString(driver));
         return 0;
+    }
 
-    if ((virHooksFound & (1 << driver)) == 0)
-        return 0;
     return 1;
 }
 
-- 
1.8.2.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]