Re: [PATCH] Added hook for network modification event

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

 



On Tue, Jun 23, 2015 at 09:01:58AM +0200, Anton Khramov wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1181539

Signed-off-by: Anton Khramov <webmaster@xxxxxxxxx>
---
src/network/bridge_driver.c | 5 +++++
src/util/virhook.c          | 3 ++-
src/util/virhook.h          | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3d6721b..f5fc6f4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3307,6 +3307,11 @@ networkUpdate(virNetworkPtr net,
    if (needFirewallRefresh && networkAddFirewallRules(network->def) < 0)
        goto cleanup;

+    if (needFirewallRefresh &&
+        networkRunHook(network, NULL, NULL, VIR_HOOK_NETWORK_OP_UPDATED,
+                       VIR_HOOK_SUBOP_BEGIN) < 0)
+        goto cleanup;
+

Any reason why the hook should be called only if the firewall is being
refreshed?

    if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
        /* save updated persistent config to disk */
        if (virNetworkSaveConfig(driver->networkConfigDir,
diff --git a/src/util/virhook.c b/src/util/virhook.c
index ee19382..516e4f4 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -93,7 +93,8 @@ VIR_ENUM_IMPL(virHookNetworkOp, VIR_HOOK_NETWORK_OP_LAST,
              "started",
              "stopped",
              "plugged",
-              "unplugged")
+              "unplugged",
+              "updated")

static int virHooksFound = -1;

diff --git a/src/util/virhook.h b/src/util/virhook.h
index 550ef84..021308d 100644
--- a/src/util/virhook.h
+++ b/src/util/virhook.h
@@ -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 modified */


While it's enough for the code to work, you also need to update
the documentation (docs/hooks.html.in in particular).

    VIR_HOOK_NETWORK_OP_LAST,
} virHookNetworkOpType;
--
1.9.1

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

Attachment: signature.asc
Description: PGP signature

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