]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt domain xml allow to set peer address
authorVasiliy Tolstov <v.tolstov@selfip.ru>
Mon, 4 Apr 2016 21:00:03 +0000 (21:00 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 7 Apr 2016 17:23:01 +0000 (18:23 +0100)
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 33b6105f96a2dbf7b60c76347a2ef551c4b9dd46..de477a07951d4a9bcea4f0fa0a6a74ac7c58bf03 100644 (file)
@@ -4758,6 +4758,7 @@ qemu-kvm -net nic,model=? /dev/null
       &lt;source network='default'/&gt;
       &lt;target dev='vnet0'/&gt;
       <b>&lt;ip address='192.168.122.5' prefix='24'/&gt;</b>
+      <b>&lt;ip address='192.168.122.5' prefix='24' peer='10.0.0.10'/&gt;</b>
       <b>&lt;route family='ipv4' address='192.168.122.0' prefix='24' gateway='192.168.122.1'/&gt;</b>
       <b>&lt;route family='ipv4' address='192.168.122.8' gateway='192.168.122.1'/&gt;</b>
     &lt;/interface&gt;
@@ -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 <code>route</code>
     element in <a href="formatnetwork.html#elementsStaticroute">network definitions</a>.
-    This is only used by the LXC driver.
+    This is used by the LXC driver and <span class="since">Since 1.3.3</span> by the QEMU
+    driver.
+    </p>
+
+    <p>
+    <span class="since">Since 1.3.3</span> 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 <code>ip</code> element in
+    <a href="formatnetwork.html#elementsAddress">network definitions</a>.
+    This is only used by the LXC and QEMU drivers.
     </p>
 
     <h5><a name="elementVhostuser">vhost-user interface</a></h5>
index 54c149dd52906d645549ea6ab09fb7ce3ccf9689..fa545261326dfb59c6aa8ae38c6d8adf638061c6 100644 (file)
               <ref name="ipPrefix"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="peer">
+              <ref name="ipAddr"/>
+            </attribute>
+          </optional>
           <empty/>
         </element>
       </zeroOrMore>
index 3203dab58e2c9f535610d6aa9cdaa51d1092304a..47311be52662feeb0f9b7741480f499347ed4f7e 100644 (file)
@@ -5733,7 +5733,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, &prefixValue) < 0)) {
@@ -5747,6 +5747,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;
@@ -5764,6 +5767,14 @@ virDomainNetIpParseXML(xmlNodePtr node)
                        address);
         goto cleanup;
     }
+
+    if ((peer != NULL) && (virSocketAddrParse(&ip->peer, peer, family) < 0)) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("Failed to parse IP address: '%s'"),
+                           peer);
+            goto cleanup;
+    }
+
     ip->prefix = prefixValue;
 
     ret = ip;
@@ -5773,6 +5784,7 @@ virDomainNetIpParseXML(xmlNodePtr node)
     VIR_FREE(prefixStr);
     VIR_FREE(familyStr);
     VIR_FREE(address);
+    VIR_FREE(peer);
     VIR_FREE(ip);
     return ret;
 }
index f98b4f68686efc5459f2c762b36af9677057b454..6f93def2658647a237c48f8188585275b711dd4e 100644 (file)
@@ -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 */
 };