Skip to contentSkip to conversation

fix "xm block-detach 0 ..." for extended-ID devices

PATCH Superseded Jan Beulich 2 participants 4 messages Nov 18, 2010 – Nov 22, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

tools/python/xen/util/blkif.py +5 -1
@@ -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
 

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.

tools/python/xen/util/blkif.py +5 -1
@@ -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
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Jan Beulich writes ("[Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices"):

Quoted 3 lines

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.

...

Review def blkdev_name_to_number(name): · line 20

Quoted 2 lines
(quoted diff) +0 -1
@@ -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.

#2 lore raw
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Ian Jackson

Jan Beulich writes ("[Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices"):

Quoted 3 lines

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.

...

Review def blkdev_name_to_number(name): · line 20

Quoted 2 lines
(quoted diff) +0 -1
@@ -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).

Quoted 2 lines

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

#3 lore raw

Jan Beulich writes ("Re: [Xen-devel] [PATCH] fix "xm block-detach 0 ..." for extended-ID devices"):

Quoted 5 lines · Ian Jackson
Quoted 2 lines

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 ?

Quoted 2 lines

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.