]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu aio: add XML parsing
authorMatthias Dahl <mdvirt@designassembly.de>
Wed, 21 Apr 2010 14:28:21 +0000 (16:28 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 28 Jan 2011 16:09:48 +0000 (09:09 -0700)
Allows io={threads|native} as an optional attribute to <driver>.

Signed-off-by: Eric Blake <eblake@redhat.com>
AUTHORS
docs/formatdomain.html.in
docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

diff --git a/AUTHORS b/AUTHORS
index 96aa0ad59501fa4527a7eb100d8bcd1742a6bfdb..131b30a83659d85d254d0691b26800b2fd70ca92 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -146,6 +146,7 @@ Patches have also been contributed by:
   Marc-André Lureau    <marcandre.lureau@redhat.com>
   Michal Prívozník     <mprivozn@redhat.com>
   Juerg Haefliger      <juerg.haefliger@hp.com>
+  Matthias Dahl        <mdvirt@designassembly.de>
 
   [....send patches to get your name here....]
 
index e7f65ade537c72e5ed56df75e78a6770b798e43a..48f82ae895b12bd041d24cd5a622e351de5de7eb 100644 (file)
     &lt;/disk&gt;
       ...
     &lt;disk type='network'&gt;
-      &lt;driver name="qemu" type="raw"/&gt;
+      &lt;driver name="qemu" type="raw" io="threads"/&gt;
       &lt;source protocol="sheepdog" name="image_name"&gt;
         &lt;host name="hostname" port="7000"/&gt;
       &lt;/source&gt;
         <span class="since">Since 0.0.3; <code>bus</code> attribute since 0.4.3;
         "usb" attribute value since after 0.4.4</span></dd>
       <dt><code>driver</code></dt>
-      <dd>If the hypervisor supports multiple backend drivers, then the optional
-        <code>driver</code> element allows them to be selected. The <code>name</code>
-        attribute is the primary backend driver name, while the optional <code>type</code>
-        attribute provides the sub-type. The optional <code>cache</code> attribute
-        controls the cache mechanism, possible values are "default", "none",
-        "writethrough" and "writeback". <span class="since">Since 0.1.8</span>
+      <dd>
+        The optional driver element allows specifying further details
+        related to the hypervisor driver used to provide the disk.
+        <span class="since">Since 0.1.8; <code>io</code> attribute
+        since 0.8.8</span>
+        <ul>
+          <li>
+            If the hypervisor supports multiple backend drivers, then
+            the <code>name</code> attribute selects the primary
+            backend driver name, while the optional <code>type</code>
+            attribute provides the sub-type.  For example, xen
+            supports a name of "tap", "tap2", "phy", or "file", with a
+            type of "aio", while qemu only supports a name of "qemu",
+            but multiple types including "raw", "bochs", "qcow2", and
+            "qed".
+          </li>
+          <li>
+            The optional <code>cache</code> attribute controls the
+            cache mechanism, possible values are "default", "none",
+            "writethrough" and "writeback".
+          </li>
+          <li>
+            The optional <code>error_policy</code> attribute controls
+            how the hypervisor will behave on an error, possible
+            values are "stop", "ignore", and "enospace".
+          </li>
+          <li>
+            The optional <code>io</code> attribute controls specific
+            policies on I/O; qemu guests support "threads" and
+            "native".
+          </li>
+        </ul>
       </dd>
       <dt><code>boot</code></dt>
       <dd>Specifies that the disk is bootable. The <code>order</code>
index b2f8e0069a24006f0be91441e577ab60c6919227..e4e742333d03d1e9f2b15f4d6d120b2fdf42e4b2 100644 (file)
       <optional>
         <ref name="driverErrorPolicy"/>
       </optional>
+      <optional>
+        <ref name="driverIO"/>
+      </optional>
       <empty/>
     </element>
   </define>
       </choice>
     </attribute>
   </define>
+  <define name="driverIO">
+    <attribute name="io">
+      <choice>
+        <value>threads</value>
+        <value>native</value>
+      </choice>
+    </attribute>
+  </define>
   <define name="controller">
     <element name="controller">
       <choice>
index 08c21e5fa5ab605103c95b6fa6fc8bbed8123c8d..b1cc6c82e04d72c7b2c5a6d6c27e1f7c76a1c2be 100644 (file)
@@ -149,6 +149,11 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST,
               "rbd",
               "sheepdog")
 
+VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST,
+              "default",
+              "native",
+              "threads")
+
 VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
               "ide",
               "fdc",
@@ -1683,6 +1688,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     char *bus = NULL;
     char *cachetag = NULL;
     char *error_policy = NULL;
+    char *iotag = NULL;
     char *devaddr = NULL;
     virStorageEncryptionPtr encryption = NULL;
     char *serial = NULL;
@@ -1797,6 +1803,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                 driverType = virXMLPropString(cur, "type");
                 cachetag = virXMLPropString(cur, "cache");
                 error_policy = virXMLPropString(cur, "error_policy");
+                iotag = virXMLPropString(cur, "io");
             } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
                 def->readonly = 1;
             } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
@@ -1924,6 +1931,15 @@ virDomainDiskDefParseXML(virCapsPtr caps,
         goto error;
     }
 
+    if (iotag) {
+        if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) < 0 ||
+            def->iomode == VIR_DOMAIN_DISK_IO_DEFAULT) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 _("unknown disk io mode '%s'"), iotag);
+            goto error;
+        }
+    }
+
     if (devaddr) {
         if (virDomainParseLegacyDeviceAddress(devaddr,
                                               &def->info.addr.pci) < 0) {
@@ -1985,6 +2001,7 @@ cleanup:
     VIR_FREE(driverName);
     VIR_FREE(cachetag);
     VIR_FREE(error_policy);
+    VIR_FREE(iotag);
     VIR_FREE(devaddr);
     VIR_FREE(serial);
     virStorageEncryptionFree(encryption);
@@ -6165,6 +6182,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
     const char *bus = virDomainDiskBusTypeToString(def->bus);
     const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode);
     const char *error_policy = virDomainDiskErrorPolicyTypeToString(def->error_policy);
+    const char *iomode = virDomainDiskIoTypeToString(def->iomode);
 
     if (!type) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -6186,6 +6204,11 @@ virDomainDiskDefFormat(virBufferPtr buf,
                              _("unexpected disk cache mode %d"), def->cachemode);
         return -1;
     }
+    if (!iomode) {
+        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                             _("unexpected disk io mode %d"), def->iomode);
+        return -1;
+    }
 
     virBufferVSprintf(buf,
                       "    <disk type='%s' device='%s'>\n",
@@ -6201,6 +6224,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
             virBufferVSprintf(buf, " cache='%s'", cachemode);
         if (def->error_policy)
             virBufferVSprintf(buf, " error_policy='%s'", error_policy);
+        if (def->iomode)
+            virBufferVSprintf(buf, " io='%s'", iomode);
         virBufferVSprintf(buf, "/>\n");
     }
 
index fc69627cfd092b2dfb0b61ccf775495521d6c9b3..871fa9ab06923cc5d6cdfb96a810be27ac84c659 100644 (file)
@@ -180,6 +180,14 @@ struct _virDomainDiskHostDef {
     char *port;
 };
 
+enum  virDomainDiskIo {
+    VIR_DOMAIN_DISK_IO_DEFAULT,
+    VIR_DOMAIN_DISK_IO_NATIVE,
+    VIR_DOMAIN_DISK_IO_THREADS,
+
+    VIR_DOMAIN_DISK_IO_LAST
+};
+
 /* Stores the virtual disk configuration */
 typedef struct _virDomainDiskDef virDomainDiskDef;
 typedef virDomainDiskDef *virDomainDiskDefPtr;
@@ -198,6 +206,7 @@ struct _virDomainDiskDef {
     int cachemode;
     int error_policy;
     int bootIndex;
+    int iomode;
     unsigned int readonly : 1;
     unsigned int shared : 1;
     virDomainDeviceInfo info;
@@ -1286,6 +1295,7 @@ VIR_ENUM_DECL(virDomainDiskBus)
 VIR_ENUM_DECL(virDomainDiskCache)
 VIR_ENUM_DECL(virDomainDiskErrorPolicy)
 VIR_ENUM_DECL(virDomainDiskProtocol)
+VIR_ENUM_DECL(virDomainDiskIo)
 VIR_ENUM_DECL(virDomainController)
 VIR_ENUM_DECL(virDomainControllerModel)
 VIR_ENUM_DECL(virDomainFS)
index b0ae692695a7526db1f374bc47a049e7d101663b..3a5aec9601a125bc1e55fbdcfab3d518bf82e50e 100644 (file)
@@ -232,9 +232,12 @@ virDomainDiskDefAssignAddress;
 virDomainDiskDefForeachPath;
 virDomainDiskDefFree;
 virDomainDiskDeviceTypeToString;
+virDomainDiskErrorPolicyTypeFromString;
 virDomainDiskErrorPolicyTypeToString;
 virDomainDiskInsert;
 virDomainDiskInsertPreAlloced;
+virDomainDiskIoTypeFromString;
+virDomainDiskIoTypeToString;
 virDomainDiskRemove;
 virDomainDiskTypeFromString;
 virDomainDiskTypeToString;