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

[libvirt] [PATCH 1/2] parallels: fix crash in prlsdkAddNet in case of CT definition



Since net->model is not defined for containers we shouldn't touch it

Signed-off-by: Maxim Nestratov <mnestratov parallels com>
---
 src/parallels/parallels_sdk.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 59ca62e..988bcc6 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2728,7 +2728,8 @@ static const char * prlsdkFormatMac(virMacAddrPtr mac, char *macstr)
 
 static int prlsdkAddNet(PRL_HANDLE sdkdom,
                         parallelsConnPtr privconn,
-                        virDomainNetDefPtr net)
+                        virDomainNetDefPtr net,
+                        bool isCt)
 {
     PRL_RESULT pret;
     PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
@@ -2760,19 +2761,21 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
     pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    if (STREQ(net->model, "rtl8139")) {
-        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
-    } else if (STREQ(net->model, "e1000")) {
-        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
-    } else if (STREQ(net->model, "virtio")) {
-        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
-    } else {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+    if (!isCt) {
+        if (STREQ(net->model, "rtl8139")) {
+            pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
+        } else if (STREQ(net->model, "e1000")) {
+            pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+        } else if (STREQ(net->model, "virtio")) {
+            pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
+        } else {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Specified network adapter model is not "
                          "supported by Parallels Cloud Server."));
-        goto cleanup;
+            goto cleanup;
+        }
+        prlsdkCheckRetGoto(pret, cleanup);
     }
-    prlsdkCheckRetGoto(pret, cleanup);
 
     if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
         if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
@@ -3156,7 +3159,7 @@ prlsdkDoApplyConfig(virConnectPtr conn,
     }
 
     for (i = 0; i < def->nnets; i++) {
-        if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
+        if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i], IS_CT(def)) < 0)
            goto error;
     }
 
-- 
1.7.1


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