Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 4850a02

Browse files
committed
VirtualDisk: Generate usable target for dev > 27
1 parent 377522f commit 4850a02

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

tests/xmlconfig.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,5 +962,18 @@ def testCpustrToTuple(self):
962962
virtinst.Guest.cpuset_str_to_tuple,
963963
conn, "16")
964964

965+
def testManyVirtio(self):
966+
d = VirtualDisk(conn=utils.get_conn(), bus="virtio",
967+
path="/default-pool/testvol1.img")
968+
969+
targetlist = []
970+
for ignore in range(0, (26 * 2) + 1):
971+
d.target = None
972+
d.generate_target(targetlist)
973+
targetlist.append(d.target)
974+
975+
self.assertEquals("vdaa", targetlist[26])
976+
self.assertEquals("vdba", targetlist[26 * 2])
977+
965978
if __name__ == "__main__":
966979
unittest.main()

virtinst/VirtualDisk.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,34 @@ def generate_target(self, skip_targets):
17291729
self.target = "hdc"
17301730
return self.target
17311731

1732+
if maxnode > (26 * 26 * 26):
1733+
raise RuntimeError("maxnode value is too high")
1734+
17321735
# Regular scanning
1733-
for i in range(maxnode):
1734-
gen_t = "%s%c" % (prefix, ord('a') + i)
1736+
for i in range(1, maxnode + 1):
1737+
gen_t = prefix
1738+
1739+
tmp = i
1740+
digits = []
1741+
for factor in range(0, 3):
1742+
amt = (tmp % (26 ** (factor + 1))) / (26 ** factor)
1743+
if amt == 0 and tmp >= (26 ** (factor + 1)):
1744+
amt = 26
1745+
tmp -= amt
1746+
digits.insert(0, amt)
1747+
1748+
seen_valid = False
1749+
for digit in digits:
1750+
if digit == 0:
1751+
if not seen_valid:
1752+
continue
1753+
digit = 1
1754+
1755+
seen_valid = True
1756+
gen_t += "%c" % (ord('a') + digit - 1)
1757+
1758+
#print i, digits, gen_t
1759+
17351760
if gen_t in except_targets:
17361761
continue
17371762
if gen_t not in skip_targets:

0 commit comments

Comments
 (0)