[PATCH 2/2] conf: Accept model=virtio for SCSI controllers

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

 



At the moment, all VirtIO devices support model=virtio except
for SCSI controllers where model=virtio-scsi must be used
instead: get rid of this inconsistency by providing an alias
at the parser level, so that existing code keeps working but
using the same values across the board is also optionally
possible.

Tweak one of the test cases to show that the new value is
accepted transparently, without altering any of the output
files in the process.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 docs/schemas/domaincommon.rng                    |  1 +
 src/conf/domain_conf.c                           | 16 ++++++++++------
 .../qemuxml2argvdata/controller-virtio-scsi.xml  |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 80f9f84f70..8981eda4b7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2156,6 +2156,7 @@
                   <value>ibmvscsi</value>
                   <value>virtio-scsi</value>
                   <value>lsisas1078</value>
+                  <value>virtio</value>
                   <value>virtio-transitional</value>
                   <value>virtio-non-transitional</value>
                 </choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0c0e422889..cde10598f9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10320,16 +10320,20 @@ static int
 virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
                                        const char *model)
 {
-    if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
-        return virDomainControllerModelSCSITypeFromString(model);
-    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
+    if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
+        if (STREQ_NULLABLE(model, "virtio"))
+            return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO;
+        else
+            return virDomainControllerModelSCSITypeFromString(model);
+    } else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
         return virDomainControllerModelUSBTypeFromString(model);
-    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+    } else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
         return virDomainControllerModelPCITypeFromString(model);
-    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
+    } else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
         return virDomainControllerModelIDETypeFromString(model);
-    else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+    } else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) {
         return virDomainControllerModelVirtioSerialTypeFromString(model);
+    }
 
     return -1;
 }
diff --git a/tests/qemuxml2argvdata/controller-virtio-scsi.xml b/tests/qemuxml2argvdata/controller-virtio-scsi.xml
index 844e4ad397..861121821c 100644
--- a/tests/qemuxml2argvdata/controller-virtio-scsi.xml
+++ b/tests/qemuxml2argvdata/controller-virtio-scsi.xml
@@ -47,7 +47,7 @@
     <controller type='scsi' index='2' model='virtio-scsi'>
       <driver cmd_per_lun='50'/>
     </controller>
-    <controller type='scsi' index='3' model='virtio-scsi'>
+    <controller type='scsi' index='3' model='virtio'>
       <driver max_sectors='512'/>
     </controller>
     <controller type='scsi' index='4' model='virtio-scsi'>
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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