Jan Beulich
2010-Nov-18 16:41 UTC
[Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices
Simply taking stat()''s st_rdev doesn''t work here, as the minor is split into two parts, the major is present, and the "extended" bit isn''t set. Not sure whether non-Linux needs different decoding here. Signed-off-by: Jan Beulich <jbeulich@novell.com> --- a/tools/python/xen/util/blkif.py +++ b/tools/python/xen/util/blkif.py @@ -20,7 +20,11 @@ def blkdev_name_to_number(name): devnum = None try: - return (devname, os.stat(n).st_rdev) + rdev = os.stat(n).st_rdev + if rdev > 0xffff and (rdev & 0xff00) == (202 << 8): + devnum = (1 << 28) + ((rdev >> 12) & ~0xff) + (rdev & 0xff) + return (devname, devnum) + return (devname, rdev) except Exception, ex: pass _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Nov-19 17:56 UTC
Re: [Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices
Jan Beulich writes ("[Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices"):> Simply taking stat()''s st_rdev doesn''t work here, as the minor is > split into two parts, the major is present, and the "extended" bit > isn''t set....> @@ -20,7 +20,11 @@ def blkdev_name_to_number(name): > - return (devname, os.stat(n).st_rdev)This seems to me to be entirely wrong. When you block detach you should be providing the device name according to the Xen guest device naming scheme, not a local device path (which may have different major and minor numbers). If you just remove the try/except block and always use the following code, does it work correctly ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2010-Nov-22 08:29 UTC
Re: [Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices
>>> On 19.11.10 at 18:56, Ian Jackson <Ian.Jackson@eu.citrix.com> wrote: > Jan Beulich writes ("[Xen-devel] [PATCH] fix "xm block-detach 0 ..." for > extended-ID devices"): >> Simply taking stat()''s st_rdev doesn''t work here, as the minor is >> split into two parts, the major is present, and the "extended" bit >> isn''t set. > ... >> @@ -20,7 +20,11 @@ def blkdev_name_to_number(name): >> - return (devname, os.stat(n).st_rdev) > > This seems to me to be entirely wrong. When you block detach you > should be providing the device name according to the Xen guest device > naming scheme, not a local device path (which may have different major > and minor numbers). > > If you just remove the try/except block and always use the following > code, does it work correctly ?Yes. Since the code is there presumably for a reason, I didn''t dare to suggest removing it altogether. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Nov-22 16:05 UTC
Re: [Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices
Jan Beulich writes ("Re: [Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices"):> On 19.11.10 at 18:56, Ian Jackson <Ian.Jackson@eu.citrix.com> wrote: > > If you just remove the try/except block and always use the following > > code, does it work correctly ? > > Yes.Good. Let''s do that then :-). Would you care to submit it as a patch and I''ll put my acked-by on it ?> Since the code is there presumably for a reason, I didn''t dare > to suggest removing it altogether.Historically, there has been a different (not to say ENTIRELY WRONGHEADED) idea of what the vbd device numbers are supposed to mean. [lib]xl doesn''t ever stat devices in the dom0 filesystem for this purpose. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel