Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
libvirt.11411
430e9391-lxc-conf2xml-gateway.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 430e9391-lxc-conf2xml-gateway.patch of Package libvirt.11411
From 430e9391279521969386d998a5b3f1df052a513b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com> Date: Thu, 24 Jul 2014 13:40:32 +0200 Subject: [PATCH 13/17] lxc conf2xml: convert lxc.network.ipv[46].gateway --- src/lxc/lxc_native.c | 57 +++++++++++++++++++++- .../lxcconf2xmldata/lxcconf2xml-physnetwork.config | 2 + tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml | 2 + tests/lxcconf2xmldata/lxcconf2xml-simple.config | 2 + tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 2 + 5 files changed, 64 insertions(+), 1 deletion(-) Index: libvirt-1.2.5/src/lxc/lxc_native.c =================================================================== --- libvirt-1.2.5.orig/src/lxc/lxc_native.c +++ libvirt-1.2.5/src/lxc/lxc_native.c @@ -423,11 +423,37 @@ typedef struct { char *name; virDomainNetIpDefPtr *ips; size_t nips; + char *gateway_ipv4; + char *gateway_ipv6; bool privnet; size_t networks; } lxcNetworkParseData; static int +lxcAddNetworkRouteDefinition(const char *address, + int family, + virDomainNetRouteDefPtr **routes, + size_t *nroutes) +{ + virDomainNetRouteDefPtr route = NULL; + + if (VIR_ALLOC(route) < 0) + goto error; + + if (virSocketAddrParse(&route->via, address, family) < 0) + goto error; + + if (VIR_APPEND_ELEMENT(*routes, *nroutes, route) < 0) + goto error; + + return 0; + + error: + VIR_FREE(route); + return -1; +} + +static int lxcAddNetworkDefinition(lxcNetworkParseData *data) { virDomainNetDefPtr net = NULL; @@ -464,6 +490,18 @@ lxcAddNetworkDefinition(lxcNetworkParseD hostdev->source.caps.u.net.ips = data->ips; hostdev->source.caps.u.net.nips = data->nips; + if (data->gateway_ipv4 && + lxcAddNetworkRouteDefinition(data->gateway_ipv4, AF_INET, + &hostdev->source.caps.u.net.routes, + &hostdev->source.caps.u.net.nroutes) < 0) + goto error; + + if (data->gateway_ipv6 && + lxcAddNetworkRouteDefinition(data->gateway_ipv6, AF_INET6, + &hostdev->source.caps.u.net.routes, + &hostdev->source.caps.u.net.nroutes) < 0) + goto error; + if (VIR_EXPAND_N(data->def->hostdevs, data->def->nhostdevs, 1) < 0) goto error; data->def->hostdevs[data->def->nhostdevs - 1] = hostdev; @@ -476,6 +514,18 @@ lxcAddNetworkDefinition(lxcNetworkParseD net->ips = data->ips; net->nips = data->nips; + if (data->gateway_ipv4 && + lxcAddNetworkRouteDefinition(data->gateway_ipv4, AF_INET, + &net->routes, + &net->nroutes) < 0) + goto error; + + if (data->gateway_ipv6 && + lxcAddNetworkRouteDefinition(data->gateway_ipv6, AF_INET6, + &net->routes, + &net->nroutes) < 0) + goto error; + if (VIR_EXPAND_N(data->def->nets, data->def->nnets, 1) < 0) goto error; data->def->nets[data->def->nnets - 1] = net; @@ -567,6 +617,10 @@ lxcNetworkWalkCallback(const char *name, VIR_FREE(ip); return -1; } + } else if (STREQ(name, "lxc.network.ipv4.gateway")) { + parseData->gateway_ipv4 = value->str; + } else if (STREQ(name, "lxc.network.ipv6.gateway")) { + parseData->gateway_ipv6 = value->str; } else if (STRPREFIX(name, "lxc.network")) { VIR_WARN("Unhandled network property: %s = %s", name, @@ -583,7 +637,8 @@ lxcConvertNetworkSettings(virDomainDefPt int result = -1; size_t i; lxcNetworkParseData data = {def, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, 0, true, 0}; + NULL, NULL, NULL, NULL, 0, + NULL, NULL, true, 0}; if (virConfWalk(properties, lxcNetworkWalkCallback, &data) < 0) goto error; Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config =================================================================== --- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config +++ libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config @@ -2,7 +2,9 @@ lxc.network.type = phys lxc.network.link = eth0 lxc.network.name = eth1 lxc.network.ipv4 = 192.168.122.2/24 +lxc.network.ipv4.gateway = 192.168.122.1 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 +lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 lxc.rootfs = /var/lib/lxc/migrate_test/rootfs lxc.utsname = migrate_test Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml =================================================================== --- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml +++ libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml @@ -27,6 +27,8 @@ </source> <ip address='192.168.122.2' family='ipv4' prefix='24'/> <ip address='2003:db8:1:0:214:1234:fe0b:3596' family='ipv6' prefix='64'/> + <route family='ipv4' via='192.168.122.1'/> + <route family='ipv6' via='2003:db8:1:0:214:1234:fe0b:3595'/> </hostdev> </devices> </domain> Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.config =================================================================== --- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-simple.config +++ libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.config @@ -7,7 +7,9 @@ lxc.network.link = virbr0 lxc.network.hwaddr = 02:00:15:8f:05:c1 lxc.network.name = eth0 lxc.network.ipv4 = 192.168.122.2/24 +lxc.network.ipv4.gateway = 192.168.122.1 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 +lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 #remove next line if host DNS configuration should not be available to container lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0 Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.xml =================================================================== --- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-simple.xml +++ libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.xml @@ -39,6 +39,8 @@ <source bridge='virbr0'/> <ip address='192.168.122.2' family='ipv4' prefix='24'/> <ip address='2003:db8:1:0:214:1234:fe0b:3596' family='ipv6' prefix='64'/> + <route family='ipv4' via='192.168.122.1'/> + <route family='ipv6' via='2003:db8:1:0:214:1234:fe0b:3595'/> <guest dev='eth0'/> <link state='up'/> </interface>
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor