---
src/lxc/lxc_native.c | 22 ++++++++++++++++------
.../lxcconf2xmldata/lxcconf2xml-physnetwork.config | 1 +
tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 1 +
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index f4c4556..e14face 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -338,7 +338,8 @@ lxcCreateNetDef(const char *type,
const char *linkdev,
const char *mac,
const char *flag,
- const char *macvlanmode)
+ const char *macvlanmode,
+ const char *name)
{
virDomainNetDefPtr net = NULL;
virMacAddr macAddr;
@@ -353,6 +354,8 @@ lxcCreateNetDef(const char *type,
net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN;
}
+ if (name && VIR_STRDUP(net->ifname_guest, name) < 0)
+ goto error;
if (mac && virMacAddrParse(mac, &macAddr) == 0)
net->mac = macAddr;
@@ -416,7 +419,8 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
const char *mac,
const char *flag,
const char *macvlanmode,
- const char *vlanid)
+ const char *vlanid,
+ const char *name)
{
virDomainNetDefPtr net = NULL;
virDomainHostdevDefPtr hostdev = NULL;
@@ -452,7 +456,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
goto error;
def->hostdevs[def->nhostdevs - 1] = hostdev;
} else {
- if (!(net = lxcCreateNetDef(type, linkdev, mac, flag, macvlanmode)))
+ if (!(net = lxcCreateNetDef(type, linkdev, mac, flag, macvlanmode, name)))
goto error;
if (VIR_EXPAND_N(def->nets, def->nnets, 1) < 0)
@@ -476,6 +480,7 @@ typedef struct {
char *flag;
char *macvlanmode;
char *vlanid;
+ char *name;
bool privnet;
size_t networks;
} lxcNetworkParseData;
@@ -492,7 +497,8 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void
*data)
parseData->link, parseData->mac,
parseData->flag,
parseData->macvlanmode,
- parseData->vlanid);
+ parseData->vlanid,
+ parseData->name);
if (status < 0)
return -1;
@@ -508,6 +514,7 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void
*data)
parseData->flag = NULL;
parseData->macvlanmode = NULL;
parseData->vlanid = NULL;
+ parseData->name = NULL;
/* Keep the new value */
parseData->type = value->str;
@@ -522,6 +529,8 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void
*data)
parseData->macvlanmode = value->str;
else if (STREQ(name, "lxc.network.vlan.id"))
parseData->vlanid = value->str;
+ else if (STREQ(name, "lxc.network.name"))
+ parseData->name = value->str;
else if (STRPREFIX(name, "lxc.network"))
VIR_WARN("Unhandled network property: %s = %s",
name,
@@ -535,7 +544,7 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
{
int status;
lxcNetworkParseData data = {def, NULL, NULL, NULL, NULL,
- NULL, NULL, true, 0};
+ NULL, NULL, NULL, true, 0};
virConfWalk(properties, lxcNetworkWalkCallback, &data);
@@ -543,7 +552,8 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
status = lxcAddNetworkDefinition(def, data.type, data.link,
data.mac, data.flag,
data.macvlanmode,
- data.vlanid);
+ data.vlanid,
+ data.name);
if (status < 0)
return -1;
else if (status > 0)
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
index 63a4aa1..ed196e1 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
+++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
@@ -1,5 +1,6 @@
lxc.network.type = phys
lxc.network.link = eth0
+lxc.network.name = eth1
lxc.rootfs = /var/lib/lxc/migrate_test/rootfs
lxc.utsname = migrate_test
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
index b3c3659..dabb76e 100644
--- a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
+++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
@@ -29,6 +29,7 @@
<interface type='bridge'>
<mac address='02:00:15:8f:05:c1'/>
<source bridge='virbr0'/>
+ <guest dev='eth0'/>
<link state='up'/>
</interface>
<console type='pty'>
--
1.8.4.5