From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N3RWU-0001FN-I6 for qemu-devel@nongnu.org; Thu, 29 Oct 2009 05:42:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N3RWM-00016F-Pl for qemu-devel@nongnu.org; Thu, 29 Oct 2009 05:42:23 -0400 Received: from [199.232.76.173] (port=58422 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3RWM-00015s-9S for qemu-devel@nongnu.org; Thu, 29 Oct 2009 05:42:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22315) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N3RWL-0003dh-Np for qemu-devel@nongnu.org; Thu, 29 Oct 2009 05:42:18 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9T9gG7F003953 for ; Thu, 29 Oct 2009 05:42:17 -0400 Received: from [10.35.0.60] (dhcp-0-60.tlv.redhat.com [10.35.0.60]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9T9gCmc000993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 29 Oct 2009 05:42:15 -0400 Message-ID: <4AE96373.8020407@redhat.com> Date: Thu, 29 Oct 2009 11:42:11 +0200 From: Naphtali Sprei MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Pass the drive's readonly attribute to the guest OS List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, I've seen my patch (http://repo.or.cz/w/qemu/aliguori-queue.git?a=commit;h=2286b94c7458cd6d72883990b53500194975c2ff) in the staging tree, but the patch relies on a previous patch (http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg01316.html) I sent that I cannot find in the staging tree, nor committed. So here is the missing patch again, against current head. Naphtali Subject: [PATCH] Pass the drive's readonly attribute to the guest OS Implemented for virtio-blk and for scsi Signed-off-by: Naphtali Sprei --- hw/scsi-disk.c | 3 ++- hw/virtio-blk.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 2a9268a..5da573d 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -633,7 +633,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->dinfo->bdrv) == BDRV_TYPE_CDROM) { + if (bdrv_get_type_hint(s->dinfo->bdrv) == BDRV_TYPE_CDROM || + bdrv_is_read_only(s->dinfo->bdrv)) { outbuf[2] = 0x80; /* Readonly. */ } p += 4; diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 2630b99..e6df9f2 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -444,6 +444,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev) #endif if (strcmp(s->serial_str, "0")) features |= 1 << VIRTIO_BLK_F_IDENTIFY; + + if (bdrv_is_read_only(s->bs)) + features |= 1 << VIRTIO_BLK_F_RO; return features; } -- 1.6.3.3