[PATCH 3/8] network: Move port deletion into the shutdown function

Martin Kletzander posted 8 patches 1 month, 1 week ago
[PATCH 3/8] network: Move port deletion into the shutdown function
Posted by Martin Kletzander 1 month, 1 week ago
It will be more useful in there when calling from new places.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/network/bridge_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b16d524aa181..d27a7e9b88c4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2447,6 +2447,8 @@ networkShutdownNetwork(virNetworkDriverState *driver,
         return -1;
     }
 
+    virNetworkObjDeleteAllPorts(obj, cfg->stateDir);
+
     /* now that we know it's stopped call the hook if present */
     networkRunHook(obj, NULL, VIR_HOOK_NETWORK_OP_STOPPED,
                    VIR_HOOK_SUBOP_END);
@@ -3458,8 +3460,6 @@ networkDestroy(virNetworkPtr net)
     if ((ret = networkShutdownNetwork(driver, obj)) < 0)
         goto cleanup;
 
-    virNetworkObjDeleteAllPorts(obj, cfg->stateDir);
-
     /* @def replaced in virNetworkObjUnsetDefTransient */
     def = virNetworkObjGetDef(obj);
 
-- 
2.46.0
Re: [PATCH 3/8] network: Move port deletion into the shutdown function
Posted by Laine Stump 3 weeks, 4 days ago
On 9/3/24 10:36 AM, Martin Kletzander wrote:
> It will be more useful in there when calling from new places.

(and also the extra call to virNetworkObjDeleteAllPorts() that this 
creates in the error cleanup of networkStartNetwork() is harmless)
> 
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>

Reviewed-by: Laine Stump <laine@redhat.com>

> ---
>   src/network/bridge_driver.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index b16d524aa181..d27a7e9b88c4 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -2447,6 +2447,8 @@ networkShutdownNetwork(virNetworkDriverState *driver,
>           return -1;
>       }
>   
> +    virNetworkObjDeleteAllPorts(obj, cfg->stateDir);
> +
>       /* now that we know it's stopped call the hook if present */
>       networkRunHook(obj, NULL, VIR_HOOK_NETWORK_OP_STOPPED,
>                      VIR_HOOK_SUBOP_END);
> @@ -3458,8 +3460,6 @@ networkDestroy(virNetworkPtr net)
>       if ((ret = networkShutdownNetwork(driver, obj)) < 0)
>           goto cleanup;
>   
> -    virNetworkObjDeleteAllPorts(obj, cfg->stateDir);
> -
>       /* @def replaced in virNetworkObjUnsetDefTransient */
>       def = virNetworkObjGetDef(obj);
>