From: Keir Fraser Date: Thu, 1 May 2008 15:35:28 +0000 (+0100) Subject: Accept decimal block device IDs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14215^2~90 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=84736d7607c9840cf58d8c094f28594d716515a7;p=xen.git 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 --- diff --git a/tools/python/xen/util/blkif.py b/tools/python/xen/util/blkif.py index 15d20dde8c..0fdd52f418 100644 --- a/tools/python/xen/util/blkif.py +++ b/tools/python/xen/util/blkif.py @@ -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):