Patchwork [v2,4/4] Disable fall-back to read-only when cannot open drive's file for read-write

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

Comments

Naphtali Sprei - Jan. 17, 2010, 2:48 p.m.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
 block.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
Michael S. Tsirkin - Jan. 17, 2010, 2:59 p.m.
On Sun, Jan 17, 2010 at 04:48:15PM +0200, Naphtali Sprei wrote:
> 
> Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
> ---
>  block.c |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 8def3c4..f90e983 100644
> --- a/block.c
> +++ b/block.c
> @@ -444,8 +444,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>      if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
>          bs->enable_write_cache = 1;
>  
> -    /* Note: for compatibility, we open disk image files as RDWR, and
> -       RDONLY as fallback */
>      bs->read_only = (flags & BDRV_O_RDWR) == 0;
>      if (!(flags & BDRV_O_FILE)) {
>          open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
> @@ -459,10 +457,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>          ret = -ENOTSUP;
>      } else {
>          ret = drv->bdrv_open(bs, filename, open_flags);
> -        if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) {
> -            ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR);
> -            bs->read_only = 1;
> -        }

Maybe print an error message explaining the problem and
suggesting the solution?

>      }
>      if (ret < 0) {
>          qemu_free(bs->opaque);
> -- 
> 1.6.3.3
> 
>
Naphtali Sprei - Jan. 18, 2010, 11:45 a.m.
Michael S. Tsirkin wrote:
> On Sun, Jan 17, 2010 at 04:48:15PM +0200, Naphtali Sprei wrote:
>> Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
>> ---
>>  block.c |    6 ------
>>  1 files changed, 0 insertions(+), 6 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index 8def3c4..f90e983 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -444,8 +444,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>>      if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
>>          bs->enable_write_cache = 1;
>>  
>> -    /* Note: for compatibility, we open disk image files as RDWR, and
>> -       RDONLY as fallback */
>>      bs->read_only = (flags & BDRV_O_RDWR) == 0;
>>      if (!(flags & BDRV_O_FILE)) {
>>          open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
>> @@ -459,10 +457,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
>>          ret = -ENOTSUP;
>>      } else {
>>          ret = drv->bdrv_open(bs, filename, open_flags);
>> -        if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) {
>> -            ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR);
>> -            bs->read_only = 1;
>> -        }
> 
> Maybe print an error message explaining the problem and
> suggesting the solution?

Printing done in (some of the) callers.
Should add suggestion. How is it done in QMP ?

> 
>>      }
>>      if (ret < 0) {
>>          qemu_free(bs->opaque);
>> -- 
>> 1.6.3.3
>>
>>

Patch

diff --git a/block.c b/block.c
index 8def3c4..f90e983 100644
--- a/block.c
+++ b/block.c
@@ -444,8 +444,6 @@  int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
     if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
         bs->enable_write_cache = 1;
 
-    /* Note: for compatibility, we open disk image files as RDWR, and
-       RDONLY as fallback */
     bs->read_only = (flags & BDRV_O_RDWR) == 0;
     if (!(flags & BDRV_O_FILE)) {
         open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
@@ -459,10 +457,6 @@  int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         ret = -ENOTSUP;
     } else {
         ret = drv->bdrv_open(bs, filename, open_flags);
-        if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) {
-            ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR);
-            bs->read_only = 1;
-        }
     }
     if (ret < 0) {
         qemu_free(bs->opaque);