Fix net->data usage accordingly to type field.

Signed-off-by: Nikolay Shirokovskiy <nshirokovs...@virtuozzo.com>
---
 src/vz/vz_sdk.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 7730bca..328a5bc 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -866,9 +866,6 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
     PRL_BOOL isConnected;
     int ret = -1;
 
-    net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
-
-
     /* use device name, shown by prlctl as target device
      * for identifying network adapter in virDomainDefineXML */
     if (!(net->ifname = 
prlsdkGetStringParamVar(PrlVmDevNet_GetHostInterfaceName,
@@ -909,7 +906,9 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
                        PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
             goto cleanup;
     } else {
-        if (!(net->data.network.name =
+        char *netid = NULL;
+
+        if (!(netid =
               prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId,
                                       netAdapter)))
             goto cleanup;
@@ -920,8 +919,13 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
          * predefined ones such as PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME
          * and PARALLELS_DONAIN_ROUTED_NETWORK_NAME
          */
-        if (STRNEQ(net->data.network.name, 
PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME))
+        if (STRNEQ(netid, PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME)) {
             net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+            net->data.network.name = netid;
+        } else {
+            net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
+            net->data.bridge.brname = netid;
+        }
 
     }
 
@@ -3161,7 +3165,7 @@ static int prlsdkConfigureNet(vzDriverPtr driver,
         pret = PrlVirtNet_Create(&vnet);
         prlsdkCheckRetGoto(pret, cleanup);
 
-        pret = PrlVirtNet_SetNetworkId(vnet, net->data.network.name);
+        pret = PrlVirtNet_SetNetworkId(vnet, net->data.bridge.brname);
         prlsdkCheckRetGoto(pret, cleanup);
 
         pret = PrlVirtNet_SetNetworkType(vnet, PVN_BRIDGED_ETHERNET);
@@ -3176,7 +3180,7 @@ static int prlsdkConfigureNet(vzDriverPtr driver,
         pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
         prlsdkCheckRetGoto(pret, cleanup);
 
-        pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
+        pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, 
net->data.bridge.brname);
         prlsdkCheckRetGoto(pret, cleanup);
     }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to