All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naphtali Sprei <nsprei@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Pass the drive's readonly attribute to the guest OS
Date: Thu, 29 Oct 2009 11:42:11 +0200	[thread overview]
Message-ID: <4AE96373.8020407@redhat.com> (raw)

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 <nsprei@redhat.com>
---
 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

             reply	other threads:[~2009-10-29  9:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-29  9:42 Naphtali Sprei [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-14 15:52 [Qemu-devel] [PATCH] Pass the drive's readonly attribute to the guest OS Naphtali Sprei
2009-10-14 15:57 ` Gerd Hoffmann
2009-10-14 15:59   ` Naphtali Sprei
2009-10-14 16:07     ` Gerd Hoffmann
2009-10-14 16:32       ` Naphtali Sprei
2009-10-14 16:40 ` Naphtali Sprei
2009-10-15  9:36   ` Kevin Wolf
2009-10-15  9:43     ` Gleb Natapov
2009-10-15  9:50       ` Kevin Wolf
2009-10-15  9:54         ` Gleb Natapov
2009-10-15  9:55           ` Kevin Wolf
2009-10-15 10:01             ` Gleb Natapov
2009-10-15 10:05               ` Kevin Wolf
2009-10-15 10:11                 ` Gleb Natapov
2009-10-15 10:18                   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AE96373.8020407@redhat.com \
    --to=nsprei@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.