From 91ef4e05eac546f8ffdb18979cd21e4aee3dcbfd Mon Sep 17 00:00:00 2001 From: Matthias Dahl Date: Wed, 21 Apr 2010 16:28:21 +0200 Subject: [PATCH] qemu aio: add XML parsing Allows io={threads|native} as an optional attribute to . Signed-off-by: Eric Blake --- AUTHORS | 1 + docs/formatdomain.html.in | 40 ++++++++++++++++++++++++++++++++------- docs/schemas/domain.rng | 11 +++++++++++ src/conf/domain_conf.c | 25 ++++++++++++++++++++++++ src/conf/domain_conf.h | 10 ++++++++++ src/libvirt_private.syms | 3 +++ 6 files changed, 83 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 96aa0ad595..131b30a836 100644 --- a/AUTHORS +++ b/AUTHORS @@ -146,6 +146,7 @@ Patches have also been contributed by: Marc-André Lureau Michal Prívozník Juerg Haefliger + Matthias Dahl [....send patches to get your name here....] diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e7f65ade53..48f82ae895 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -716,7 +716,7 @@ </disk> ... <disk type='network'> - <driver name="qemu" type="raw"/> + <driver name="qemu" type="raw" io="threads"/> <source protocol="sheepdog" name="image_name"> <host name="hostname" port="7000"/> </source> @@ -768,12 +768,38 @@ Since 0.0.3; bus attribute since 0.4.3; "usb" attribute value since after 0.4.4
driver
-
If the hypervisor supports multiple backend drivers, then the optional - driver element allows them to be selected. The name - attribute is the primary backend driver name, while the optional type - attribute provides the sub-type. The optional cache attribute - controls the cache mechanism, possible values are "default", "none", - "writethrough" and "writeback". Since 0.1.8 +
+ The optional driver element allows specifying further details + related to the hypervisor driver used to provide the disk. + Since 0.1.8; io attribute + since 0.8.8 +
    +
  • + If the hypervisor supports multiple backend drivers, then + the name attribute selects the primary + backend driver name, while the optional type + 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". +
  • +
  • + The optional cache attribute controls the + cache mechanism, possible values are "default", "none", + "writethrough" and "writeback". +
  • +
  • + The optional error_policy attribute controls + how the hypervisor will behave on an error, possible + values are "stop", "ignore", and "enospace". +
  • +
  • + The optional io attribute controls specific + policies on I/O; qemu guests support "threads" and + "native". +
  • +
boot
Specifies that the disk is bootable. The order diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index b2f8e0069a..e4e742333d 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -696,6 +696,9 @@ + + + @@ -727,6 +730,14 @@ + + + + threads + native + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 08c21e5fa5..b1cc6c82e0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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, " \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"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fc69627cfd..871fa9ab06 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -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) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b0ae692695..3a5aec9601 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -232,9 +232,12 @@ virDomainDiskDefAssignAddress; virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDeviceTypeToString; +virDomainDiskErrorPolicyTypeFromString; virDomainDiskErrorPolicyTypeToString; virDomainDiskInsert; virDomainDiskInsertPreAlloced; +virDomainDiskIoTypeFromString; +virDomainDiskIoTypeToString; virDomainDiskRemove; virDomainDiskTypeFromString; virDomainDiskTypeToString;