diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 7b7a851351d9665b380d24b424ec57e7d1da18a2..e5f3018417c75876d07e5b3dac8ce915bb1a5e3b 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -60,7 +60,7 @@ virNetworkRouteDefFree(virNetworkRouteDefPtr def) virNetworkRouteDefPtr virNetworkRouteDefCreate(const char *errorDetail, - char *family, + const char *family, const char *address, const char *netmask, const char *gateway, diff --git a/src/conf/networkcommon_conf.h b/src/conf/networkcommon_conf.h index 1500d0f288a533d39cb7474c1d658c0ee8ca2c5e..41d8b9707b8da5a789db9481743b06389da41329 100644 --- a/src/conf/networkcommon_conf.h +++ b/src/conf/networkcommon_conf.h @@ -40,7 +40,7 @@ virNetworkRouteDefFree(virNetworkRouteDefPtr def); virNetworkRouteDefPtr virNetworkRouteDefCreate(const char *networkName, - char *family, + const char *family, const char *address, const char *netmask, const char *gateway, diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index d8af64b56ab18932c07c51e73dd30d0700b25f87..7e41f49ebebd84f16054e8aa79f5937b90973a83 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -832,6 +832,50 @@ prlsdkGetNetAddresses(PRL_HANDLE sdknet, virDomainNetDefPtr net) return ret; } +static int +prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr net) +{ + int ret = -1; + char *gw = NULL; + char *gw6 = NULL; + virNetworkRouteDefPtr route = NULL; + + if (!(gw = prlsdkGetStringParamVar(PrlVmDevNet_GetDefaultGateway, sdknet))) + goto cleanup; + + if (!(gw6 = prlsdkGetStringParamVar(PrlVmDevNet_GetDefaultGatewayIPv6, sdknet))) + goto cleanup; + + if (*gw != '\0') { + if (!(route = virNetworkRouteDefCreate(_("Domain interface"), + "ipv4", VIR_SOCKET_ADDR_IPV4_ALL, + NULL, gw, 0, true, 0, false))) + goto cleanup; + + if (VIR_APPEND_ELEMENT(net->routes, net->nroutes, route) < 0) + goto cleanup; + } + + if (*gw6 != '\0') { + if (!(route = virNetworkRouteDefCreate(_("Domain interface"), + "ipv6", VIR_SOCKET_ADDR_IPV6_ALL, + NULL, gw6, 0, true, 0, false))) + goto cleanup; + + if (VIR_APPEND_ELEMENT(net->routes, net->nroutes, route) < 0) + goto cleanup; + } + + ret = 0; + + cleanup: + VIR_FREE(route); + VIR_FREE(gw); + VIR_FREE(gw6); + + return ret; +} + static int prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt) { @@ -874,6 +918,9 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt) if (prlsdkGetNetAddresses(netAdapter, net) < 0) goto cleanup; + if (prlsdkGetRoutes(netAdapter, net) < 0) + goto cleanup; + pret = PrlVmDev_GetEmulatedType(netAdapter, &emulatedType); prlsdkCheckRetGoto(pret, cleanup);