[libvirt] [PATCHv4 02/10] conf: support backend domain name in disk and network devices

Jim Fehlig jfehlig at suse.com
Fri Feb 20 21:49:54 UTC 2015


Marek Marczykowski-Górecki wrote:
> From: Marek Marczykowski <marmarek at invisiblethingslab.com>
>
> At least Xen supports backend drivers in another domain (aka "driver
> domain"). This patch introduces XML config option for such setting as
> 'domain' attribute of 'source' element. Verification its content is left
> for the driver.
>
> 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 at invisiblethingslab.com>
> ---
> Changes in v2:
>  - describe in docs/formatdomain.html.in
>  - enforce empty domain tag (only 'name' attribute allowed)
>
> Changes in v3:
>  - change <domain name='xx'/> element to domain='' attribute of source
>    element - this is more logical place
>  - grammar of docs
>
> Changes in v4:
>  - revert back to separate element, named <backenddomain name='xx'/>
>
>  docs/formatdomain.html.in     | 29 +++++++++++++++++++++++++++++
>  docs/schemas/domaincommon.rng | 16 ++++++++++++++++
>  src/conf/domain_conf.c        | 21 +++++++++++++++++++++
>  src/conf/domain_conf.h        |  2 ++
>  4 files changed, 68 insertions(+)
>
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index c5ad6f4..16d8b5c 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -2357,6 +2357,13 @@
>            </li>
>          </ul>
>        </dd>
> +      <dt><code>backenddomain</code></dt>
> +      <dd>The optional <code>backenddomain</code> element allows specifying a backend
> +        domain (aka driver domain) for the device. If the real device/file resides
> +        in some other domain on the same host, use the <code>name</code>
> +        attribute to specify its name.
>   

I shortened the long lines and changed the text a bit.

> +        <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
> @@ -4235,6 +4242,28 @@ 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>
> +  ...
> +  <devices>
> +    ...
> +    <interface type='bridge'>
> +      <source bridge='br0'/>
> +      <b><backenddomain name='netvm'/></b>
> +    </interface>
> +    ...
> +  </devices>
> +  ...</pre>
> +
> +    <p>
> +      The optional <code>backenddomain</code> element allows specifying a backend
> +      domain (aka driver domain) for the device. Use the <code>name</code> attribute
> +      to specify its 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 'bridge' to connect to some bridge
> +      inside the driver domain.
>   

Same here.

> +      <span class="since">Since 1.2.13 (Xen only)</span>
> +    </p>
>  
>      <h5><a name="elementQoS">Quality of service</a></h5>
>  
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index d467dce..6721431 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -1127,6 +1127,14 @@
>        </optional>
>        <ref name="target"/>
>        <optional>
> +        <element name="backenddomain">
> +          <attribute name="name">
> +            <ref name="domainName"/>
> +          </attribute>
> +          <empty/>
> +        </element>
> +      </optional>
> +      <optional>
>   

I moved this below "devcieBoot", since it seemed to fit there better :-).

>          <ref name="deviceBoot"/>
>        </optional>
>        <optional>
> @@ -2328,6 +2336,14 @@
>          </element>
>        </optional>
>        <optional>
> +        <element name="backenddomain">
> +          <attribute name="name">
> +            <ref name="domainName"/>
> +          </attribute>
> +          <empty/>
> +        </element>
> +      </optional>
> +      <optional>
>          <element name="model">
>            <attribute name="type">
>              <data type="string">
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 4251b13..657b71f 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -1260,6 +1260,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);
> @@ -1442,6 +1443,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);
> @@ -5725,6 +5727,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;
> @@ -5790,6 +5793,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) {
> @@ -6514,6 +6520,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;
> @@ -6576,6 +6584,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
>      VIR_FREE(product);
>      VIR_FREE(mirrorType);
>      VIR_FREE(mirrorFormat);
> +    VIR_FREE(domain_name);
>  
>      ctxt->node = save_ctxt;
>      return def;
> @@ -7365,6 +7374,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;
> @@ -7503,6 +7513,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")) {
> @@ -7802,6 +7815,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;
> @@ -8059,6 +8076,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>      VIR_FREE(mode);
>      VIR_FREE(linkstate);
>      VIR_FREE(addrtype);
> +    VIR_FREE(domain_name);
>      VIR_FREE(trustGuestRxFilters);
>      VIR_FREE(ips);
>      virNWFilterHashTableFree(filterparams);
> @@ -16820,6 +16838,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);
>  
> @@ -17786,6 +17806,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)))) {
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 93f2314..b2ef8db 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -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 */
>  };
>  
>  
> @@ -995,6 +996,7 @@ struct _virDomainNetDef {
>          unsigned long sndbuf;
>      } tune;
>      char *script;
> +    char *domain_name; /* backend domain name */
>      char *ifname;
>      char *ifname_guest;
>      char *ifname_guest_actual;
>   

ACK.  I'll squash in the below diff before pushing.

Regards,
Jim


diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index eb6a412..fb0a0d1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2373,11 +2373,10 @@
         </ul>
       </dd>
       <dt><code>backenddomain</code></dt>
-      <dd>The optional <code>backenddomain</code> element allows
specifying a backend
-        domain (aka driver domain) for the device. If the real
device/file resides
-        in some other domain on the same host, use the <code>name</code>
-        attribute to specify its name.
-        <span class="since">Since 1.2.13 (Xen only)</span>
+      <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>
@@ -4277,12 +4276,13 @@ qemu-kvm -net nic,model=? /dev/null
   ...</pre>
 
     <p>
-      The optional <code>backenddomain</code> element allows specifying
a backend
-      domain (aka driver domain) for the device. Use the
<code>name</code> attribute
-      to specify its 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 'bridge' to connect to some
bridge
-      inside the driver domain.
+      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>
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5476f5d..f41ca43 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1171,6 +1171,9 @@
       </optional>
       <ref name="target"/>
       <optional>
+        <ref name="deviceBoot"/>
+      </optional>
+      <optional>
         <element name="backenddomain">
           <attribute name="name">
             <ref name="domainName"/>
@@ -1179,9 +1182,6 @@
         </element>
       </optional>
       <optional>
-        <ref name="deviceBoot"/>
-      </optional>
-      <optional>
         <element name="readonly">
           <empty/>
         </element>




More information about the libvir-list mailing list