parallels: introduce and use string constants for network types and names

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
This commit is contained in:
Maxim Nestratov 2015-03-18 11:33:51 +03:00 committed by Michal Privoznik
parent 9c23b325b4
commit 20111b6fdf
3 changed files with 13 additions and 7 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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;