]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Enable loopback disk image files on readonly nfs filesystem.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 24 Jan 2008 14:57:57 +0000 (14:57 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 24 Jan 2008 14:57:57 +0000 (14:57 +0000)
When we losetup a file on readonly nfs filesystem, it fails with:
# losetup /dev/loop7 /data/vm/xen_el5_i386_para/system.raw
/data/vm/xen_el5_i386_para/system.raw: Permission denied

New version of losetup has add a "-r" option for readonly loop, which
Linux kernel has supported for a long time. Some distribution (EL5
update, Fedora 8, etc.) have shipped it. This patch benefit this
option while doesn't break the old versions of losetup.

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
xen-unstable changeset:   16330:fbe7ed173314723f80f105e7e60fddd0bed77e5b
xen-unstable date:        Wed Nov 07 09:22:31 2007 +0000

tools/examples/block

index 2b6b9911254a76864bc57ac1e861c9b77491d8c7..a058f5c3081c4c58531fbf8b3b647548e9eb5a7e 100644 (file)
@@ -367,7 +367,10 @@ mount it read-write in a guest domain."
           fatal 'Failed to find an unused loop device'
         fi
 
-        do_or_die losetup "$loopdev" "$file"
+        status=$(losetup "$loopdev" "$file" || echo "failed")
+        if [ -n "$status" ]; then
+          do_or_die losetup -r "$loopdev" "$file"
+        fi
         xenstore_write "$XENBUS_PATH/node" "$loopdev"
         write_dev "$loopdev"
         release_lock "block"