On Wed, Feb 05, 2014 at 03:10:15PM +0100, Cédric Bosdonnat wrote:
The problem with VLAN is that the user still has to manually create
the
vlan interface on the host. Then the generated configuration will use
it as a nerwork hostdev device. So the generated configurations of the
following two fragments are equivalent (see rhbz#1059637).
lxc.network.type = phys
lxc.network.link = eth0.5
lxc.network.type = vlan
lxc.network.link = eth0
lxc.network.vlan.id = 5
---
src/lxc/lxc_native.c | 28 ++++++++++++++++++----
.../lxcconf2xmldata/lxcconf2xml-vlannetwork.config | 12 ++++++++++
tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml | 26 ++++++++++++++++++++
tests/lxcconf2xmltest.c | 1 +
4 files changed, 62 insertions(+), 5 deletions(-)
create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.config
create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 9a16523..8d8c50a 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -411,22 +411,33 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
const char *link,
const char *mac,
const char *flag,
- const char *macvlanmode)
+ const char *macvlanmode,
+ const char *vlanid)
{
virDomainNetDefPtr net = NULL;
virDomainHostdevDefPtr hostdev = NULL;
+ bool isPhys, isVlan = false;
if ((type == NULL) || STREQ(type, "empty") || STREQ(type, "")
||
STREQ(type, "none"))
return 0;
- if (type != NULL && STREQ(type, "phys")) {
+ isPhys = STREQ(type, "phys");
+ isVlan = STREQ(type, "vlan");
+ if (type != NULL && (isPhys || isVlan)) {
if (!link ||
!(hostdev = lxcCreateHostdevDef(VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
link)))
goto error;
+ /* This still requires the user to manually setup the vlan interface
+ * on the host */
+ if (isVlan && !(link && vlanid &&
+ virAsprintf(&hostdev->source.caps.u.net.iface,
+ "%s.%s", link, vlanid) >= 0))
+ goto error;
Small memory leak as this virAsprintf overwrites memory allocated
by lxcCreateHostdevDef. Will fx that when pushing
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 :|