Skip to contentSkip to conversation

Don't mount raw blktap disks for pygrub

PATCH RESEND In review Mark McLoughlin 2 participants 2 messages Mar 7, 2007

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Don't mount raw blktap disks for pygrub

(Doesn't seem to be in the staging tree; re-sending just in case it slipped through the cracks)

Hi,
Currently, we mount all blktap disks for pygrub so that it can boot
from e.g. QCOW images. However, since pygrub will handle a raw image just fine without mounting through blktap, we shouldn't bother in that case.

Also, it looks like XendDomainInfo.create_vbd() takes the full disk
uname rather than the image path.

Cheers,
Mark.

tools/python/xen/util/blkif.py +12 -5
diff -r 3ac19fda0bc2 tools/python/xen/util/blkif.py
@@ -66,16 +66,23 @@ def blkdev_segment(name):
                 'type'         : 'Disk' }
     return val
 
-def blkdev_uname_to_file(uname):
-    """Take a blkdev uname and return the corresponding filename."""
-    fn = None
+def _parse_uname(uname):
+    fn = taptype = None
     if uname.find(":") != -1:
         (typ, fn) = uname.split(":", 1)
         if typ == "phy" and not fn.startswith("/"):
             fn = "/dev/%s" %(fn,)
         if typ == "tap":
-            (typ, fn) = fn.split(":", 1)
-    return fn
+            (taptype, fn) = fn.split(":", 1)
+    return (fn, taptype)
+
+def blkdev_uname_to_file(uname):
+    """Take a blkdev uname and return the corresponding filename."""
+    return _parse_uname(uname)[0]
+
+def blkdev_uname_to_taptype(uname):
+    """Take a blkdev uname and return the blktap type."""
+    return _parse_uname(uname)[1]
 
 def mount_mode(name):
     mode = None
tools/python/xen/xend/XendDomainInfo.py +4 -3
diff -r 3ac19fda0bc2 tools/python/xen/xend/XendDomainInfo.py
@@ -34,7 +34,7 @@ from types import StringTypes
 
 import xen.lowlevel.xc
 from xen.util import asserts
-from xen.util.blkif import blkdev_uname_to_file
+from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
 from xen.util import security
 
 from xen.xend import balloon, sxp, uuid, image, arch, osdep
@@ -1768,7 +1768,8 @@ class XendDomainInfo:
             disk = devinfo[1]['uname']
 
             fn = blkdev_uname_to_file(disk)
-            mounted = devtype == 'tap' and not os.stat(fn).st_rdev
+            taptype = blkdev_uname_to_taptype(disk)
+            mounted = devtype == 'tap' and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev
             if mounted:
                 # This is a file, not a device.  pygrub can cope with a
                 # file if it's raw, but if it's QCOW or other such formats
@@ -1784,7 +1785,7 @@ class XendDomainInfo:
 
                 from xen.xend import XendDomain
                 dom0 = XendDomain.instance().privilegedDomain()
-                dom0._waitForDeviceUUID(dom0.create_vbd(vbd, fn))
+                dom0._waitForDeviceUUID(dom0.create_vbd(vbd, disk))
                 fn = BOOTLOADER_LOOPBACK_DEVICE
 
             try:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

What is the broken thing that you are trying to fix with this patch? The current code works fine and treats all tap-based devices equally, while this new code special-cases certain tap-based drivers (aio and sync).

a.

Quoted 24 lines · Mark McLoughlin

(Doesn't seem to be in the staging tree; re-sending just in case it slipped through the cracks)

Hi,
Currently, we mount all blktap disks for pygrub so that it can boot
from e.g. QCOW images. However, since pygrub will handle a raw image just fine without mounting through blktap, we shouldn't bother in that case.

Also, it looks like XendDomainInfo.create_vbd() takes the full disk
uname rather than the image path.

Cheers,
Mark.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel