]> xenbits.xensource.com Git - libvirt.git/commitdiff
network: Added hook for network modification event
authorAnton Khramov <anton@endocode.com>
Wed, 13 Jul 2016 11:06:05 +0000 (13:06 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 26 Jul 2016 16:40:14 +0000 (12:40 -0400)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1181539

docs/hooks.html.in
src/network/bridge_driver.c
src/util/virhook.c
src/util/virhook.h

index 1aae00c77bbfda0e2e6d1d06fc020287d5b06ce0..d4f4ac3dcf74731d68fae78470c033763f092281 100644 (file)
           <pre>/etc/libvirt/hooks/network network_name plugged begin -</pre>
         Please note, that in this case, the script is passed both network and
         domain XMLs on its stdin.</li>
+      <li>When network is updated, the hook script is called as:<br/>
+          <pre>/etc/libvirt/hooks/network network_name updated begin -</pre></li>
       <li>When the domain from previous case is shutting down, the interface
         is unplugged. This leads to another script invocation:<br/>
           <pre>/etc/libvirt/hooks/network network_name unplugged begin -</pre>
index 50202664e440e8b35fbf5e6bf5a564d298186e30..87019cb44f8b16b2e2e8f195a71d465fbfadf3ce 100644 (file)
@@ -3462,6 +3462,12 @@ networkUpdate(virNetworkPtr net,
             goto cleanup;
         }
     }
+
+    /* call the 'updated' network hook script */
+    if (networkRunHook(network, NULL, NULL, VIR_HOOK_NETWORK_OP_UPDATED,
+                       VIR_HOOK_SUBOP_BEGIN) < 0)
+        goto cleanup;
+
     ret = 0;
  cleanup:
     virNetworkObjEndAPI(&network);
index d37d6da224848e6632bdc21d425a4c2dca44cf25..a8422a2ad0f6edc9d88864f9cf351fa9aa283a33 100644 (file)
@@ -93,7 +93,8 @@ VIR_ENUM_IMPL(virHookNetworkOp, VIR_HOOK_NETWORK_OP_LAST,
               "started",
               "stopped",
               "plugged",
-              "unplugged")
+              "unplugged",
+              "updated")
 
 static int virHooksFound = -1;
 
index 550ef84a38ef6c9cc78fd0f65dbbf7723288f14e..4015426b41cebab20d63fcfa7cf4a9f3d68c973f 100644 (file)
@@ -82,6 +82,7 @@ typedef enum {
     VIR_HOOK_NETWORK_OP_STOPPED,        /* network has stopped */
     VIR_HOOK_NETWORK_OP_IFACE_PLUGGED,  /* an interface has been plugged into the network */
     VIR_HOOK_NETWORK_OP_IFACE_UNPLUGGED,    /* an interface was unplugged from the network */
+    VIR_HOOK_NETWORK_OP_UPDATED,        /* network has been updated */
 
     VIR_HOOK_NETWORK_OP_LAST,
 } virHookNetworkOpType;