mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Fix generate_target once more
Passing a zero to the generate_target() function's as pref_ctrl parameter makes the 'if pref_ctrl' conditions obviously false. Also the range created was starting from 0 and not from 1. Apart from fixing this, also fix tests so they actually test something this time. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
7c516b382c
commit
55d5b35e50
@ -1045,7 +1045,8 @@ class TestXMLConfig(unittest.TestCase):
|
|||||||
self.assertEquals("hdc", disk.generate_target(["hdb", "sda"]))
|
self.assertEquals("hdc", disk.generate_target(["hdb", "sda"]))
|
||||||
self.assertEquals("hdb", disk.generate_target(["hda", "hdd"]))
|
self.assertEquals("hdb", disk.generate_target(["hda", "hdd"]))
|
||||||
|
|
||||||
disk.bus = "scsi"
|
disk.bus = "virtio-scsi"
|
||||||
|
self.assertEquals("sdb", disk.generate_target(["sda", "sdg", "sdi"], 0))
|
||||||
self.assertEquals("sdh", disk.generate_target(["sda", "sdg"], 1))
|
self.assertEquals("sdh", disk.generate_target(["sda", "sdg"], 1))
|
||||||
|
|
||||||
def testFedoraTreeinfo(self):
|
def testFedoraTreeinfo(self):
|
||||||
|
@ -925,14 +925,14 @@ class VirtualDisk(VirtualDevice):
|
|||||||
def get_target():
|
def get_target():
|
||||||
first_found = None
|
first_found = None
|
||||||
|
|
||||||
ran = range(1, maxnode + 1)
|
ran = range(maxnode)
|
||||||
if pref_ctrl:
|
if pref_ctrl is not None:
|
||||||
# We assume narrow SCSI bus and libvirt assigning 7
|
# We assume narrow SCSI bus and libvirt assigning 7
|
||||||
# (0-6, 7-13, etc.) devices per controller
|
# (1-7, 8-14, etc.) devices per controller
|
||||||
ran = range(pref_ctrl * 7, (pref_ctrl + 1) * 7)
|
ran = range(pref_ctrl * 7, (pref_ctrl + 1) * 7)
|
||||||
|
|
||||||
for i in ran:
|
for i in ran:
|
||||||
gen_t = prefix + self.num_to_target(i)
|
gen_t = prefix + self.num_to_target(i + 1)
|
||||||
if gen_t in skip_targets:
|
if gen_t in skip_targets:
|
||||||
skip_targets.remove(gen_t)
|
skip_targets.remove(gen_t)
|
||||||
continue
|
continue
|
||||||
@ -948,7 +948,7 @@ class VirtualDisk(VirtualDevice):
|
|||||||
self.target = ret
|
self.target = ret
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
if pref_ctrl:
|
if pref_ctrl is not None:
|
||||||
# This basically means that we either chose full
|
# This basically means that we either chose full
|
||||||
# controller or didn't add any
|
# controller or didn't add any
|
||||||
raise ValueError(_("Controller number %d for disk of type %s has "
|
raise ValueError(_("Controller number %d for disk of type %s has "
|
||||||
|
Loading…
Reference in New Issue
Block a user