[PATCH 8/8] parallels: handle network adapters of type 'routed'

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

 



Network adapters of type 'routed' is a special case. Other adapters
have 'network' parameter in prlctl's output instead.

Routed network adapters should be connected to 'routed' network
from libvirt's view.

Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_driver.c |   42 +++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 21279c0..f16777a 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -482,13 +482,34 @@ parallelsGetNetInfo(virDomainNetDefPtr net,
         goto error;
     }
 
-    if (!(tmp = virJSONValueObjectGetString(value, "network"))) {
-        parallelsParseError();
-        goto error;
-    }
 
-    if (!(net->data.network.name = strdup(tmp))) {
-        virReportOOMError();
+    if (virJSONValueObjectHasKey(value, "network")) {
+        if (!(tmp = virJSONValueObjectGetString(value, "network"))) {
+            parallelsParseError();
+            goto error;
+        }
+
+        if (!(net->data.network.name = strdup(tmp))) {
+            virReportOOMError();
+            goto error;
+        }
+    } else if (virJSONValueObjectHasKey(value, "type")) {
+        if (!(tmp = virJSONValueObjectGetString(value, "type"))) {
+            parallelsParseError();
+            goto error;
+        }
+
+        if (!STREQ(tmp, "routed")) {
+            parallelsParseError();
+            goto error;
+        }
+
+        if (!(net->data.network.name = strdup(PARALLELS_ROUTED_NETWORK_NAME))) {
+            virReportOOMError();
+            goto error;
+        }
+    } else {
+        parallelsParseError();
         goto error;
     }
 
@@ -1866,7 +1887,14 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
     }
 
     if (!STREQ_NULLABLE(oldnet->data.network.name, newnet->data.network.name)) {
-        virCommandAddArgFormat(cmd, "--network=%s", newnet->data.network.name);
+        if (STREQ_NULLABLE(newnet->data.network.name,
+                           PARALLELS_ROUTED_NETWORK_NAME)) {
+            virCommandAddArgFormat(cmd, "--type=routed");
+        } else {
+            virCommandAddArgFormat(cmd, "--network=%s",
+                                   newnet->data.network.name);
+        }
+
         is_changed = true;
     }
 
-- 
1.7.7.6

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