[PATCH v4 1/7] parallels: introduce and use string constants for network types and names

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

 



Signed-off-by: Maxim Nestratov <mnestratov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_network.c |    6 +++---
 src/parallels/parallels_sdk.c     |    6 +++---
 src/parallels/parallels_utils.h   |    8 +++++++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 1d3b694..bb7ec5e 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -211,12 +211,12 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
         goto cleanup;
     }
 
-    if (STREQ(tmp, "bridged")) {
+    if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
         def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
         if (parallelsGetBridgedNetInfo(def, jobj) < 0)
             goto cleanup;
-    } else if (STREQ(tmp, "host-only")) {
+    } else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
         def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
         if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
@@ -248,7 +248,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 
     def->forward.type = VIR_NETWORK_FORWARD_ROUTE;
 
-    if (VIR_STRDUP(def->name, PARALLELS_ROUTED_NETWORK_NAME) < 0)
+    if (VIR_STRDUP(def->name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
         goto cleanup;
 
     if (virUUIDParse(PARALLELS_ROUTED_NETWORK_UUID, def->uuid) < 0) {
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index a0b62cd..d3fb5d4 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -708,7 +708,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
          * always up */
         net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
         if (VIR_STRDUP(net->data.network.name,
-                       PARALLELS_ROUTED_NETWORK_NAME) < 0)
+                       PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
             goto cleanup;
         return 0;
     }
@@ -727,7 +727,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
 
     if (emulatedType == PNA_ROUTED) {
         if (VIR_STRDUP(net->data.network.name,
-                       PARALLELS_ROUTED_NETWORK_NAME) < 0)
+                       PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
             goto cleanup;
     } else {
         pret = PrlVmDevNet_GetVirtualNetworkId(netAdapter, NULL, &buflen);
@@ -2658,8 +2658,8 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, virDomainNetDefPtr net)
     pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    if (STREQ(net->data.network.name, PARALLELS_ROUTED_NETWORK_NAME)) {
         pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
+    if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
         prlsdkCheckRetGoto(pret, cleanup);
     } else {
         pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 394548a..0f29374 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -47,7 +47,13 @@
                        _("no domain with matching uuid '%s'"), uuidstr); \
     } while (0)
 
-# define PARALLELS_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME  "Bridged"
+
+# define PARALLELS_REQUIRED_HOSTONLY_NETWORK "Host-Only"
+# define PARALLELS_HOSTONLY_NETWORK_TYPE "host-only"
+# define PARALLELS_REQUIRED_BRIDGED_NETWORK  "Bridged"
+# define PARALLELS_BRIDGED_NETWORK_TYPE  "bridged"
 
 struct _parallelsConn {
     virMutex lock;
-- 
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]