[PATCH 10/18] vz: dump route info in domain xml

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

 



Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/conf/networkcommon_conf.c |  2 +-
 src/conf/networkcommon_conf.h |  2 +-
 src/vz/vz_sdk.c               | 47 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c
index 7b7a851..e5f3018 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 1500d0f..41d8b97 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 db85558..6c085b3 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -813,6 +813,50 @@ prlsdkGetNetAddresses(PRL_HANDLE sdknet, virDomainNetDefPtr net)
 }
 
 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)
 {
     char macstr[VIR_MAC_STRING_BUFLEN];
@@ -854,6 +898,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);
 
-- 
1.8.3.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]