Subject: addhardware: Fix virtio-scsi controller target calculation From: Cole Robinson crobinso@redhat.com Wed Nov 22 14:58:12 2017 -0500 Date: Wed Nov 22 16:50:33 2017 -0500: Git: 7fc7e94f211676b9a958662cb93edf770f23273c More details here: https://www.redhat.com/archives/virt-tools-list/2017-November/msg00014.html Reported-by: Lin Ma diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index cd82cd3..4a962e6 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -20,7 +20,6 @@ import logging import traceback -import collections from gi.repository import Gtk from gi.repository import Gdk @@ -1455,13 +1454,18 @@ class vmmAddHardware(vmmGObjectUI): if x.model == controller_model] # Save occupied places per controller - occupied = collections.defaultdict(int) + occupied = {} for d in used_disks: if d.get_target_prefix() == disk.get_target_prefix(): num = virtinst.VirtualDisk.target_to_num(d.target) - occupied[num / 7] += 1 + idx = num // 7 + if idx not in occupied: + occupied[idx] = [] + if d.target not in occupied[idx]: + occupied[idx].append(d.target) + for c in ctrls_scsi: - if occupied[c.index] < 7: + if c.index not in occupied or len(occupied[c.index]) < 7: controller = c break else: