Skip to contentSkip to conversation

xen: xm/blkif ide dev-numbers

PATCH In review Jody Belka 1 participant 1 message Jan 31, 2005

lore
Share & tools
lore

Jody Belka

author
#0 lore raw

PATCH 2/5 xen: xm/blkif ide dev-numbers

Fix the device number calculation for /dev/hd* device names; ide device numbering works differently to scsi

diffstat:

 blkif.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
tools/python/xen/xend/server/blkif.py +5 -2
diff -durN xen.orig/tools/python/xen/xend/server/blkif.py xen/tools/python/xen/xend/server/blkif.py
@@ -66,8 +66,11 @@
     if re.match( '/dev/sd[a-p]([0-9]|1[0-5])', n):
         return 8 * 256 + 16 * (ord(n[7:8]) - ord('a')) + int(n[8:])
 
-    if re.match( '/dev/hd[a-p]([0-9]|[1-5][0-9]|6[0-3])', n):
-        return 3 * 256 + 16 * (ord(n[7:8]) - ord('a')) + int(n[8:])        
+    if re.match( '/dev/hd[a-t]([1-9]|[1-5][0-9]|6[0-3])?', n):
+        ide_majors = [ 3, 22, 33, 34, 56, 57, 88, 89, 90, 91 ]
+        major = ide_majors[(ord(n[7:8]) - ord('a')) / 2]
+        minor = ((ord(n[7:8]) - ord('a')) % 2) * 64 + int(n[8:] or 0)
+        return major * 256 + minor
 
     # see if this is a hex device number
     if re.match( '^(0x)?[0-9a-fA-F]+$', name ):

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl