[libvirt] [PATCH] [4/6] Add the script hook support to the libvirt daemon

Daniel Veillard veillard at redhat.com
Fri Mar 26 15:44:40 UTC 2010


Add the script hook support to the libvirt daemon

It supports 3 kind of probing times, at daemon startup, when the
daemon reloads its drivers on SIGHUP and when the daemon exits

* daemon/libvirtd.c: daemon hooks for startup, reload and exit

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index d59a2ab..150ff18 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -62,6 +62,7 @@
 #include "event.h"
 #include "memory.h"
 #include "stream.h"
+#include "hooks.h"
 #ifdef HAVE_AVAHI
 # include "mdns.h"
 #endif
@@ -375,8 +376,11 @@ qemudDispatchSignalEvent(int watch ATTRIBUTE_UNUSED,
     switch (siginfo.si_signo) {
     case SIGHUP:
         VIR_INFO0(_("Reloading configuration on SIGHUP"));
+        virHookCall(VIR_HOOK_DRIVER_DAEMON, "-",
+                    VIR_HOOK_DAEMON_OP_RELOAD, SIGHUP, "SIGHUP", NULL);
         if (virStateReload() < 0)
             VIR_WARN0(_("Error while reloading drivers"));
+
         break;
 
     case SIGINT:
@@ -3124,9 +3128,18 @@ int main(int argc, char **argv) {
         goto error;
     }
 
+    /* setup the hooks */
+    virHookInitialize();
+
     /* Disable error func, now logging is setup */
     virSetErrorFunc(NULL, virshErrorHandler);
 
+    /*
+     * Call the daemon startup hook
+     */
+    virHookCall(VIR_HOOK_DRIVER_DAEMON, "-", VIR_HOOK_DAEMON_OP_START,
+                0, "start", NULL);
+
     if (qemudNetworkInit(server) < 0) {
         ret = VIR_DAEMON_ERR_NETWORK;
         goto error;
@@ -3187,6 +3200,9 @@ shutdown:
     }
     pthread_join(server->eventThread, NULL);
 
+    virHookCall(VIR_HOOK_DRIVER_DAEMON, "-", VIR_HOOK_DAEMON_OP_SHUTDOWN,
+                0, "shutdown", NULL);
+
 error:
     if (statuswrite != -1) {
         if (ret != 0) {

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list