[virt-tools-list] [virt-manager PATCH] Fix generate_target once more
Cole Robinson
crobinso at redhat.com
Mon Feb 17 16:49:04 UTC 2014
On 02/17/2014 10:46 AM, Martin Kletzander wrote:
> 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 at redhat.com>
> ---
> tests/xmlconfig.py | 3 ++-
> virtinst/devicedisk.py | 10 +++++-----
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py
> index 9db51cb..5d08ca0 100644
> --- a/tests/xmlconfig.py
> +++ b/tests/xmlconfig.py
> @@ -1045,7 +1045,8 @@ class TestXMLConfig(unittest.TestCase):
> self.assertEquals("hdc", disk.generate_target(["hdb", "sda"]))
> 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))
>
> def testFedoraTreeinfo(self):
> diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
> index 28c55ba..6e7c6c8 100644
> --- a/virtinst/devicedisk.py
> +++ b/virtinst/devicedisk.py
> @@ -925,14 +925,14 @@ class VirtualDisk(VirtualDevice):
> def get_target():
> first_found = None
>
> - ran = range(1, maxnode + 1)
> - if pref_ctrl:
> + ran = range(maxnode)
> + if pref_ctrl is not None:
> # 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)
>
> 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:
> skip_targets.remove(gen_t)
> continue
> @@ -948,7 +948,7 @@ class VirtualDisk(VirtualDevice):
> self.target = ret
> return ret
>
> - if pref_ctrl:
> + if pref_ctrl is not None:
> # This basically means that we either chose full
> # controller or didn't add any
> raise ValueError(_("Controller number %d for disk of type %s has "
>
ACK
- Cole
More information about the virt-tools-list
mailing list