Added support for disk native AIO mode for KVM
authorMarco Casavecchia (aka MCM) <marcolinuz@gmail.com>
Thu, 24 Apr 2014 12:29:27 +0000 (14:29 +0200)
committerHelga Velroyen <helgav@google.com>
Thu, 24 Apr 2014 13:43:51 +0000 (15:43 +0200)
This patch adds support for the native aio on KVM
hypervisor.

Basically, It adds a new HV-KVM optional parameter
"disk_aio" that can be set with the followings values:
threads (the default for KVM) or native. If not set, it
uses the KVM default that is "threads". The patch also
updates the man page for gnt-instance.

Signed-off-by: Marco Casavecchia (aka MCM) <marcolinuz@gmail.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/hypervisor/hv_kvm/__init__.py
man/gnt-instance.rst
src/Ganeti/Constants.hs

index ac99fc5..220f484 100644 (file)
@@ -331,6 +331,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
     constants.HV_DISK_CACHE:
       hv_base.ParamInSet(True, constants.HT_VALID_CACHE_TYPES),
+    constants.HV_KVM_DISK_AIO:
+      hv_base.ParamInSet(False, constants.HT_KVM_VALID_AIO_TYPES),
     constants.HV_SECURITY_MODEL:
       hv_base.ParamInSet(True, constants.HT_KVM_VALID_SM_TYPES),
     constants.HV_SECURITY_DOMAIN: hv_base.NO_CHECK,
@@ -895,6 +897,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
         pass
     else:
       if_val = ",if=%s" % disk_type
+    # AIO mode
+    aio_mode = up_hvp[constants.HV_KVM_DISK_AIO]
+    if aio_mode == constants.HT_KVM_AIO_NATIVE:
+      aio_val = ",aio=%s" % aio_mode
+    else:
+      aio_val = ""
     # Cache mode
     disk_cache = up_hvp[constants.HV_DISK_CACHE]
     if instance.disk_template in constants.DTS_EXT_MIRROR:
@@ -927,8 +935,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       else:
         drive_uri = link_name
 
-      drive_val = "file=%s,format=raw%s%s%s" % \
-                  (drive_uri, if_val, boot_val, cache_val)
+      drive_val = "file=%s,format=raw%s%s%s%s" % \
+                  (drive_uri, if_val, boot_val, cache_val, aio_val)
 
       if device_driver:
         # kvm_disks are the 4th entry of runtime file that did not exist in
index 3d667e6..93beac5 100644 (file)
@@ -586,6 +586,14 @@ disk\_cache
     version of KVM used and disk type (always raw file under Ganeti),
     please refer to the KVM documentation for more details.
 
+disk\_aio
+    Valid for the KVM hypervisor.
+
+    This is an optional parameter that specifies the aio mode
+    for the disks. KVM default is to use the 'threads' mode,
+    so if not explicitly specified, the native mode will not
+    be used. Possible values are: threads or native.
+
 security\_model
     Valid for the KVM hypervisor.
 
index 348111a..825bf0e 100644 (file)
@@ -1565,6 +1565,9 @@ hvKvmMigrationCaps = "migration_caps"
 hvKvmPath :: String
 hvKvmPath = "kvm_path"
 
+hvKvmDiskAio :: String
+hvKvmDiskAio = "disk_aio"
+
 hvKvmSpiceAudioCompr :: String
 hvKvmSpiceAudioCompr = "spice_playback_compression"
 
@@ -1749,6 +1752,7 @@ hvsParameterTypes = Map.fromList
   , (hvKvmMachineVersion,               VTypeString)
   , (hvKvmMigrationCaps,                VTypeString)
   , (hvKvmPath,                         VTypeString)
+  , (hvKvmDiskAio,                      VTypeString)
   , (hvKvmSpiceAudioCompr,              VTypeBool)
   , (hvKvmSpiceBind,                    VTypeString)
   , (hvKvmSpiceIpVersion,               VTypeInt)
@@ -2588,6 +2592,17 @@ htValidCacheTypes =
                        htCacheWback,
                        htCacheWthrough]
 
+htKvmAioThreads :: String
+htKvmAioThreads = "threads"
+
+htKvmAioNative :: String
+htKvmAioNative = "native"
+
+htKvmValidAioTypes :: FrozenSet String
+htKvmValidAioTypes =
+  ConstantUtils.mkSet [htKvmAioThreads,
+                       htKvmAioNative]
+
 -- * Mouse types
 
 htMouseMouse :: String
@@ -3765,6 +3780,7 @@ hvcDefaults =
           , (hvNicType,                         PyValueEx htNicParavirtual)
           , (hvDiskType,                        PyValueEx htDiskParavirtual)
           , (hvKvmCdromDiskType,                PyValueEx "")
+          , (hvKvmDiskAio,                      PyValueEx htKvmAioThreads)
           , (hvUsbMouse,                        PyValueEx "")
           , (hvKeymap,                          PyValueEx "")
           , (hvMigrationPort,                   PyValueEx (8102 :: Int))