Skip to contentSkip to conversation

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

PATCH In review Lin Ma 2 participants 3 messages Jan 22, 2018 – Jan 23, 2018

lore
Share & tools
lore

Lin Ma

author
#0 lore raw

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

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, ...
---
 blockdev.c | 2 ++
 1 file changed, 2 insertions(+)
blockdev.c +2 -0
index 29d569a24e..ef4c167235 100644
@@ -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;
Signature · 1 line
2.15.1
#1 lore raw
Quoted 5 lines · Lin Ma

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.:

Quoted 8 lines
$ 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, ...
---
 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

author
#2 lore raw
Quoted 14 lines · Max Reitz
Quoted 5 lines · Lin Ma

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.:

Quoted 8 lines
$ 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, ...
---
  blockdev.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 8 lines

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