[PATCH 6/6] net: Add support for changing persistent networks to transient

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

 



Until now, the network undefine API was able to undefine only inactive
networks. The restriction doesn't make sense any more so this patch
implements changing networks to transient.
---
 src/network/bridge_driver.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index e90444d..95aaea9 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2856,6 +2856,7 @@ networkUndefine(virNetworkPtr net) {
     struct network_driver *driver = net->conn->networkPrivateData;
     virNetworkObjPtr network;
     int ret = -1;
+    bool active = false;

     networkDriverLock(driver);

@@ -2866,24 +2867,25 @@ networkUndefine(virNetworkPtr net) {
         goto cleanup;
     }

-    if (virNetworkObjIsActive(network)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       "%s", _("network is still active"));
-        goto cleanup;
-    }
+    if (virNetworkObjIsActive(network))
+        active = true;

     if (virNetworkDeleteConfig(driver->networkConfigDir,
                                driver->networkAutostartDir,
                                network) < 0)
         goto cleanup;

+    network->persistent = 0;
+
     VIR_INFO("Undefining network '%s'", network->def->name);
-    if (networkRemoveInactive(driver, network) < 0) {
+    if (!active) {
+        if (networkRemoveInactive(driver, network) < 0) {
+            network = NULL;
+            goto cleanup;
+        }
         network = NULL;
-        goto cleanup;
     }

-    network = NULL;
     ret = 0;

 cleanup:
-- 
1.7.12.4

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