From: Chris Lalancette <clalance@redhat.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 4/4]: python blkdev_name_to_number fixes
Date: Mon, 23 Jun 2008 20:27:12 +0200 [thread overview]
Message-ID: <485FEB00.8050307@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 653 bytes --]
This patch reworks blkdev_name_to_number to allow the tools to attach xvd disks
beyond xvdp. Once this patch is applied, the whole system should work together
and allow disks xvdq onwards. The patch does 2 things:
1. Adds the handling for the /dev/xvd[q-z] and /dev/xvd[a-i][a-z] extended devices
2. Changes blkdev_name_to_number() to return a tuple of (xenbus, devnum), and
then deals with the resulting fallout.
I freely admit that the change to tools/python/xen/xm/main.py is horrible, but
my python is not very good. If someone can suggest a better way to do it, I
would appreciate it.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
[-- Attachment #2: xen-unstable-greater-16-vbd-tools-python.patch --]
[-- Type: text/x-patch, Size: 5023 bytes --]
diff -r dedfadeadf86 tools/python/xen/util/blkif.py
--- a/tools/python/xen/util/blkif.py Fri Jun 20 18:42:45 2008 +0100
+++ b/tools/python/xen/util/blkif.py Mon Jun 23 17:47:49 2008 +0200
@@ -16,6 +16,9 @@ def blkdev_name_to_number(name):
n = expand_dev_name(name)
+ devname = 'virtual-device'
+ devnum = None
+
try:
return os.stat(n).st_rdev
except Exception, ex:
@@ -25,28 +28,30 @@ def blkdev_name_to_number(name):
if re.match( '/dev/sd[a-z]([1-9]|1[0-5])?$', n):
major = scsi_major[(ord(n[7:8]) - ord('a')) / 16]
minor = ((ord(n[7:8]) - ord('a')) % 16) * 16 + int(n[8:] or 0)
- return major * 256 + minor
- if re.match( '/dev/sd[a-i][a-z]([1-9]|1[0-5])?$', n):
+ devnum = major * 256 + minor
+ elif re.match( '/dev/sd[a-i][a-z]([1-9]|1[0-5])?$', n):
major = scsi_major[((ord(n[7:8]) - ord('a') + 1) * 26 + (ord(n[8:9]) - ord('a'))) / 16 ]
minor = (((ord(n[7:8]) - ord('a') + 1 ) * 26 + (ord(n[8:9]) - ord('a'))) % 16) * 16 + int(n[9:] or 0)
- return major * 256 + minor
-
- if re.match( '/dev/hd[a-t]([1-9]|[1-5][0-9]|6[0-3])?', n):
+ devnum = major * 256 + minor
+ elif 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
+ devnum = major * 256 + minor
+ elif re.match( '/dev/xvd[a-p]([1-9]|1[0-5])?$', n):
+ devnum = (202 << 8) + ((ord(n[8:9]) - ord('a')) << 4) + int(n[9:] or 0)
+ elif re.match('/dev/xvd[q-z]([1-9]|1[0-5])?$', n):
+ devname = 'virtual-device-ext'
+ devnum = (1 << 28) + ((ord(n[8:9]) - ord('a')) << 8) + int(n[9:] or 0)
+ elif re.match('/dev/xvd[a-i][a-z]([1-9]|1[0-5])?$', n):
+ devname = 'virtual-device-ext'
+ devnum = (1 << 28) + (((ord(n[8:9]) - ord('a') + 1) * 26 + (ord(n[9:10]) - ord('a'))) << 8) + int(n[10:] or 0)
+ elif re.match( '^(0x)[0-9a-fA-F]+$', name ):
+ devnum = string.atoi(name,16)
+ elif re.match('^[0-9]+$', name):
+ devnum = string.atoi(name, 10)
- 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)
-
- 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
+ return (devname, devnum)
def blkdev_segment(name):
"""Take the given block-device name (e.g. '/dev/sda1', 'hda')
diff -r dedfadeadf86 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Fri Jun 20 18:42:45 2008 +0100
+++ b/tools/python/xen/xend/XendConfig.py Mon Jun 23 17:47:49 2008 +0200
@@ -1123,7 +1123,7 @@ class XendConfig(dict):
try:
devid = int(dev2)
except ValueError:
- devid = blkdev_name_to_number(dev2)
+ (device_path, devid) = blkdev_name_to_number(dev2)
if devid == None:
log.debug("The device %s is not device name", dev2)
return None
diff -r dedfadeadf86 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py Fri Jun 20 18:42:45 2008 +0100
+++ b/tools/python/xen/xend/server/blkif.py Mon Jun 23 17:47:49 2008 +0200
@@ -81,11 +81,11 @@ class BlkifController(DevController):
if security.on() == xsconstants.XS_POLICY_ACM:
self.do_access_control(config, uname)
- devid = blkif.blkdev_name_to_number(dev)
+ (device_path, devid) = blkif.blkdev_name_to_number(dev)
if devid is None:
raise VmError('Unable to find number for device (%s)' % (dev))
- front = { 'virtual-device' : "%i" % devid,
+ front = { device_path : "%i" % devid,
'device-type' : dev_type
}
@@ -204,5 +204,5 @@ class BlkifController(DevController):
dev = devid.split('/')[-1]
dev = int(dev)
except ValueError:
- dev = blkif.blkdev_name_to_number(dev)
+ (device_path, dev) = blkif.blkdev_name_to_number(dev)
return dev
diff -r dedfadeadf86 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Fri Jun 20 18:42:45 2008 +0100
+++ b/tools/python/xen/xm/main.py Mon Jun 23 17:47:49 2008 +0200
@@ -2022,8 +2022,11 @@ def xm_block_list(args):
map(server.xenapi.VBD.get_runtime_properties, vbd_refs)
vbd_devs = \
map(server.xenapi.VBD.get_device, vbd_refs)
- vbd_devids = \
+ tmp_devids = \
map(blkdev_name_to_number, vbd_devs)
+ vbd_devids = []
+ for dev in tmp_devids:
+ vbd_devids.append(dev[1])
devs = map(lambda (devid, prop): [devid, map2sxp(prop)],
zip(vbd_devids, vbd_properties))
else:
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2008-06-23 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-23 18:27 Chris Lalancette [this message]
2008-06-23 18:40 ` [PATCH 4/4]: python blkdev_name_to_number fixes Brendan Cully
2008-06-24 7:39 ` Chris Lalancette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=485FEB00.8050307@redhat.com \
--to=clalance@redhat.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.