Re: [libvirt] [ 2/5] libvirt domain xml allow to set peer address

2016-04-07 Thread Daniel P. Berrange
On Mon, Apr 04, 2016 at 09:00:03PM +, Vasiliy Tolstov wrote:
> Signed-off-by: Vasiliy Tolstov 
> ---
>  docs/formatdomain.html.in | 12 +++-
>  docs/schemas/domaincommon.rng |  5 +
>  src/conf/domain_conf.c| 14 +-
>  src/conf/domain_conf.h|  1 +
>  4 files changed, 30 insertions(+), 2 deletions(-)

ACK


Regards,
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ 2/5] libvirt domain xml allow to set peer address

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 docs/formatdomain.html.in | 12 +++-
 docs/schemas/domaincommon.rng |  5 +
 src/conf/domain_conf.c| 14 +-
 src/conf/domain_conf.h|  1 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 957b839eb745..a6c6b15aa8e4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4758,6 +4758,7 @@ qemu-kvm -net nic,model=? /dev/null
   source network='default'/
   target dev='vnet0'/
   ip address='192.168.122.5' prefix='24'/
+  ip address='192.168.122.5' prefix='24' peer='10.0.0.10'/
   route family='ipv4' address='192.168.122.0' prefix='24' 
gateway='192.168.122.1'/
   route family='ipv4' address='192.168.122.8' 
gateway='192.168.122.1'/
 /interface
@@ -4790,7 +4791,16 @@ qemu-kvm -net nic,model=? /dev/null
 to define the network routes to use for the network device. The attributes
 of this element are described in the documentation for the 
route
 element in network 
definitions.
-This is only used by the LXC driver.
+This is used by the LXC driver and Since 1.3.3 
by the QEMU
+driver.
+
+
+
+Since 1.3.3 ip elements can hold peer attribute 
to assign
+a point-to-point address for the network device. The attributes  of this 
element
+are described in the documentation for the ip element in
+network definitions.
+This is only used by the LXC and QEMU drivers.
 
 
 vhost-user interface
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 54c149dd5290..fa545261326d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2393,6 +2393,11 @@
   
 
   
+  
+
+  
+
+  
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d4c78fdb9fbb..65d2b3eeef3b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5734,7 +5734,7 @@ virDomainNetIpParseXML(xmlNodePtr node)
 unsigned int prefixValue = 0;
 char *familyStr = NULL;
 int family = AF_UNSPEC;
-char *address = NULL;
+char *address = NULL, *peer = NULL;
 
 if (!(prefixStr = virXMLPropString(node, "prefix")) ||
 (virStrToLong_ui(prefixStr, NULL, 10, ) < 0)) {
@@ -5748,6 +5748,9 @@ virDomainNetIpParseXML(xmlNodePtr node)
 goto cleanup;
 }
 
+if ((peer = virXMLPropString(node, "peer")) == NULL)
+VIR_DEBUG("Peer is empty");
+
 familyStr = virXMLPropString(node, "family");
 if (familyStr && STREQ(familyStr, "ipv4"))
 family = AF_INET;
@@ -5765,6 +5768,14 @@ virDomainNetIpParseXML(xmlNodePtr node)
address);
 goto cleanup;
 }
+
+if ((peer != NULL) && (virSocketAddrParse(>peer, peer, family) < 0)) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _("Failed to parse IP address: '%s'"),
+   peer);
+goto cleanup;
+}
+
 ip->prefix = prefixValue;
 
 ret = ip;
@@ -5774,6 +5785,7 @@ virDomainNetIpParseXML(xmlNodePtr node)
 VIR_FREE(prefixStr);
 VIR_FREE(familyStr);
 VIR_FREE(address);
+VIR_FREE(peer);
 VIR_FREE(ip);
 return ret;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fe9faebff6d6..029eee3a5618 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -514,6 +514,7 @@ typedef struct _virDomainNetIpDef virDomainNetIpDef;
 typedef virDomainNetIpDef *virDomainNetIpDefPtr;
 struct _virDomainNetIpDef {
 virSocketAddr address;   /* ipv4 or ipv6 address */
+virSocketAddr peer;/* ipv4 or ipv6 address of peer */
 unsigned int prefix; /* number of 1 bits in the net mask */
 };
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list