Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
libvirt.401
2811cc61-net-caps-hostdev-ips.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2811cc61-net-caps-hostdev-ips.patch of Package libvirt.401
From 2811cc611e3c336e1dc5001a6077e5cf9d964dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com> Date: Wed, 23 Jul 2014 17:14:00 +0200 Subject: [PATCH 10/17] Allow network capabilities hostdev to configure IP addresses --- docs/formatdomain.html.in | 8 ++++++++ docs/schemas/domaincommon.rng | 28 ++++++++++++++++++++++++---- src/conf/domain_conf.c | 34 ++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ tests/lxcxml2xmldata/lxc-hostdev.xml | 2 ++ 5 files changed, 70 insertions(+), 4 deletions(-) Index: libvirt-1.2.5/docs/formatdomain.html.in =================================================================== --- libvirt-1.2.5.orig/docs/formatdomain.html.in +++ libvirt-1.2.5/docs/formatdomain.html.in @@ -3937,6 +3937,14 @@ qemu-kvm -net nic,model=? /dev/null <target dev='vnet0'/> <b><ip family='ipv4' address='192.168.122.5' prefix='24'/></b> </interface> + ... + <hostdev mode='capabilities' type='net'> + <source> + <interface>eth0</interface> + </source> + <b><ip family='ipv4' address='192.168.122.6' prefix='24'/></b> + </hostdev> + </devices> ... </pre> Index: libvirt-1.2.5/docs/schemas/domaincommon.rng =================================================================== --- libvirt-1.2.5.orig/docs/schemas/domaincommon.rng +++ libvirt-1.2.5/docs/schemas/domaincommon.rng @@ -3555,11 +3555,31 @@ <attribute name="type"> <value>net</value> </attribute> - <element name="source"> - <element name="interface"> - <ref name="deviceName"/> + <interleave> + <element name="source"> + <element name="interface"> + <ref name="deviceName"/> + </element> </element> - </element> + <zeroOrMore> + <element name="ip"> + <attribute name="address"> + <ref name="ipAddr"/> + </attribute> + <optional> + <attribute name="family"> + <ref name="addr-family"/> + </attribute> + </optional> + <optional> + <attribute name="prefix"> + <ref name="ipPrefix"/> + </attribute> + </optional> + <empty/> + </element> + </zeroOrMore> + </interleave> </define> <define name="usbproduct"> Index: libvirt-1.2.5/src/conf/domain_conf.c =================================================================== --- libvirt-1.2.5.orig/src/conf/domain_conf.c +++ libvirt-1.2.5/src/conf/domain_conf.c @@ -1742,6 +1742,8 @@ virDomainHostdevDefPtr virDomainHostdevD void virDomainHostdevDefClear(virDomainHostdevDefPtr def) { + size_t i; + if (!def) return; @@ -1766,6 +1768,9 @@ void virDomainHostdevDefClear(virDomainH break; case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET: VIR_FREE(def->source.caps.u.net.iface); + for (i = 0; i < def->source.caps.u.net.nips; i++) + VIR_FREE(def->source.caps.u.net.ips[i]); + VIR_FREE(def->source.caps.u.net.ips); break; } break; @@ -4460,6 +4465,8 @@ virDomainHostdevDefParseXMLCaps(xmlNodeP virDomainHostdevDefPtr def) { xmlNodePtr sourcenode; + xmlNodePtr *ipnodes = NULL; + int nipnodes; int ret = -1; /* @type is passed in from the caller rather than read from the @@ -4514,6 +4521,26 @@ virDomainHostdevDefParseXMLCaps(xmlNodeP _("Missing <interface> element in hostdev net device")); goto error; } + + /* Parse possible IP addresses */ + if ((nipnodes = virXPathNodeSet("./ip", ctxt, &ipnodes)) < 0) + goto error; + + if (nipnodes) { + size_t i; + for (i = 0; i < nipnodes; i++) { + virDomainNetIpDefPtr ip = virDomainNetIpParseXML(ipnodes[i]); + + if (!ip) + goto error; + + if (VIR_APPEND_ELEMENT(def->source.caps.u.net.ips, + def->source.caps.u.net.nips, ip) < 0) { + VIR_FREE(ip); + goto error; + } + } + } break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4523,6 +4550,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodeP } ret = 0; error: + VIR_FREE(ipnodes); return ret; } @@ -15781,6 +15809,12 @@ virDomainHostdevDefFormatCaps(virBufferP virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</source>\n"); + + if (def->source.caps.type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) { + virDomainNetIpsFormat(buf, def->source.caps.u.net.ips, + def->source.caps.u.net.nips); + } + return 0; } Index: libvirt-1.2.5/src/conf/domain_conf.h =================================================================== --- libvirt-1.2.5.orig/src/conf/domain_conf.h +++ libvirt-1.2.5/src/conf/domain_conf.h @@ -447,6 +447,8 @@ struct _virDomainHostdevCaps { } misc; struct { char *iface; + size_t nips; + virDomainNetIpDefPtr *ips; } net; } u; }; Index: libvirt-1.2.5/tests/lxcxml2xmldata/lxc-hostdev.xml =================================================================== --- libvirt-1.2.5.orig/tests/lxcxml2xmldata/lxc-hostdev.xml +++ libvirt-1.2.5/tests/lxcxml2xmldata/lxc-hostdev.xml @@ -35,6 +35,8 @@ <source> <interface>eth0</interface> </source> + <ip address='192.168.122.2' family='ipv4'/> + <ip address='2003:db8:1:0:214:1234:fe0b:3596' family='ipv6' prefix='24'/> </hostdev> </devices> </domain>
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