From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MxLIR-0005hp-J4 for qemu-devel@nongnu.org; Mon, 12 Oct 2009 09:50:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MxLIL-0005b0-HZ for qemu-devel@nongnu.org; Mon, 12 Oct 2009 09:50:42 -0400 Received: from [199.232.76.173] (port=59471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MxLIL-0005an-4G for qemu-devel@nongnu.org; Mon, 12 Oct 2009 09:50:37 -0400 Received: from mail2.shareable.org ([80.68.89.115]:34218) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MxLIK-0000Zu-KW for qemu-devel@nongnu.org; Mon, 12 Oct 2009 09:50:36 -0400 Date: Mon, 12 Oct 2009 14:50:32 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] Add readonly flag to -drive command Message-ID: <20091012135032.GA13560@shareable.org> References: <4AD32550.8040901@redhat.com> <4AD32DF6.4050100@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AD32DF6.4050100@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Naphtali Sprei , qemu-devel@nongnu.org Kevin Wolf wrote: > Am 12.10.2009 14:47, schrieb Naphtali Sprei: > > In order to safely share an image between guests (as read only drive), add a 'readonly' flag > > to the -drive command (qemu command line and monitor). Heh. I've been sharing images between guests for ages - using "chmod -r" :-) > > Still missing passing the read only attribute to the guest, where possible. I don't know which device types supports > > read only, and don't know how to pass this information to guests. This was discussed in a thread some months ago. You might look it up. SCSI, USB, and floppy can pass the information to guests - see the Linux kernel for how the flag is read. CD-ROMs are read-only already of course. I don't know if virtio-blk can; if not, it would be good to add it. Not sure about the latest iterations of PATA/SATA. Read-only images are particularly useful for the backing file for a qcow2 image or -snapshot. Then the guest doesn't need to know anything, but 'savevm', 'delvm' and 'commit' need to be stopped from trying to modify the backing file. (But it's fine for -snapshot + commit to modify a writable qcow2 file which _itself_ has a read-only backing file, as long as 'commit' doesn't try to push the commit further back than one level). > > Also not sure what to do when qemu cannot open the file as > > writeable. Currently it opens it as read only. We might change it > > to give a warning or even an error. I think that's a good plan, but please don't break the current situation, where it's possible to "chmod -r" an image file and then share it safely, until the 'readonly' flag is a usable replacement. > Is this enough? Basically none of the block drivers know that their > image could be read-only, so we'll likely trigger some unexpected error > cases there. For a simple write I guess we'll be okay (not sure if we'll > return the right error code, though), but I have no idea what, say, > savevm would do with a read-only image. Right now there is already a 'readonly' flag called 'chmod -r image', because QEMU opens a file read-only if it can't open it writable, so it's not a new case. Just moving it from the filesystem into QEMU. When opened read-only, it would be better for the block drivers to return an error themselves, instead of trying to write and (hopefully) getting a host OS error. I doubt if read-only errors have been tested or accomodated, or if they are reported well to guests as the right sort of error. I'm pretty sure the read-only _flag_ isn't passed through guest interfaces for the guest OS to use yet, but that should be quite easy. -- Jamie