From: Matthias Dahl <mdvirt(a)designassembly.de>
Allows aio={threads|native} as an optional attribute to <driver>.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Changes from v3:
export the private symbol
break a single patch into a 4-patch series, along the lines
of what was done in commit 8bf6799 when adding timer support
src/conf/domain_conf.c | 23 +++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++++++
src/libvirt_private.syms | 3 +++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3e45f79..118585a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -132,6 +132,11 @@ VIR_ENUM_IMPL(virDomainDiskErrorPolicy,
VIR_DOMAIN_DISK_ERROR_POLICY_LAST,
"ignore",
"enospace")
+VIR_ENUM_IMPL(virDomainDiskAIO, VIR_DOMAIN_DISK_AIO_LAST,
+ "default",
+ "native",
+ "threads")
+
VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
"ide",
"fdc",
@@ -1378,6 +1383,7 @@ virDomainDiskDefParseXML(xmlNodePtr node,
char *bus = NULL;
char *cachetag = NULL;
char *error_policy = NULL;
+ char *aiotag = NULL;
char *devaddr = NULL;
virStorageEncryptionPtr encryption = NULL;
char *serial = NULL;
@@ -1444,6 +1450,7 @@ virDomainDiskDefParseXML(xmlNodePtr node,
driverType = virXMLPropString(cur, "type");
cachetag = virXMLPropString(cur, "cache");
error_policy = virXMLPropString(cur, "error_policy");
+ aiotag = virXMLPropString(cur, "aio");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = 1;
} else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
@@ -1567,6 +1574,13 @@ virDomainDiskDefParseXML(xmlNodePtr node,
goto error;
}
+ if (aiotag &&
+ (def->aiomode = virDomainDiskAIOTypeFromString(aiotag)) < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown disk aio mode '%s'"), aiotag);
+ goto error;
+ }
+
if (devaddr) {
if (virDomainParseLegacyDeviceAddress(devaddr,
&def->info.addr.pci) < 0) {
@@ -1608,6 +1622,7 @@ cleanup:
VIR_FREE(driverName);
VIR_FREE(cachetag);
VIR_FREE(error_policy);
+ VIR_FREE(aiotag);
VIR_FREE(devaddr);
VIR_FREE(serial);
virStorageEncryptionFree(encryption);
@@ -4887,6 +4902,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 *aiomode = virDomainDiskAIOTypeToString(def->aiomode);
if (!type) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4908,6 +4924,11 @@ virDomainDiskDefFormat(virBufferPtr buf,
_("unexpected disk cache mode %d"),
def->cachemode);
return -1;
}
+ if (!aiomode) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected disk aio mode %d"),
def->aiomode);
+ return -1;
+ }
virBufferVSprintf(buf,
" <disk type='%s'
device='%s'>\n",
@@ -4923,6 +4944,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferVSprintf(buf, " cache='%s'", cachemode);
if (def->error_policy)
virBufferVSprintf(buf, " error_policy='%s'",
error_policy);
+ if (def->aiomode)
+ virBufferVSprintf(buf, " aio='%s'", aiomode);
virBufferVSprintf(buf, "/>\n");
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fadc8bd..1eec1d2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -161,6 +161,14 @@ enum virDomainDiskErrorPolicy {
VIR_DOMAIN_DISK_ERROR_POLICY_LAST
};
+enum virDomainDiskAIO {
+ VIR_DOMAIN_DISK_AIO_DEFAULT,
+ VIR_DOMAIN_DISK_AIO_NATIVE,
+ VIR_DOMAIN_DISK_AIO_THREADS,
+
+ VIR_DOMAIN_DISK_AIO_LAST
+};
+
/* Stores the virtual disk configuration */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;
@@ -175,6 +183,7 @@ struct _virDomainDiskDef {
char *serial;
int cachemode;
int error_policy;
+ int aiomode;
unsigned int readonly : 1;
unsigned int shared : 1;
virDomainDeviceInfo info;
@@ -1069,6 +1078,7 @@ VIR_ENUM_DECL(virDomainDiskDevice)
VIR_ENUM_DECL(virDomainDiskBus)
VIR_ENUM_DECL(virDomainDiskCache)
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
+VIR_ENUM_DECL(virDomainDiskAIO)
VIR_ENUM_DECL(virDomainController)
VIR_ENUM_DECL(virDomainFS)
VIR_ENUM_DECL(virDomainNet)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 09f3da1..f1555d8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,9 @@ virDomainDeviceInfoIterate;
virDomainClockOffsetTypeToString;
virDomainClockOffsetTypeFromString;
virDomainDiskErrorPolicyTypeToString;
+virDomainDiskErrorPolicyTypeFromString;
+virDomainDiskAIOToString;
+virDomainDiskAIOFromString;
virDomainTimerNameTypeToString;
virDomainTimerNameTypeFromString;
virDomainTimerTrackTypeToString;
--
1.7.0.1