virt-manager/530987c4-disk-bus-calculation-fix.patch
Charles Arnold 674941bbf7 - Upstream bug fixes
53022930-lxc-connection-fix.patch
  530229cb-non-x86-kvm-creation-fix.patch
  53023f56-dont-alter-caps-machine-list-on-create.patch
  53030858-generate_target-fix.patch
  53037798-not-customizing-generate_target-fix.patch
  53047532-dont-get-duplicated-disks.patch
  53047595-calculate-disk-bus-properly.patch
  530987c4-disk-bus-calculation-fix.patch
  530c021c-attempt-empty-path-on-virDomainBlockStats.patch
  530cd6ab-log-broken-xml.patch
  530cf4de-allow-numbered-object-names.patch
  530cfa5e-close-connection-on-tick-failure-fix.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=146
2014-02-28 14:58:33 +00:00

64 lines
2.7 KiB
Diff

Subject: virtinst: fix an issue of disk bus caculation
From: Chen Hanxiao chenhanxiao@cn.fujitsu.com Sun Feb 23 13:31:48 2014 +0800
Date: Sun Feb 23 13:31:48 2014 +0800:
Git: 0dceb24b3ba567aad3976fe3c6af524db9e1ac6d
commit 466c2bcf9cb07f16690cb41684d67d0265d2d47e
will generate the same index for
'hda' and 'hdaa'.
Also break test cases.
This patch will fix this.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py
index 5d08ca0..022d278 100644
--- a/tests/xmlconfig.py
+++ b/tests/xmlconfig.py
@@ -1027,15 +1027,15 @@ class TestXMLConfig(unittest.TestCase):
self.assertEquals("zz", VirtualDisk.num_to_target(27 * 26))
self.assertEquals("aaa", VirtualDisk.num_to_target(27 * 26 + 1))
- self.assertEquals(VirtualDisk.target_to_num("hda"), 1)
- self.assertEquals(VirtualDisk.target_to_num("hdb"), 2)
- self.assertEquals(VirtualDisk.target_to_num("sdz"), 26)
- self.assertEquals(VirtualDisk.target_to_num("sdaa"), 27)
- self.assertEquals(VirtualDisk.target_to_num("vdab"), 28)
- self.assertEquals(VirtualDisk.target_to_num("vdaz"), 52)
- self.assertEquals(VirtualDisk.target_to_num("xvdba"), 53)
- self.assertEquals(VirtualDisk.target_to_num("xvdzz"), 27 * 26)
- self.assertEquals(VirtualDisk.target_to_num("xvdaaa"), 27 * 26 + 1)
+ self.assertEquals(VirtualDisk.target_to_num("hda"), 0)
+ self.assertEquals(VirtualDisk.target_to_num("hdb"), 1)
+ self.assertEquals(VirtualDisk.target_to_num("sdz"), 25)
+ self.assertEquals(VirtualDisk.target_to_num("sdaa"), 26)
+ self.assertEquals(VirtualDisk.target_to_num("vdab"), 27)
+ self.assertEquals(VirtualDisk.target_to_num("vdaz"), 51)
+ self.assertEquals(VirtualDisk.target_to_num("xvdba"), 52)
+ self.assertEquals(VirtualDisk.target_to_num("xvdzz"), 26 * (25 + 1) + 25)
+ self.assertEquals(VirtualDisk.target_to_num("xvdaaa"), 26 * 26 * 1 + 26 * 1 + 0)
disk = virtinst.VirtualDisk(utils.get_conn())
disk.bus = "ide"
diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
index 9ebcc11..2d692f1 100644
--- a/virtinst/devicedisk.py
+++ b/virtinst/devicedisk.py
@@ -480,11 +480,14 @@ class VirtualDisk(VirtualDevice):
Convert disk /dev number (like hda, hdb, hdaa, etc.) to an index
"""
num = 0
+ k = 0
if tgt[0] == 'x':
# This case is here for 'xvda'
tgt = tgt[1:]
for i, c in enumerate(reversed(tgt[2:])):
- num += (ord(c) - ord('a')) * (26 ** i)
+ if i != 0:
+ k = 1
+ num += (ord(c) - ord('a') + k) * (26 ** i)
return num