[PATCH 2/7] parallels: fix parallelsLoadNetworks

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

 



Don't fail initialization of parallels driver if
parallelsLoadNetwork fails for optional networks.
This can happen when some of them are added manually
and configured incompletely. PCS requires only two networks
created automatically (named Host-Only and Bridged), others
are optional and their incompletenes can be ignored.

Signed-off-by: Maxim Nestratov <mnestratov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_network.c |   43 +++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index bb7ec5e..1d0ee1c 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -180,9 +180,10 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr def, const char *name)
     return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
 {
+    int ret = -1;
     virNetworkObjPtr net;
     virNetworkDefPtr def;
     const char *tmp;
@@ -214,13 +215,25 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
     if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
         def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
-        if (parallelsGetBridgedNetInfo(def, jobj) < 0)
+        if (parallelsGetBridgedNetInfo(def, jobj) < 0) {
+
+            /* Only mandatory networks are required to be configured completely */
+            if (STRNEQ(def->name, PARALLELS_REQUIRED_BRIDGED_NETWORK))
+                ret = 0;
+
             goto cleanup;
+        }
     } else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
         def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
-        if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
+        if (parallelsGetHostOnlyNetInfo(def, def->name) < 0) {
+
+            /* Only mandatory networks are required to be configured completely */
+            if (STRNEQ(def->name, PARALLELS_REQUIRED_HOSTONLY_NETWORK))
+                ret = 0;
+
             goto cleanup;
+        }
     } else {
         parallelsParseError();
         goto cleanup;
@@ -230,14 +243,16 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
         goto cleanup;
     net->active = 1;
     net->autostart = 1;
-    return net;
+    virNetworkObjEndAPI(&net);
+    ret = 0;
+    def = NULL;
 
  cleanup:
     virNetworkDefFree(def);
-    return NULL;
+    return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 {
     virNetworkObjPtr net = NULL;
@@ -264,18 +279,18 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
     }
     net->active = 1;
     net->autostart = 1;
+    virNetworkObjEndAPI(&net);
 
-    return net;
+    return 0;
 
  cleanup:
     virNetworkDefFree(def);
-    return NULL;
+    return -1;
 }
 
 static int parallelsLoadNetworks(parallelsConnPtr privconn)
 {
     virJSONValuePtr jobj, jobj2;
-    virNetworkObjPtr net = NULL;
     int ret = -1;
     int count;
     size_t i;
@@ -300,22 +315,18 @@ static int parallelsLoadNetworks(parallelsConnPtr privconn)
             goto cleanup;
         }
 
-        net = parallelsLoadNetwork(privconn, jobj2);
-        if (!net)
+        ret = parallelsLoadNetwork(privconn, jobj2);
+        if (!ret)
             goto cleanup;
-        else
-            virNetworkObjEndAPI(&net);
-
     }
 
-    if (!(net = parallelsAddRoutedNetwork(privconn)))
+    if (!(ret = parallelsAddRoutedNetwork(privconn)))
         goto cleanup;
 
     ret = 0;
 
  cleanup:
     virJSONValueFree(jobj);
-    virNetworkObjEndAPI(&net);
     return ret;
 }
 
-- 
1.7.1

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