From 06fcc3206cc2dc8f65f5c2394eaaa138c3d6c539 Mon Sep 17 00:00:00 2001 From: Naphtali Sprei <nsprei@redhat.com> Date: Thu, 15 Apr 2010 11:56:39 -0300 Subject: [PATCH 03/12] read-only: Pass the read-only attribute to the Guest RH-Author: Naphtali Sprei <nsprei@redhat.com> Message-id: <1271332608-5243-3-git-send-email-nsprei@redhat.com> Patchwork-id: 8650 O-Subject: [RHEL 5.6 kvm PATCH v4 02/11] read-only: Pass the read-only attribute to the Guest Bugzilla: 510630 RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Kevin Wolf <kwolf@redhat.com> Added for scsi and virtio-blk upstream commit: c79662f7f765a0e6cb7aa26902cc8d61f9022dd5 Signed-off-by: Naphtali Sprei <nsprei@redhat.com> --- qemu/hw/scsi-disk.c | 3 ++- qemu/hw/virtio-blk.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/hw/scsi-disk.c | 3 ++- qemu/hw/virtio-blk.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/qemu/hw/scsi-disk.c b/qemu/hw/scsi-disk.c index 00bcf28..f3f07ac 100644 --- a/qemu/hw/scsi-disk.c +++ b/qemu/hw/scsi-disk.c @@ -626,7 +626,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, memset(p, 0, 4); outbuf[1] = 0; /* Default media type. */ outbuf[3] = 0; /* Block descriptor length. */ - if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) { + if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM || + bdrv_is_read_only(s->bdrv)) { outbuf[2] = 0x80; /* Readonly. */ } p += 4; diff --git a/qemu/hw/virtio-blk.c b/qemu/hw/virtio-blk.c index 8d3e295..7dd03cc 100644 --- a/qemu/hw/virtio-blk.c +++ b/qemu/hw/virtio-blk.c @@ -327,6 +327,8 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev) features = (1 << VIRTIO_BLK_F_SEG_MAX | 1 << VIRTIO_BLK_F_GEOMETRY); if (bdrv_enable_write_cache(s->bs)) features |= (1 << VIRTIO_BLK_F_WCACHE); + if (bdrv_is_read_only(s->bs)) + features |= 1 << VIRTIO_BLK_F_RO; return features; } -- 1.7.0.3