diff mbox series

raw: Disable probing if image format is given by driver-specific options

Message ID 20180122072102.4141-1-lma@suse.com
State New
Headers show
Series raw: Disable probing if image format is given by driver-specific options | expand

Commit Message

Lin Ma Jan. 22, 2018, 7:21 a.m. UTC
If the user specifies image format through driver-specific options, The
format probing should be prohibited and the warning message should not
be printed.

e.g.:
$ qemu-system-x86_64 ... -drive file.file.filename=disk0.raw,file.driver=raw ...
WARNING: Image format was not specified for 'disk0.raw' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, ...

Signed-off-by: Lin Ma <lma@suse.com>
---
 blockdev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Max Reitz Jan. 22, 2018, 4:45 p.m. UTC | #1
On 2018-01-22 08:21, Lin Ma wrote:
> If the user specifies image format through driver-specific options, The
> format probing should be prohibited and the warning message should not
> be printed.
> 
> e.g.:
> $ qemu-system-x86_64 ... -drive file.file.filename=disk0.raw,file.driver=raw ...
> WARNING: Image format was not specified for 'disk0.raw' and probing guessed raw.
>          Automatically detecting the format is dangerous for raw images, ...
> 
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
>  blockdev.c | 2 ++
>  1 file changed, 2 insertions(+)

But what has been proped is the driver for the root BDS, so the warning
is actually correct.

(That command line is creating a chain of three BDS:
raw (probed) -> raw (explicitly specified) -> file (default protocol))

Max
Lin Ma Jan. 23, 2018, 3:05 a.m. UTC | #2
On 01/23/2018 12:45 AM, Max Reitz wrote:
> On 2018-01-22 08:21, Lin Ma wrote:
>> If the user specifies image format through driver-specific options, The
>> format probing should be prohibited and the warning message should not
>> be printed.
>>
>> e.g.:
>> $ qemu-system-x86_64 ... -drive file.file.filename=disk0.raw,file.driver=raw ...
>> WARNING: Image format was not specified for 'disk0.raw' and probing guessed raw.
>>           Automatically detecting the format is dangerous for raw images, ...
>>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> ---
>>   blockdev.c | 2 ++
>>   1 file changed, 2 insertions(+)
> But what has been proped is the driver for the root BDS, so the warning
> is actually correct.
>
> (That command line is creating a chain of three BDS:
> raw (probed) -> raw (explicitly specified) -> file (default protocol))
>
> Max
>
OK, Thanks
Lin
diff mbox series

Patch

diff --git a/blockdev.c b/blockdev.c
index 29d569a24e..ef4c167235 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -529,6 +529,8 @@  static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
             goto early_err;
         }
         qdict_put_str(bs_opts, "driver", buf);
+    } else if (qdict_haskey(bs_opts, "file.driver")) {
+        qdict_put_str(bs_opts, "driver", qdict_get_str(bs_opts, "file.driver"));
     }
 
     on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;