All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: Fix for loop mounting of readonly images
Date: Fri, 2 Feb 2007 20:43:13 +0000	[thread overview]
Message-ID: <20070202204313.GG18218@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1698 bytes --]

We hit an wierd edge case when booting a fullyvirt guest VM off an ISO 
image stored on NFS, where the hotplug scripts would fail to map the
ISO to the backend. This only happened if the ISO image was marked readonly,
but on a read-write NFS mount. It worked fine on a readonly NFS mount!

After a little debugging appears that losetup was failing with:

# mount -orw nfs1:/some/path /mnt
# strace -e trace=open losetup /dev/loop0  /mnt/rhel4-i386-AS/images/boot.iso 2>&1 | grep boot.iso
open("/mnt/rhel4-i386-AS/images/boot.iso", O_RDWR) = -1 EACCES (Permission denied)
/mnt/rhel4-i386-AS/images/boot.iso: Permission denied

When the NFS mount is mounted read-only it works, because it falls back
to setting up a readonly loop device:

# mount -oro nfs1:/some/path /mnt
# strace -e trace=open losetup /dev/loop0  /mnt/rhel4-i386-AS/images/boot.iso 2>&1 | grep boot.iso
open("/mnt/rhel4-i386-AS/images/boot.iso", O_RDWR) = -1 EROFS (Read-only file system)
open("/mnt/rhel4-i386-AS/images/boot.iso", O_RDONLY) = 3

Which made me wonder - why don't we request a readonly loopdevice in the
first place, given that the ISO is being exported read-only to the guest.

So I'm ataching a patch to teh block hotplug scripts which will automatically
pass the '-r' option to losetup if the device sharing mode is 'r'

   Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-block-readonly.patch --]
[-- Type: text/plain, Size: 662 bytes --]

diff -r 2e80cd715047 tools/examples/block
--- a/tools/examples/block	Thu Feb 01 11:42:50 2007 +0000
+++ b/tools/examples/block	Thu Feb 01 11:58:38 2007 -0500
@@ -367,7 +367,13 @@ mount it read-write in a guest domain."
           fatal 'Failed to find an unused loop device'
         fi
 
-        do_or_die losetup "$loopdev" "$file"
+        cmode=`canonicalise_mode $mode`
+        if [ "$cmode" == 'r' ]
+        then
+          do_or_die losetup -r "$loopdev" "$file"
+        else
+          do_or_die losetup "$loopdev" "$file"
+        fi
         xenstore_write "$XENBUS_PATH/node" "$loopdev"
         write_dev "$loopdev"
         release_lock "block"

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2007-02-02 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-02 20:43 Daniel P. Berrange [this message]
2007-02-06 15:35 ` Fix for loop mounting of readonly images Ewan Mellor

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=20070202204313.GG18218@redhat.com \
    --to=berrange@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.