From patchwork Thu Oct 29 09:42:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naphtali Sprei X-Patchwork-Id: 37173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4ABCAB7BDD for ; Thu, 29 Oct 2009 20:43:19 +1100 (EST) Received: from localhost ([127.0.0.1]:49245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3RXH-0001LY-RB for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2009 05:43:15 -0400 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 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: qemu-devel@nongnu.org X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] Pass the drive's readonly attribute to the guest OS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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; }