This will allow the user to explicitly set the type of SCSI
controller to use. The available types are: lsi, virtio-scsi-pci,
and megasas. QEMU uses lsi by default and so does Ganeti.

Signed-off-by: Dimitris Aragiorgis <[email protected]>
---
 lib/hypervisor/hv_kvm/__init__.py |   15 ++++++++++-----
 man/gnt-instance.rst              |   11 +++++++++++
 src/Ganeti/Constants.hs           |   22 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/lib/hypervisor/hv_kvm/__init__.py 
b/lib/hypervisor/hv_kvm/__init__.py
index 4dc79d5..bac72c0 100644
--- a/lib/hypervisor/hv_kvm/__init__.py
+++ b/lib/hypervisor/hv_kvm/__init__.py
@@ -476,6 +476,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       hv_base.ParamInSet(True, constants.HT_KVM_VALID_NIC_TYPES),
     constants.HV_DISK_TYPE:
       hv_base.ParamInSet(True, constants.HT_KVM_VALID_DISK_TYPES),
+    constants.HV_KVM_SCSI_CONTROLLER_TYPE:
+      hv_base.ParamInSet(True, constants.HT_KVM_VALID_SCSI_CONTROLLER_TYPES),
     constants.HV_KVM_CDROM_DISK_TYPE:
       hv_base.ParamInSet(False, constants.HT_KVM_VALID_DISK_TYPES),
     constants.HV_USB_MOUSE:
@@ -1230,11 +1232,14 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       soundhw = hvp[constants.HV_SOUNDHW]
       kvm_cmd.extend(["-soundhw", soundhw])
 
-    if hvp[constants.HV_DISK_TYPE] == constants.HT_DISK_SCSI:
-      # In case a SCSI disk is given, QEMU adds
-      # a SCSI contorller (LSI Logic / Symbios Logic 53c895a)
-      # implicitly.
-      pass
+    if hvp[constants.HV_DISK_TYPE] in constants.HT_SCSI_DEVICE_TYPES:
+      # In case a SCSI disk is given, QEMU adds a SCSI contorller
+      # (LSI Logic / Symbios Logic 53c895a) implicitly.
+      # Here, we add the controller explicitly with the default id.
+      kvm_cmd.extend([
+        "-device",
+        "%s,id=scsi" % hvp[constants.HV_KVM_SCSI_CONTROLLER_TYPE]
+        ])
 
     kvm_cmd.extend(["-balloon", "virtio"])
     kvm_cmd.extend(["-daemonize"])
diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst
index a29fd79..03d8fc9 100644
--- a/man/gnt-instance.rst
+++ b/man/gnt-instance.rst
@@ -333,6 +333,17 @@ vif\_type
     - ioemu
     - vif
 
+scsi\_controller\_type
+    Valid for the KVM hypervisor.
+
+    This parameter specifies which type of SCSI controller to use.
+    The possible options are:
+
+    - lsi [default]
+    - megasas
+    - virtio-scsi-pci
+
+
 disk\_type
     Valid for the Xen HVM and KVM hypervisors.
 
diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
index 7b8ece5..98d6805 100644
--- a/src/Ganeti/Constants.hs
+++ b/src/Ganeti/Constants.hs
@@ -1697,6 +1697,9 @@ hvKvmPath = "kvm_path"
 hvKvmDiskAio :: String
 hvKvmDiskAio = "disk_aio"
 
+hvKvmScsiControllerType :: String
+hvKvmScsiControllerType = "scsi_controller_type"
+
 hvKvmSpiceAudioCompr :: String
 hvKvmSpiceAudioCompr = "spice_playback_compression"
 
@@ -1903,6 +1906,7 @@ hvsParameterTypes = Map.fromList
   , (hvKvmMigrationCaps,                VTypeString)
   , (hvKvmPath,                         VTypeString)
   , (hvKvmDiskAio,                      VTypeString)
+  , (hvKvmScsiControllerType,           VTypeString)
   , (hvKvmSpiceAudioCompr,              VTypeBool)
   , (hvKvmSpiceBind,                    VTypeString)
   , (hvKvmSpiceIpVersion,               VTypeInt)
@@ -2762,6 +2766,23 @@ htKvmValidDiskTypes =
                        htDiskScsiHd,
                        htDiskScsiCd]
 
+-- * SCSI controller types
+
+htScsiControllerLsi :: String
+htScsiControllerLsi = "lsi"
+
+htScsiControllerVirtio :: String
+htScsiControllerVirtio = "virtio-scsi-pci"
+
+htScsiControllerMegasas :: String
+htScsiControllerMegasas = "megasas"
+
+htKvmValidScsiControllerTypes :: FrozenSet String
+htKvmValidScsiControllerTypes =
+  ConstantUtils.mkSet [htScsiControllerLsi,
+                       htScsiControllerVirtio,
+                       htScsiControllerMegasas]
+
 htCacheDefault :: String
 htCacheDefault = "default"
 
@@ -4036,6 +4057,7 @@ hvcDefaults =
           , (hvVncX509,                         PyValueEx "")
           , (hvVncX509Verify,                   PyValueEx False)
           , (hvVncPasswordFile,                 PyValueEx "")
+          , (hvKvmScsiControllerType,           PyValueEx htScsiControllerLsi)
           , (hvKvmSpiceBind,                    PyValueEx "")
           , (hvKvmSpiceIpVersion,           PyValueEx 
ifaceNoIpVersionSpecified)
           , (hvKvmSpicePasswordFile,            PyValueEx "")
-- 
1.7.10.4

Reply via email to