forked from pool/libvirt
43a3b335a6
- lxc AppArmor profile now only restricting potentially dangerous accesses. fdo#886460 - added patches: * 9265f8ab-apparmor-lxc-rework.patch * 9b1e4cd5-skip-useless-apparmor-files.patch - virt-lxc-convert: force free to output values in bytes - added patches: * dba3432b-virt-lxc-convert-fix.patch - lxc: allow setting a custom name for container NICs as LXC is is able to do it. lxc-net-target-name.patch, lxc-net-target-name-conversion.patch, lxc-net-target-name-doc.patch OBS-URL: https://build.opensuse.org/request/show/241206 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=390
131 lines
5.1 KiB
Diff
131 lines
5.1 KiB
Diff
From 27b425b5f77029bf0d322afb930eabf6ec6899e4 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
|
|
Date: Wed, 2 Jul 2014 15:13:40 +0200
|
|
Subject: [PATCH 1/2] lxc conf2xml: convert lxc.network.name for veth networks
|
|
|
|
---
|
|
src/lxc/lxc_native.c | 22 ++++++++++++++++------
|
|
.../lxcconf2xmldata/lxcconf2xml-physnetwork.config | 1 +
|
|
tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 1 +
|
|
3 files changed, 18 insertions(+), 6 deletions(-)
|
|
|
|
Index: libvirt-1.2.5/src/lxc/lxc_native.c
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/src/lxc/lxc_native.c
|
|
+++ libvirt-1.2.5/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
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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(virDomainDefPt
|
|
{
|
|
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(virDomainDefPt
|
|
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)
|
|
Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
|
|
+++ libvirt-1.2.5/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
|
|
Index: libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
|
|
===================================================================
|
|
--- libvirt-1.2.5.orig/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
|
|
+++ libvirt-1.2.5/tests/lxcconf2xmldata/lxcconf2xml-simple.xml
|
|
@@ -37,6 +37,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'>
|