Accept decimal block device IDs

Solaris uses a simple indexing scheme for block devices. Parts of xend
translate them as hexadecimal (such as block-attach), and decimal, or
unconverted, elsewhere (such as block-detach). Harmonise these
interfaces by allowing decimal specifications.

Also allow Solaris-style block device names.

Signed-off-by: John Levon <john.levon@sun.com>
This commit is contained in:
Keir Fraser committed 2008-05-01 16:35:28 +01:00
1 parent 1d45c8ef8c
commit 84736d7607
1 file changed
+5 -3
+5 -3
View File
@@ -42,10 +42,12 @@ def blkdev_name_to_number(name):
if re.match( '/dev/xvd[a-p]([1-9]|1[0-5])?', n):
return 202 * 256 + 16 * (ord(n[8:9]) - ord('a')) + int(n[9:] or 0)
# see if this is a hex device number
if re.match( '^(0x)?[0-9a-fA-F]+$', name ):
if re.match( '^(0x)[0-9a-fA-F]+$', name ):
return string.atoi(name,16)
if re.match('^[0-9]+$', name):
return string.atoi(name, 10)
return None
def blkdev_segment(name):
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.