diff --git a/docs/hooks.html.in b/docs/hooks.html.in index 1aae00c77b..d4f4ac3dcf 100644 --- a/docs/hooks.html.in +++ b/docs/hooks.html.in @@ -250,6 +250,8 @@
/etc/libvirt/hooks/network network_name plugged begin -
Please note, that in this case, the script is passed both network and domain XMLs on its stdin. +
  • When network is updated, the hook script is called as:
    +
    /etc/libvirt/hooks/network network_name updated begin -
  • When the domain from previous case is shutting down, the interface is unplugged. This leads to another script invocation:
    /etc/libvirt/hooks/network network_name unplugged begin -
    diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 50202664e4..87019cb44f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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); diff --git a/src/util/virhook.c b/src/util/virhook.c index d37d6da224..a8422a2ad0 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 550ef84a38..4015426b41 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 updated */ VIR_HOOK_NETWORK_OP_LAST, } virHookNetworkOpType;