Patchwork [v2,1/4] Make CDROM a read-only drive

login
register
mail settings
Submitter Naphtali Sprei
Date Jan. 17, 2010, 2:48 p.m.
Message ID <1263739695-13043-2-git-send-email-nsprei@redhat.com>
Download mbox | patch
Permalink /patch/43029/
State New
Headers show

Comments

Naphtali Sprei - Jan. 17, 2010, 2:48 p.m.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
 vl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Jamie Lokier - Jan. 20, 2010, 2:06 a.m.
Naphtali Sprei wrote:
>          }
>          (void)bdrv_set_read_only(dinfo->bdrv, 1);
>      }
> +    /* 
> +     * cdrom is read-only. Set it now, after above interface checking
> +     * since readonly attribute not explicitly required, so no error.
> +     */
> +    if (media == MEDIA_CDROM) {
> +        (void)bdrv_set_read_only(dinfo->bdrv, 1);
> +    }
>  
>      if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
>          fprintf(stderr, "qemu: could not open disk image %s: %s\n",

When I have anything to say, I usually ask for more comments, but in
this case, I think the code would be perfectly clear without it.

-- Jamie
Anthony Liguori - Jan. 20, 2010, 2:55 p.m.
On 01/17/2010 08:48 AM, Naphtali Sprei wrote:
> Signed-off-by: Naphtali Sprei<nsprei@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   vl.c |    7 +++++++
>   1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 06cb40d..76ef8ca 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2233,6 +2233,13 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
>           }
>           (void)bdrv_set_read_only(dinfo->bdrv, 1);
>       }
> +    /*
> +     * cdrom is read-only. Set it now, after above interface checking
> +     * since readonly attribute not explicitly required, so no error.
> +     */
> +    if (media == MEDIA_CDROM) {
> +        (void)bdrv_set_read_only(dinfo->bdrv, 1);
> +    }
>
>       if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv)<  0) {
>           fprintf(stderr, "qemu: could not open disk image %s: %s\n",
>

Patch

diff --git a/vl.c b/vl.c
index 06cb40d..76ef8ca 100644
--- a/vl.c
+++ b/vl.c
@@ -2233,6 +2233,13 @@  DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         }
         (void)bdrv_set_read_only(dinfo->bdrv, 1);
     }
+    /* 
+     * cdrom is read-only. Set it now, after above interface checking
+     * since readonly attribute not explicitly required, so no error.
+     */
+    if (media == MEDIA_CDROM) {
+        (void)bdrv_set_read_only(dinfo->bdrv, 1);
+    }
 
     if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
         fprintf(stderr, "qemu: could not open disk image %s: %s\n",