[libvirt] [RFC PATCH] Support for qemu aio drive option

This is a "quick" implementation to support the qemu aio drive option. I tried to stay true to the coding style and this has been tested w/ libvirt 0.7.6 and works just fine. Since I am not that familiar w/ the inner workings of libvirt, I am sure I missed a few spots, so I hope either someone will base his work on this patch or point me into the right direction so I can finish this up for good. :-) For everyone else, enjoy... --- src/conf/domain_conf.c | 23 +++++++++++++++++++++++ src/conf/domain_conf.h | 10 ++++++++++ src/qemu/qemu_conf.c | 14 ++++++++++++++ src/qemu/qemu_conf.h | 2 ++ 4 files changed, 49 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 766993c..8bee7b8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -120,6 +120,11 @@ VIR_ENUM_IMPL(virDomainDiskCache, VIR_DOMAIN_DISK_CACHE_LAST, "writethrough", "writeback") +VIR_ENUM_IMPL(virDomainDiskAIO, VIR_DOMAIN_DISK_AIO_LAST, + "default", + "native", + "threads") + VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST, "ide", "fdc", @@ -1228,6 +1233,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, char *target = NULL; char *bus = NULL; char *cachetag = NULL; + char *aiotag = NULL; char *devaddr = NULL; virStorageEncryptionPtr encryption = NULL; char *serial = NULL; @@ -1293,6 +1299,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, driverName = virXMLPropString(cur, "name"); driverType = virXMLPropString(cur, "type"); cachetag = virXMLPropString(cur, "cache"); + aiotag = virXMLPropString(cur, "aio"); } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { def->readonly = 1; } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { @@ -1409,6 +1416,13 @@ virDomainDiskDefParseXML(virConnectPtr conn, goto error; } + if (aiotag && + (def->aiomode = virDomainDiskAIOTypeFromString(aiotag)) < 0) { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("unknown disk aio mode '%s'"), aiotag); + goto error; + } + if (devaddr) { if (sscanf(devaddr, "%x:%x:%x", &def->info.addr.pci.domain, @@ -1450,6 +1464,7 @@ cleanup: VIR_FREE(driverType); VIR_FREE(driverName); VIR_FREE(cachetag); + VIR_FREE(aiotag); VIR_FREE(devaddr); VIR_FREE(serial); virStorageEncryptionFree(encryption); @@ -4565,6 +4580,7 @@ virDomainDiskDefFormat(virConnectPtr conn, const char *device = virDomainDiskDeviceTypeToString(def->device); const char *bus = virDomainDiskBusTypeToString(def->bus); const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode); + const char *aiomode = virDomainDiskAIOTypeToString(def->aiomode); if (!type) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -4586,6 +4602,11 @@ virDomainDiskDefFormat(virConnectPtr conn, _("unexpected disk cache mode %d"), def- >cachemode); return -1; } + if (!aiomode) { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("unexpected disk aio mode %d"), def->aiomode); + return -1; + } virBufferVSprintf(buf, " <disk type='%s' device='%s'>\n", @@ -4597,6 +4618,8 @@ virDomainDiskDefFormat(virConnectPtr conn, virBufferVSprintf(buf, " type='%s'", def->driverType); if (def->cachemode) virBufferVSprintf(buf, " cache='%s'", cachemode); + 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 0b79e88..07805a6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -141,6 +141,14 @@ enum virDomainDiskCache { VIR_DOMAIN_DISK_CACHE_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; @@ -154,6 +162,7 @@ struct _virDomainDiskDef { char *driverType; char *serial; int cachemode; + int aiomode; unsigned int readonly : 1; unsigned int shared : 1; virDomainDeviceInfo info; @@ -897,6 +906,7 @@ VIR_ENUM_DECL(virDomainDisk) VIR_ENUM_DECL(virDomainDiskDevice) VIR_ENUM_DECL(virDomainDiskBus) VIR_ENUM_DECL(virDomainDiskCache) +VIR_ENUM_DECL(virDomainDiskAIO) VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3d83a8f..fd3a670 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -83,6 +83,12 @@ VIR_ENUM_IMPL(qemuDiskCacheV2, VIR_DOMAIN_DISK_CACHE_LAST, "writethrough", "writeback"); +VIR_ENUM_DECL(qemuDiskAIO) +VIR_ENUM_IMPL(qemuDiskAIO, VIR_DOMAIN_DISK_AIO_LAST, + "default", + "native", + "threads"); + VIR_ENUM_DECL(qemuVideo) VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, @@ -1137,6 +1143,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_DRIVE_CACHE_V2; if (strstr(help, "format=")) flags |= QEMUD_CMD_FLAG_DRIVE_FORMAT; + if (strstr(help, "aio=threads|native")) + flags |= QEMUD_CMD_FLAG_DRIVE_AIO; } if (strstr(help, "-vga") && !strstr(help, "-std-vga")) flags |= QEMUD_CMD_FLAG_VGA; @@ -2340,6 +2348,12 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAddLit(&opt, ",cache=off"); } + if (disk->aiomode && (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_AIO)) { + const char * mode = qemuDiskAIOTypeToString(disk->aiomode); + + virBufferVSprintf(&opt, ",aio=%s", mode); + } + if (virBufferError(&opt)) { virReportOOMError(NULL); goto error; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 101f187..780ae6e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -82,6 +82,8 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_SDL = (1 << 27), /* Is the new -sdl arg available */ QEMUD_CMD_FLAG_SMP_TOPOLOGY = (1 << 28), /* Is sockets=s,cores=c,threads=t available for -smp? */ QEMUD_CMD_FLAG_NETDEV = (1 << 29), /* The -netdev flag & netdev_add/remove monitor commands */ + + QEMUD_CMD_FLAG_DRIVE_AIO = (1 << 30), /* Is -drive aio= avail */ }; /* Main driver state */ -- 1.7.0.4

On 04/18/2010 07:47 AM, Matthias Dahl wrote:
This is a "quick" implementation to support the qemu aio drive option. I tried to stay true to the coding style and this has been tested w/ libvirt 0.7.6 and works just fine.
Since I am not that familiar w/ the inner workings of libvirt, I am sure I missed a few spots, so I hope either someone will base his work on this patch or point me into the right direction so I can finish this up for good. :-)
This is a decent start, but it's still missing XML definition, remote protocol support, and virsh support. docs/api_extension gives a sample patch series that shows all the pieces that are necessary for enhancing the API. Would you like to try your hand at respinning this into a multi-patch submission? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2010/4/20 Eric Blake <eblake@redhat.com>:
On 04/18/2010 07:47 AM, Matthias Dahl wrote:
This is a "quick" implementation to support the qemu aio drive option. I tried to stay true to the coding style and this has been tested w/ libvirt 0.7.6 and works just fine.
Since I am not that familiar w/ the inner workings of libvirt, I am sure I missed a few spots, so I hope either someone will base his work on this patch or point me into the right direction so I can finish this up for good. :-)
This is a decent start, but it's still missing XML definition, remote protocol support, and virsh support. docs/api_extension gives a sample patch series that shows all the pieces that are necessary for enhancing the API.
This is just an domain XML extension. Why does it need remote protocol support or virsh support? Parts that are really missing: Documenting this new domain XML attribute in docs/formatdomain.html.in and updating the docs/schemas/domain.rng. Once that done I would consider this patch as complete. Matthias

On 04/20/2010 03:23 PM, Matthias Bolte wrote:
This is a decent start, but it's still missing XML definition, remote protocol support, and virsh support. docs/api_extension gives a sample patch series that shows all the pieces that are necessary for enhancing the API.
This is just an domain XML extension. Why does it need remote protocol support or virsh support?
That would be my inexperience with major additions showing through; I was assuming that this required remote support, but you may indeed be correct that it is more localized than that. Sorry if I accidentally overstated the scope of this addition.
Parts that are really missing: Documenting this new domain XML attribute in docs/formatdomain.html.in and updating the docs/schemas/domain.rng. Once that done I would consider this patch as complete.
Agreed - without the change in docs/schemas/domain.rng, the existing patch cannot ever be fed validated XML that includes the new attribute in the first place. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tuesday 20 April 2010 23:23:26 Matthias Bolte wrote:
Parts that are really missing: Documenting this new domain XML attribute in docs/formatdomain.html.in and updating the docs/schemas/domain.rng. Once that done I would consider this patch as complete.
Thanks a lot Eric and Matthias for your comments. I added both and have just posted a revised patch for consideration. So long, matthias
participants (3)
-
Eric Blake
-
Matthias Bolte
-
Matthias Dahl