qemu aio: add XML parsing

Allows io={threads|native} as an optional attribute to <driver>.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Matthias Dahl 2010-04-21 16:28:21 +02:00 committed by Eric Blake
parent eb1be58e0e
commit 91ef4e05ea
6 changed files with 83 additions and 7 deletions

View File

@ -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....]

View File

@ -716,7 +716,7 @@
&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;
@ -768,12 +768,38 @@
<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>

View File

@ -696,6 +696,9 @@
<optional>
<ref name="driverErrorPolicy"/>
</optional>
<optional>
<ref name="driverIO"/>
</optional>
<empty/>
</element>
</define>
@ -727,6 +730,14 @@
</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>

View 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");
}

View 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)

View File

@ -232,9 +232,12 @@ virDomainDiskDefAssignAddress;
virDomainDiskDefForeachPath;
virDomainDiskDefFree;
virDomainDiskDeviceTypeToString;
virDomainDiskErrorPolicyTypeFromString;
virDomainDiskErrorPolicyTypeToString;
virDomainDiskInsert;
virDomainDiskInsertPreAlloced;
virDomainDiskIoTypeFromString;
virDomainDiskIoTypeToString;
virDomainDiskRemove;
virDomainDiskTypeFromString;
virDomainDiskTypeToString;