[libvirt] [PATCH]util: Refresh virHook before checking its existence

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Wed Sep 25 07:48:16 UTC 2013


From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>

We refresh the status of hook scripts
only when start/stop libvirt, or reload its configuration.
But the status of hooks scripts may be changed.
We need to refresh its status before checking its existence.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 src/util/virhook.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/util/virhook.c b/src/util/virhook.c
index 159efdb..5500f62 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -170,11 +170,15 @@ virHookPresent(int driver) {
     if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
         (driver >= VIR_HOOK_DRIVER_LAST))
         return 0;
-    if (virHooksFound == -1)
-        return 0;
+    if (virHookInitialize() > 0) {
+        if (virHooksFound == -1)
+            return 0;
 
-    if ((virHooksFound & (1 << driver)) == 0)
+        if ((virHooksFound & (1 << driver)) == 0)
+            return 0;
+    } else {
         return 0;
+    }
     return 1;
 }
 
-- 
1.8.2.1




More information about the libvir-list mailing list