[virt-tools-list] [virt-manager PATCH 5/7] addhardware: Correctly calculate virtio-scsi controller index

Lin Ma lma at suse.com
Mon Nov 6 12:52:07 UTC 2017


Because sata, usb and scsi use same device prefix: sd*, They will be
included into occupied list while we add virtio-scsi disks, This is
wrong and may cause adding additional virtio-scsi controller.

How to reproduce:
1. fresh install a qemu guest.
2. add 6 virtual USB disks.
3. add disk A on scsi bus.
   (then a virtio-scsi controller 0 will be added automatically)
4. add disk B on scsi bus.
5. observe.

Expected:
disk A and disk B  should be connected to virtio-scsi controller 0 because
controller 0 has enough available slots.

Actual:
disk A was connected to virtio-scsi controller 0.
An additional virtio-scsi controller 1 was added and disk B was connected
to it because virt-manager thought the virtio-scsi controller 0 doesn't
have available slot.

Signed-off-by: Lin Ma <lma at suse.com>
---
 virtManager/addhardware.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index c6402e0d..d661602d 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1457,7 +1457,8 @@ class vmmAddHardware(vmmGObjectUI):
         # Save occupied places per controller
         occupied = collections.defaultdict(int)
         for d in used_disks:
-            if d.get_target_prefix() == disk.get_target_prefix():
+            if (d.get_target_prefix() == disk.get_target_prefix() and
+                d.bus == "scsi"):
                 num = virtinst.VirtualDisk.target_to_num(d.target)
                 occupied[num / 7] += 1
         for c in ctrls_scsi:
-- 
2.14.0




More information about the virt-tools-list mailing list