---
src/lxc/lxc_native.c | 19 ++++++++++++++++++-
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config | 2 ++
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml | 1 +
tests/lxcconf2xmldata/lxcconf2xml-simple.config | 2 ++
tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 1 +
5 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 8ff5c9b..bfcf5b5 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -423,6 +423,8 @@ typedef struct {
char *vlanid;
char *name;
char **ips;
+ char *gateway_ipv4;
+ char *gateway_ipv6;
size_t nips;
bool privnet;
size_t networks;
@@ -493,6 +495,12 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
hostdev->source.caps.u.net.ips = ips;
hostdev->source.caps.u.net.nips = nips;
+ if (VIR_STRDUP(hostdev->source.caps.u.net.gateway_ipv4,
+ data->gateway_ipv4) < 0 ||
+ VIR_STRDUP(hostdev->source.caps.u.net.gateway_ipv6,
+ data->gateway_ipv6) < 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;
@@ -505,6 +513,10 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
net->ips = ips;
net->nips = nips;
+ if (VIR_STRDUP(net->gateway_ipv4, data->gateway_ipv4) < 0 ||
+ VIR_STRDUP(net->gateway_ipv6, data->gateway_ipv6) < 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;
@@ -579,6 +591,10 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void
*data)
return -1;
if (VIR_STRDUP(parseData->ips[parseData->nips - 1], value->str) < 0)
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,
@@ -594,7 +610,8 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
int result = -1;
size_t i;
lxcNetworkParseData data = {def, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, 0, true, 0};
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, 0, true, 0};
if (virConfWalk(properties, lxcNetworkWalkCallback, &data) < 0)
goto cleanup;
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
index 94f7c61..779dac2 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
+++ b/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
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
index 7cd9e6f..b80147f 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
+++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
@@ -27,6 +27,7 @@
</source>
<ip address='192.168.122.2' prefix='24'/>
<ip address='2003:db8:1:0:214:1234:fe0b:3596' prefix='64'/>
+ <gateway ipv4='192.168.122.1'
ipv6='2003:db8:1:0:214:1234:fe0b:3595'/>
</hostdev>
</devices>
</domain>
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.config
b/tests/lxcconf2xmldata/lxcconf2xml-simple.config
index d417ba0..50a44bb 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-simple.config
+++ b/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
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
index a73d05c..32494e4 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
+++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
@@ -39,6 +39,7 @@
<source bridge='virbr0'/>
<ip address='192.168.122.2' prefix='24'/>
<ip address='2003:db8:1:0:214:1234:fe0b:3596' prefix='64'/>
+ <gateway ipv4='192.168.122.1'
ipv6='2003:db8:1:0:214:1234:fe0b:3595'/>
<guest dev='eth0'/>
<link state='up'/>
</interface>
--
1.8.4.5