qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command
@ 2010-04-25 16:30 Naphtali Sprei
  2010-05-03 18:05 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Naphtali Sprei @ 2010-04-25 16:30 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command
  2010-04-25 16:30 [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command Naphtali Sprei
@ 2010-05-03 18:05 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2010-05-03 18:05 UTC (permalink / raw)
  To: Naphtali Sprei; +Cc: qemu-devel

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

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;
>       }
>    

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-03 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-25 16:30 [Qemu-devel] [PATCH] block: read-only: open cdrom as read-only when using monitor's change command Naphtali Sprei
2010-05-03 18:05 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).