[PATCH 2/3] qemu: Clean up qemuDomainDefaultSCSIControllerModel()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use a better order for sections, improve comments, tweak
formatting.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c408fb8c88..a6c0b581b2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4233,8 +4233,9 @@ qemuDomainDefAddDefaultAudioBackend(virQEMUDriver *driver,
 
 
 /**
- * @def: Domain definition
- * @qemuCaps: qemu capabilities
+ * qemuDomainDefaultSCSIControllerModel:
+ * @def: domain definition
+ * @qemuCaps: QEMU capabilities, or NULL
  *
  * Choose a reasonable model to use for a SCSI controller where a
  * specific one hasn't been provided by the user.
@@ -4255,16 +4256,27 @@ virDomainControllerModelSCSI
 qemuDomainDefaultSCSIControllerModel(const virDomainDef *def,
                                      virQEMUCaps *qemuCaps)
 {
+    /* For machine types with built-in SCSI controllers, the choice
+     * of model is obvious */
+    if (qemuDomainHasBuiltinESP(def))
+        return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90;
+
+    /* Most new architectures should ideally use virtio */
+    if (ARCH_IS_S390(def->os.arch) ||
+        qemuDomainIsLoongArchVirt(def))
+        return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
+
+    /* pSeries has its own special default */
     if (qemuDomainIsPSeries(def))
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
-    if (ARCH_IS_S390(def->os.arch) || qemuDomainIsLoongArchVirt(def))
-        return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
+
+    /* If there is no preference, base the choice on device
+     * availability. In this case, lsilogic is favored over
+     * virtio-scsi for backwards compatibility reasons */
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI))
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI))
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
-    if (qemuDomainHasBuiltinESP(def))
-        return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90;
 
     return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT;
 }
-- 
2.50.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux