From 2eb455c97f1afda33a4b1c87adb2721fac9d9b5f Mon Sep 17 00:00:00 2001 From: Lin Ma Date: Mon, 6 Nov 2017 20:52:07 +0800 Subject: [PATCH] addhardware: Correctly calculate virtio-scsi controller index 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 --- virtManager/addhardware.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 4a962e6f..e563fe62 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -1456,7 +1456,8 @@ class vmmAddHardware(vmmGObjectUI): # Save occupied places per controller occupied = {} 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) idx = num // 7 if idx not in occupied: