On Tue, Jan 14, 2014 at 02:49:57PM +0100, Cédric Bosdonnat wrote: > --- > src/lxc/lxc_native.c | 38 +++++++++++++++++----- > .../lxcconf2xml-macvlannetwork.config | 14 ++++++++ > .../lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml | 30 +++++++++++++++++ > tests/lxcconf2xmltest.c | 1 + > 4 files changed, 74 insertions(+), 9 deletions(-) > create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.config > create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml > > diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c > index 6ea4998..a99bc1c 100644 > --- a/src/lxc/lxc_native.c > +++ b/src/lxc/lxc_native.c > @@ -521,9 +521,11 @@ static virDomainNetDefPtr > lxcCreateNetDef(const char *type, > const char *link, > const char *mac, > - const char *flag) > + const char *flag, > + const char *macvlanmode) > { > virDomainNetDefPtr net = NULL; > + virMacAddr macAddr; > > if (VIR_ALLOC(net) < 0) > goto error; > @@ -535,9 +537,11 @@ lxcCreateNetDef(const char *type, > net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; > } > > - if (STREQ(type, "veth")) { > - virMacAddr macAddr; > > + if (mac && virMacAddrParse(mac, &macAddr) == 0) > + net->mac = macAddr; > + > + if (STREQ(type, "veth")) { > if (!link) > goto error; > > @@ -546,9 +550,18 @@ lxcCreateNetDef(const char *type, > if (VIR_STRDUP(net->data.bridge.brname, link) < 0) > goto error; > > - if (mac && virMacAddrParse(mac, &macAddr) == 0) > - net->mac = macAddr; > + } else if (STREQ(type, "macvlan")) { > + net->type = VIR_DOMAIN_NET_TYPE_DIRECT; > + > + if (VIR_STRDUP(net->data.direct.linkdev, link) < 0) > + goto error; > > + if (!macvlanmode || STREQ(macvlanmode, "private")) > + net->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_PRIVATE; > + else if (STREQ(macvlanmode, "vepa")) > + net->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_VEPA; > + else if (STREQ(macvlanmode, "bridget")) Is that really meant to be 'bridget' is is that a typo ? > + net->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_BRIDGE; We should likely have a 'else' clause which reports an error > @@ -655,10 +672,13 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virPropertiesPtr properties) > mac = property->value; > else if (STREQ(property->key, "lxc.network.flags")) > flag = property->value; > + else if (STREQ(property->key, "lxc.network.macvlan.mode")) > + macvlanmode = property->value; Perhaps we want to have a 'VIR_WARN' statement here. Reporting an error is a bit harsh, since we want to make best effort to report something sensible, so a VIR_WARN at least lets us know we've work todo > } > > /* Add the last network definition found */ > - status = lxcAddNetworkDefinition(def, type, link, mac, flag); > + status = lxcAddNetworkDefinition(def, type, link, mac, flag, > + macvlanmode); > if (status < 0) > return -1; > else if (status > 0) Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list