lxc: Fix wrong addresses statements for IPv{4, 6} in native network definitions

After LXC version 3, some settings were changed to new names. Same as
network. LXC introduced network indexes and changed IPv{4,6} addresses
fields. Before, users should only pass `lxc.network.ipv4` to define an
IPv4 address. Now, on version 3, users need to pass
`lxc.net.X.ipv4.address` to specify the same thing. Same for IPv6.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Julio Faracco 2020-02-06 01:19:56 -03:00 committed by Michal Privoznik
parent 991c56105d
commit 23be4887af
6 changed files with 18 additions and 12 deletions

View File

@ -44,10 +44,12 @@ VIR_ENUM_IMPL(virLXCNetworkConfigEntry,
"flags", "flags",
"macvlan.mode", "macvlan.mode",
"vlan.id", "vlan.id",
"ipv4", "ipv4", /* Legacy: LXC IPv4 address */
"ipv4.gateway", "ipv4.gateway",
"ipv6", "ipv4.address",
"ipv6.gateway" "ipv6", /* Legacy: LXC IPv6 address */
"ipv6.gateway",
"ipv6.address"
); );
static virDomainFSDefPtr static virDomainFSDefPtr
@ -570,7 +572,7 @@ lxcNetworkParseDataIPs(const char *name,
if (VIR_ALLOC(ip) < 0) if (VIR_ALLOC(ip) < 0)
return -1; return -1;
if (STREQ(name, "ipv6")) if (STREQ(name, "ipv6") || STREQ(name, "ipv6.address"))
family = AF_INET6; family = AF_INET6;
ipparts = virStringSplit(value->str, "/", 2); ipparts = virStringSplit(value->str, "/", 2);
@ -627,7 +629,9 @@ lxcNetworkParseDataSuffix(const char *entry,
parseData->name = value->str; parseData->name = value->str;
break; break;
case VIR_LXC_NETWORK_CONFIG_IPV4: case VIR_LXC_NETWORK_CONFIG_IPV4:
case VIR_LXC_NETWORK_CONFIG_IPV4_ADDRESS:
case VIR_LXC_NETWORK_CONFIG_IPV6: case VIR_LXC_NETWORK_CONFIG_IPV6:
case VIR_LXC_NETWORK_CONFIG_IPV6_ADDRESS:
if (lxcNetworkParseDataIPs(entry, value, parseData) < 0) if (lxcNetworkParseDataIPs(entry, value, parseData) < 0)
return -1; return -1;
break; break;

View File

@ -35,8 +35,10 @@ typedef enum {
VIR_LXC_NETWORK_CONFIG_VLAN_ID, VIR_LXC_NETWORK_CONFIG_VLAN_ID,
VIR_LXC_NETWORK_CONFIG_IPV4, VIR_LXC_NETWORK_CONFIG_IPV4,
VIR_LXC_NETWORK_CONFIG_IPV4_GATEWAY, VIR_LXC_NETWORK_CONFIG_IPV4_GATEWAY,
VIR_LXC_NETWORK_CONFIG_IPV4_ADDRESS,
VIR_LXC_NETWORK_CONFIG_IPV6, VIR_LXC_NETWORK_CONFIG_IPV6,
VIR_LXC_NETWORK_CONFIG_IPV6_GATEWAY, VIR_LXC_NETWORK_CONFIG_IPV6_GATEWAY,
VIR_LXC_NETWORK_CONFIG_IPV6_ADDRESS,
VIR_LXC_NETWORK_CONFIG_LAST, VIR_LXC_NETWORK_CONFIG_LAST,
} virLXCNetworkConfigEntry; } virLXCNetworkConfigEntry;

View File

@ -5,9 +5,9 @@ lxc.net.0.type = veth
lxc.net.0.flags = up lxc.net.0.flags = up
lxc.net.0.hwaddr = 02:00:15:8f:05:c1 lxc.net.0.hwaddr = 02:00:15:8f:05:c1
lxc.net.0.name = eth0 lxc.net.0.name = eth0
lxc.net.0.ipv4 = 192.168.122.2/24 lxc.net.0.ipv4.address = 192.168.122.2/24
lxc.net.0.ipv4.gateway = 192.168.122.1 lxc.net.0.ipv4.gateway = 192.168.122.1
lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596/64
lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
#remove next line if host DNS configuration should not be available to container #remove next line if host DNS configuration should not be available to container

View File

@ -1,9 +1,9 @@
lxc.net.0.type = phys lxc.net.0.type = phys
lxc.net.0.link = eth0 lxc.net.0.link = eth0
lxc.net.0.name = eth1 lxc.net.0.name = eth1
lxc.net.0.ipv4 = 192.168.122.2/24 lxc.net.0.ipv4.address = 192.168.122.2/24
lxc.net.0.ipv4.gateway = 192.168.122.1 lxc.net.0.ipv4.gateway = 192.168.122.1
lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596/64
lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
lxc.net.1.type = vlan lxc.net.1.type = vlan

View File

@ -1,9 +1,9 @@
lxc.net.0.type = phys lxc.net.0.type = phys
lxc.net.0.link = eth0 lxc.net.0.link = eth0
lxc.net.0.name = eth1 lxc.net.0.name = eth1
lxc.net.0.ipv4 = 192.168.122.2/24 lxc.net.0.ipv4.address = 192.168.122.2/24
lxc.net.0.ipv4.gateway = 192.168.122.1 lxc.net.0.ipv4.gateway = 192.168.122.1
lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596/64
lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs

View File

@ -6,9 +6,9 @@ lxc.net.0.flags = up
lxc.net.0.link = virbr0 lxc.net.0.link = virbr0
lxc.net.0.hwaddr = 02:00:15:8f:05:c1 lxc.net.0.hwaddr = 02:00:15:8f:05:c1
lxc.net.0.name = eth0 lxc.net.0.name = eth0
lxc.net.0.ipv4 = 192.168.122.2/24 lxc.net.0.ipv4.address = 192.168.122.2/24
lxc.net.0.ipv4.gateway = 192.168.122.1 lxc.net.0.ipv4.gateway = 192.168.122.1
lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596/64
lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595 lxc.net.0.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
#remove next line if host DNS configuration should not be available to container #remove next line if host DNS configuration should not be available to container