[virt-tools-list] [virt-manager PATCH 2/2] scsi-storage: unify SCSI storage code and logic

Pavel Hrdina phrdina at redhat.com
Mon Aug 3 16:52:07 UTC 2015


There is no virtio-scsi or spapr-vscsi bus, but only 'scsi' bus.  There
are several types of SCSI controllers, but the SCSI storage don't care
about the SCSI controller and there is also no difference in address
specification or address type.  Use only 'scsi' bus for all SCSI storages
to correspond the reality and also the libvirt domain XML.  The only
difference is in the type of SCSI controller

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 virtManager/addhardware.py | 15 +++++++--------
 virtManager/details.py     | 36 ++++++------------------------------
 virtinst/devicedisk.py     |  2 --
 3 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 088085e..094ac95 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -723,9 +723,8 @@ class vmmAddHardware(vmmGObjectUI):
         if vm.get_hv_type() in ["qemu", "kvm", "test"]:
             rows.append(["sd", "SD"])
             rows.append(["virtio", "VirtIO"])
-            rows.append(["virtio-scsi", "VirtIO SCSI"])
-            if vm.xmlobj.os.is_pseries():
-                rows.append(["spapr-vscsi", "sPAPR-vSCSI"])
+            if not rows.count(["scsi", "SCSI"]):
+                rows.append(["scsi", "SCSI"])
 
         if vm.conn.is_xen() or vm.conn.is_test_conn():
             rows.append(["xen", "Xen"])
@@ -733,11 +732,10 @@ class vmmAddHardware(vmmGObjectUI):
         model.clear()
 
         bus_map = {
-            "disk": ["ide", "sata", "scsi", "sd", "spapr-vscsi",
-                     "usb", "virtio", "virtio-scsi", "xen"],
+            "disk": ["ide", "sata", "scsi", "sd", "usb", "virtio", "xen"],
             "floppy": ["fdc"],
             "cdrom": ["ide", "sata", "scsi"],
-            "lun": ["virtio-scsi"],
+            "lun": ["scsi"],
         }
         for row in rows:
             if row[0] in bus_map[devtype]:
@@ -1526,8 +1524,9 @@ class vmmAddHardware(vmmGObjectUI):
         fmt = uiutil.get_list_selection(self.widget("config-storage-format"))
 
         controller_model = None
-        if bus == "virtio-scsi":
-            bus = "scsi"
+        if (bus == "scsi" and
+            self.vm.get_hv_type() in ["qemu", "kvm", "test"] and
+            not self.vm.xmlobj.os.is_pseries()):
             controller_model = "virtio-scsi"
 
         collidelist = [d.path for d in self.vm.get_disk_devices()]
diff --git a/virtManager/details.py b/virtManager/details.py
index 6ab1bad..360cd43 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -163,28 +163,11 @@ remove_pages = [HW_LIST_TYPE_NIC, HW_LIST_TYPE_INPUT,
 _remove_tooltip = _("Remove this device from the virtual machine")
 
 
-def _label_for_device(dev, vm):
+def _label_for_device(dev):
     devtype = dev.virtual_device_type
 
     if devtype == "disk":
-        def _find_matching_disk_controller():
-            for controller in vm.get_controller_devices():
-                if (dev.address.controller is not None and
-                    controller.type == dev.bus and
-                    controller.index == dev.address.controller):
-                    return controller
-
-        bus = dev.bus
-        if dev.address.type == "spapr-vio":
-            bus = "spapr-vscsi"
-
-        busstr = virtinst.VirtualDisk.pretty_disk_bus(bus) or ""
-
-        if bus == "scsi":
-            matching_controller = _find_matching_disk_controller()
-            if (matching_controller and
-                matching_controller.model == "virtio-scsi"):
-                busstr = "Virtio SCSI"
+        busstr = virtinst.VirtualDisk.pretty_disk_bus(dev.bus) or ""
 
         if dev.device == "floppy":
             devstr = "Floppy"
@@ -2196,9 +2179,6 @@ class vmmDetails(vmmGObjectUI):
         if self.edited(EDIT_DISK_BUS):
             bus = uiutil.get_list_selection(self.widget("disk-bus"))
             addr = None
-            if bus == "spapr-vscsi":
-                bus = "scsi"
-                addr = "spapr-vio"
 
             kwargs["bus"] = bus
             kwargs["addrstr"] = addr
@@ -2678,7 +2658,6 @@ class vmmDetails(vmmGObjectUI):
         share = disk.shareable
         bus = disk.bus
         removable = disk.removable
-        addr = disk.address.type
         cache = disk.driver_cache
         io = disk.driver_io
         driver_type = disk.driver_type or ""
@@ -2728,10 +2707,7 @@ class vmmDetails(vmmGObjectUI):
         else:
             can_set_removable = True
 
-        if addr == "spapr-vio":
-            bus = "spapr-vscsi"
-
-        pretty_name = _label_for_device(disk, self.vm)
+        pretty_name = _label_for_device(disk)
 
         self.widget("disk-source-path").set_text(path or "-")
         self.widget("disk-target-type").set_text(pretty_name)
@@ -2855,7 +2831,7 @@ class vmmDetails(vmmGObjectUI):
         if rd.type == 'tcp':
             address = _("%s:%s") % (rd.host, rd.service)
 
-        self.widget("redir-title").set_markup(_label_for_device(rd, self.vm))
+        self.widget("redir-title").set_markup(_label_for_device(rd))
         self.widget("redir-type").set_text(rd.pretty_type(rd.type))
 
         self.widget("redir-address").set_text(address or "")
@@ -3238,7 +3214,7 @@ class vmmDetails(vmmGObjectUI):
             See if passed hw is already in list, and if so, update info.
             If not in list, add it!
             """
-            label = _label_for_device(dev, self.vm)
+            label = _label_for_device(dev)
             icon = _icon_for_device(dev)
 
             currentDevices.append(dev)
@@ -3323,7 +3299,7 @@ class vmmDetails(vmmGObjectUI):
         ret = []
         for dev in self.vm.get_bootable_devices():
             icon = _icon_for_device(dev)
-            label = _label_for_device(dev, self.vm)
+            label = _label_for_device(dev)
 
             ret.append([dev.vmmidstr, label, icon, False, True])
 
diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
index 679b0cd..95e4620 100644
--- a/virtinst/devicedisk.py
+++ b/virtinst/devicedisk.py
@@ -169,8 +169,6 @@ class VirtualDisk(VirtualDevice):
             return bus.capitalize()
         if bus == "virtio":
             return "VirtIO"
-        if bus == "spapr-vscsi":
-            return "vSCSI"
         return bus
 
     @staticmethod
-- 
2.4.6




More information about the virt-tools-list mailing list