Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
libvirt
ecdc9383-lxc-veth-set-ip.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ecdc9383-lxc-veth-set-ip.patch of Package libvirt
From ecdc93830e2fccd6802ffbfefc6002f1a5f6c1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com> Date: Tue, 22 Jul 2014 13:35:48 +0200 Subject: [PATCH 08/17] LXC: set IP addresses to veth devices in the container Uses the new virDomainNetDef ips to set the IP addresses on the network interfaces in the container. --- src/lxc/lxc_container.c | 20 +++++++++++++++++++- src/util/virsocketaddr.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) Index: libvirt-1.2.5/src/lxc/lxc_container.c =================================================================== --- libvirt-1.2.5.orig/src/lxc/lxc_container.c +++ libvirt-1.2.5/src/lxc/lxc_container.c @@ -495,7 +495,7 @@ static int lxcContainerRenameAndEnableIn char **veths) { int rc = 0; - size_t i; + size_t i, j; char *newname = NULL; virDomainNetDefPtr netDef; bool privNet = vmDef->features[VIR_DOMAIN_FEATURE_PRIVNET] == @@ -516,6 +516,24 @@ static int lxcContainerRenameAndEnableIn if (rc < 0) goto error_out; + for (j = 0; j < netDef->nips; j++) { + virDomainNetIpDefPtr ip = netDef->ips[j]; + unsigned int prefix = (ip->prefix > 0) ? ip->prefix : + VIR_SOCKET_ADDR_DEFAULT_PREFIX; + char *ipStr = virSocketAddrFormat(&ip->address); + + VIR_DEBUG("Adding IP address '%s/%u' to '%s'", + ipStr, ip->prefix, newname); + if (virNetDevSetIPAddress(newname, &ip->address, prefix) < 0) { + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to set IP address '%s' on %s"), + ipStr, newname); + VIR_FREE(ipStr); + goto error_out; + } + VIR_FREE(ipStr); + } + VIR_DEBUG("Enabling %s", newname); rc = virNetDevSetOnline(newname, true); if (rc < 0) Index: libvirt-1.2.5/src/util/virsocketaddr.h =================================================================== --- libvirt-1.2.5.orig/src/util/virsocketaddr.h +++ libvirt-1.2.5/src/util/virsocketaddr.h @@ -54,6 +54,8 @@ typedef struct { # define VIR_SOCKET_ADDR_FAMILY(s) \ ((s)->data.sa.sa_family) +# define VIR_SOCKET_ADDR_DEFAULT_PREFIX 24 + typedef virSocketAddr *virSocketAddrPtr; typedef struct _virSocketAddrRange virSocketAddrRange;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor