]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: support backend domain name in disk and network devices
authorMarek Marczykowski <marmarek@invisiblethingslab.com>
Fri, 20 Feb 2015 03:22:05 +0000 (04:22 +0100)
committerJim Fehlig <jfehlig@suse.com>
Fri, 20 Feb 2015 21:50:24 +0000 (14:50 -0700)
At least Xen supports backend drivers in another domain (aka "driver
domain"). This patch introduces an XML config option for specifying the
backend domain name for <disk> and <interface> devices.  E.g.

  <disk>
    <backenddomain name='diskvm'/>
    ...
  </disk>
  <interface type='bridge'>
    <backenddomain name='netvm'/>
    ...
  </interface>

In the future, same option will be needed for USB devices (hostdev
objects), but for now libxl doesn't have support for PVUSB.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index f6477c28d4e079424d30480438fa879d8d0fc6ad..fb0a0d14c94bad7532a9c99f8fd2934a18305d5e 100644 (file)
           </li>
         </ul>
       </dd>
+      <dt><code>backenddomain</code></dt>
+      <dd>The optional <code>backenddomain</code> element allows specifying a
+          backend domain (aka driver domain) hosting the disk.  Use the
+          <code>name</code> attribute to specify the backend domain name.
+          <span class="since">Since 1.2.13 (Xen only)</span>
+      </dd>
       <dt><code>boot</code></dt>
       <dd>Specifies that the disk is bootable. The <code>order</code>
         attribute determines the order in which devices will be tried during
@@ -4256,6 +4262,29 @@ qemu-kvm -net nic,model=? /dev/null
       network device.
       <span class="since">Since 0.9.10 (QEMU and KVM only)</span>.
     </p>
+    <h5><a name="elementDomain">Setting up a network backend in a driver domain</a></h5>
+<pre>
+  ...
+  &lt;devices&gt;
+    ...
+    &lt;interface type='bridge'&gt;
+      &lt;source bridge='br0'/&gt;
+      <b>&lt;backenddomain name='netvm'/&gt;</b>
+    &lt;/interface&gt;
+    ...
+  &lt;/devices&gt;
+  ...</pre>
+
+    <p>
+      The optional <code>backenddomain</code> element allows specifying a
+      backend domain (aka driver domain) for the interface. Use the
+      <code>name</code> attribute to specify the backend domain name. You
+      can use it to create a direct network link between domains (so data
+      will not go through host system). Use with type 'ethernet' to create
+      plain network link, or with type 'bridge' to connect to a bridge inside
+      the backend domain.
+      <span class="since">Since 1.2.13 (Xen only)</span>
+    </p>
 
     <h5><a name="elementQoS">Quality of service</a></h5>
 
index 27a24b46baa60ef59cf26882eaee7974ea713628..f41ca43434cc7ceab7746a2560fef048bf06a570 100644 (file)
       <optional>
         <ref name="deviceBoot"/>
       </optional>
+      <optional>
+        <element name="backenddomain">
+          <attribute name="name">
+            <ref name="domainName"/>
+          </attribute>
+          <empty/>
+        </element>
+      </optional>
       <optional>
         <element name="readonly">
           <empty/>
           <empty/>
         </element>
       </optional>
+      <optional>
+        <element name="backenddomain">
+          <attribute name="name">
+            <ref name="domainName"/>
+          </attribute>
+          <empty/>
+        </element>
+      </optional>
       <optional>
         <element name="model">
           <attribute name="type">
index b155a5a34cc2df3cd40d9091fd51e096d48765e7..d95dd3ebd54d8361524b492749cdfde81a3f3592 100644 (file)
@@ -1267,6 +1267,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
     VIR_FREE(def->wwn);
     VIR_FREE(def->vendor);
     VIR_FREE(def->product);
+    VIR_FREE(def->domain_name);
     virDomainDeviceInfoClear(&def->info);
 
     VIR_FREE(def);
@@ -1449,6 +1450,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
     VIR_FREE(def->backend.vhost);
     VIR_FREE(def->virtPortProfile);
     VIR_FREE(def->script);
+    VIR_FREE(def->domain_name);
     VIR_FREE(def->ifname);
     VIR_FREE(def->ifname_guest);
     VIR_FREE(def->ifname_guest_actual);
@@ -5887,6 +5889,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *discard = NULL;
     char *mirrorFormat = NULL;
     char *mirrorType = NULL;
+    char *domain_name = NULL;
     int expected_secret_usage = -1;
     int auth_secret_usage = -1;
     int ret = 0;
@@ -5952,6 +5955,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                 if (target &&
                     STRPREFIX(target, "ioemu:"))
                     memmove(target, target+6, strlen(target)-5);
+            } else if (!domain_name &&
+                       xmlStrEqual(cur->name, BAD_CAST "backenddomain")) {
+                domain_name = virXMLPropString(cur, "name");
             } else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) {
                 if (virXPathUInt("string(./geometry/@cyls)",
                                  ctxt, &def->geometry.cylinders) < 0) {
@@ -6676,6 +6682,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     driverName = NULL;
     def->src->encryption = encryption;
     encryption = NULL;
+    def->domain_name = domain_name;
+    domain_name = NULL;
     def->serial = serial;
     serial = NULL;
     def->wwn = wwn;
@@ -6738,6 +6746,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_FREE(product);
     VIR_FREE(mirrorType);
     VIR_FREE(mirrorFormat);
+    VIR_FREE(domain_name);
 
     ctxt->node = save_ctxt;
     return def;
@@ -7527,6 +7536,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *mode = NULL;
     char *linkstate = NULL;
     char *addrtype = NULL;
+    char *domain_name = NULL;
     char *vhostuser_mode = NULL;
     char *vhostuser_path = NULL;
     char *vhostuser_type = NULL;
@@ -7666,6 +7676,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
             } else if (!script &&
                        xmlStrEqual(cur->name, BAD_CAST "script")) {
                 script = virXMLPropString(cur, "path");
+            } else if (!domain_name &&
+                       xmlStrEqual(cur->name, BAD_CAST "backenddomain")) {
+                domain_name = virXMLPropString(cur, "name");
             } else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
                 model = virXMLPropString(cur, "type");
             } else if (xmlStrEqual(cur->name, BAD_CAST "driver")) {
@@ -7965,6 +7978,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->script = script;
         script = NULL;
     }
+    if (domain_name != NULL) {
+        def->domain_name = domain_name;
+        domain_name = NULL;
+    }
     if (ifname != NULL) {
         def->ifname = ifname;
         ifname = NULL;
@@ -8234,6 +8251,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_FREE(mode);
     VIR_FREE(linkstate);
     VIR_FREE(addrtype);
+    VIR_FREE(domain_name);
     VIR_FREE(trustGuestRxFilters);
     VIR_FREE(ips);
     VIR_FREE(vhost_path);
@@ -17162,6 +17180,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
                                         def->src->backingStoreRaw, 1) < 0)
         return -1;
 
+    virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
+
     virDomainDiskGeometryDefFormat(buf, def);
     virDomainDiskBlockIoDefFormat(buf, def);
 
@@ -18136,6 +18156,7 @@ virDomainNetDefFormat(virBufferPtr buf,
 
     virBufferEscapeString(buf, "<script path='%s'/>\n",
                           def->script);
+    virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
     if (def->ifname &&
         !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
           (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) {
index 86db2ab9df3c817e8b8a425e365b6fe71335192c..02ddd93a4d2234b826f65cbd2c605cfff3fdee98 100644 (file)
@@ -700,6 +700,7 @@ struct _virDomainDiskDef {
     int sgio; /* enum virDomainDeviceSGIO */
     int discard; /* enum virDomainDiskDiscard */
     unsigned int iothread; /* unused = 0, > 0 specific thread # */
+    char *domain_name; /* backend domain name */
 };
 
 
@@ -996,6 +997,7 @@ struct _virDomainNetDef {
         unsigned long sndbuf;
     } tune;
     char *script;
+    char *domain_name; /* backend domain name */
     char *ifname;
     char *ifname_guest;
     char *ifname_guest_actual;