qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command
Date: Mon, 03 May 2010 13:05:58 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0

On 04/25/2010 11:30 AM, Naphtali Sprei wrote:
Current code of monitor command: 'change', used to open file for read-write
uncoditionally. Change to open it as read-only for CDROM, and read-write for 
all others.

Signed-off-by: Naphtali Sprei<address@hidden>

Applied.  Thanks.

Regards,

Anthony Liguori
---
  monitor.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/monitor.c b/monitor.c
index c25d551..df5a15d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1083,6 +1083,7 @@ static int do_change_block(Monitor *mon, const char 
*device,
  {
      BlockDriverState *bs;
      BlockDriver *drv = NULL;
+    int bdrv_flags;

      bs = bdrv_find(device);
      if (!bs) {
@@ -1099,7 +1100,8 @@ static int do_change_block(Monitor *mon, const char 
*device,
      if (eject_device(mon, bs, 0)<  0) {
          return -1;
      }
-    if (bdrv_open(bs, filename, BDRV_O_RDWR, drv)<  0) {
+    bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR;
+    if (bdrv_open(bs, filename, bdrv_flags, drv)<  0) {
          qerror_report(QERR_OPEN_FILE_FAILED, filename);
          return -1;
      }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]