WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Accept decimal block device IDs

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Accept decimal block device IDs
From: john.levon@xxxxxxx
Date: Wed, 30 Apr 2008 05:56:16 -0700
Delivery-date: Thu, 01 May 2008 08:24:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User john.levon@xxxxxxx
# Date 1209521787 25200
# Node ID bad3329d556871d37e7c9bdcb0c55a98e7fc0a54
# Parent  e3048cb9a00e0ed9c007cd9e4360cb1283005407
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@xxxxxxx>

diff --git a/tools/python/xen/util/blkif.py b/tools/python/xen/util/blkif.py
--- 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):

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Accept decimal block device IDs, john . levon <=