* [PATCH] virtio_blk: allow read-only disks
@ 2008-05-16 9:17 Christian Borntraeger
2008-05-16 9:28 ` Tomasz Chmielewski
2008-05-16 14:25 ` Rusty Russell
0 siblings, 2 replies; 4+ messages in thread
From: Christian Borntraeger @ 2008-05-16 9:17 UTC (permalink / raw)
To: Rusty Russell, kvm-devel; +Cc: virtualization
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system
corruption, the disk should be mounted read-only in that case. This patch
adds a new feature flag, that allows the host to specify, if the disk should
be considered read-only.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
drivers/block/virtio_blk.c | 6 +++++-
include/linux/virtio_blk.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
Index: kvm/drivers/block/virtio_blk.c
===================================================================
--- kvm.orig/drivers/block/virtio_blk.c
+++ kvm/drivers/block/virtio_blk.c
@@ -260,6 +260,10 @@ static int virtblk_probe(struct virtio_d
if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER))
blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL);
+ /* If disk is read-only in the host, the guest should obey */
+ if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))
+ set_disk_ro(vblk->disk, 1);
+
/* Host must always specify the capacity. */
vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity),
&cap, sizeof(cap));
@@ -325,7 +329,7 @@ static struct virtio_device_id id_table[
static unsigned int features[] = {
VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
- VIRTIO_BLK_F_GEOMETRY,
+ VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO,
};
static struct virtio_driver virtio_blk = {
Index: kvm/include/linux/virtio_blk.h
===================================================================
--- kvm.orig/include/linux/virtio_blk.h
+++ kvm/include/linux/virtio_blk.h
@@ -10,6 +10,7 @@
#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
+#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
struct virtio_blk_config
{
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] virtio_blk: allow read-only disks
2008-05-16 9:17 [PATCH] virtio_blk: allow read-only disks Christian Borntraeger
@ 2008-05-16 9:28 ` Tomasz Chmielewski
2008-05-17 4:01 ` Rusty Russell
2008-05-16 14:25 ` Rusty Russell
1 sibling, 1 reply; 4+ messages in thread
From: Tomasz Chmielewski @ 2008-05-16 9:28 UTC (permalink / raw)
To: Christian Borntraeger; +Cc: kvm-devel, virtualization
Christian Borntraeger schrieb:
> Hello Rusty,
>
> sometimes it is useful to share a disk (e.g. usr). To avoid file system
> corruption, the disk should be mounted read-only in that case.
Although it is done at a different level here, I wanted to note that mounting a
filesystem read-only does not necessarily mean the system will not try to write
to it. This is the case for ext3, for example - when mounted ro, system will
still reply the journal and do some writes etc.
The patch, however, should take care of that, too, as it is completely different
place it is made ro.
--
Tomasz Chmielewski
http://wpkg.org
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio_blk: allow read-only disks
2008-05-16 9:28 ` Tomasz Chmielewski
@ 2008-05-17 4:01 ` Rusty Russell
0 siblings, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2008-05-17 4:01 UTC (permalink / raw)
To: Tomasz Chmielewski; +Cc: kvm-devel, Christian Borntraeger, virtualization
On Friday 16 May 2008 19:28:27 Tomasz Chmielewski wrote:
> Christian Borntraeger schrieb:
> > Hello Rusty,
> >
> > sometimes it is useful to share a disk (e.g. usr). To avoid file system
> > corruption, the disk should be mounted read-only in that case.
>
> Although it is done at a different level here, I wanted to note that
> mounting a filesystem read-only does not necessarily mean the system will
> not try to write to it. This is the case for ext3, for example - when
> mounted ro, system will still reply the journal and do some writes etc.
>
> The patch, however, should take care of that, too, as it is completely
> different place it is made ro.
Note I'm assuming that the host will deny writes. Telling the guest is merely
politeness.
Cheers,
Rusty.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio_blk: allow read-only disks
2008-05-16 9:17 [PATCH] virtio_blk: allow read-only disks Christian Borntraeger
2008-05-16 9:28 ` Tomasz Chmielewski
@ 2008-05-16 14:25 ` Rusty Russell
1 sibling, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2008-05-16 14:25 UTC (permalink / raw)
To: Christian Borntraeger; +Cc: kvm-devel, virtualization
On Friday 16 May 2008 19:17:03 Christian Borntraeger wrote:
> Hello Rusty,
>
> sometimes it is useful to share a disk (e.g. usr). To avoid file system
> corruption, the disk should be mounted read-only in that case. This patch
> adds a new feature flag, that allows the host to specify, if the disk
> should be considered read-only.
Applied, thanks.
Rusty.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-05-17 4:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-16 9:17 [PATCH] virtio_blk: allow read-only disks Christian Borntraeger
2008-05-16 9:28 ` Tomasz Chmielewski
2008-05-17 4:01 ` Rusty Russell
2008-05-16 14:25 ` Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox