From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O90JI-0004Ck-7y for qemu-devel@nongnu.org; Mon, 03 May 2010 14:24:04 -0400 Received: from [140.186.70.92] (port=60442 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O90JG-00021n-20 for qemu-devel@nongnu.org; Mon, 03 May 2010 14:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O903K-0000l1-Dk for qemu-devel@nongnu.org; Mon, 03 May 2010 14:07:35 -0400 Received: from mail-qy0-f188.google.com ([209.85.221.188]:61978) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O903J-0000YL-Ik for qemu-devel@nongnu.org; Mon, 03 May 2010 14:07:34 -0400 Received: by qyk26 with SMTP id 26so4215804qyk.19 for ; Mon, 03 May 2010 11:06:06 -0700 (PDT) Message-ID: <4BDF1086.7030606@codemonkey.ws> Date: Mon, 03 May 2010 13:05:58 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command References: <1272213037-30327-1-git-send-email-nsprei@redhat.com> In-Reply-To: <1272213037-30327-1-git-send-email-nsprei@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Naphtali Sprei Cc: qemu-devel@nongnu.org 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 > 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; > } >