Skip to contentSkip to conversation

qemu-img convert: Deprecate using -n and -o together

PATCH In review Kevin Wolf 4 participants 4 messages Aug 15, 2019

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH v2 1/1 qemu-img convert: Deprecate using -n and -o together

bdrv_create options specified with -o have no effect when skipping image creation with -n, so this doesn't make sense. Warn against the misuse and deprecate the combination so we can make it a hard error later.

---

- Hopefully removed the "finger-wagging" that John saw, without stating that the combination doesn't have a well-defined behaviour (because skipping image creation and therefore ignoring -o is well-defined behaviour).

 qemu-img.c           | 5 +++++
 qemu-deprecated.texi | 7 +++++++
 2 files changed, 12 insertions(+)
qemu-img.c +5 -0
index 79983772de..d9321f6418 100644
@@ -2231,6 +2231,11 @@ static int img_convert(int argc, char **argv)
         goto fail_getopt;
     }
 
+    if (skip_create && options) {
+        warn_report("-o has no effect when skipping image creation");
+        warn_report("This will become an error in future QEMU versions.");
+    }
+
     s.src_num = argc - optind - 1;
     out_filename = s.src_num >= 1 ? argv[argc - 1] : NULL;
 
qemu-deprecated.texi +7 -0
index fff07bb2a3..f7680c08e1 100644
@@ -305,6 +305,13 @@ to just export the entire image and then mount only /dev/nbd0p1 than
 it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
 subset of the image.
 
+@subsection qemu-img convert -n -o (since 4.2.0)
+
+All options specified in @option{-o} are image creation options, so
+they have no effect when used with @option{-n} to skip image creation.
+Silently ignored options can be confusing, so this combination of
+options will be made an error in future versions.
+
 @section Build system
 
 @subsection Python 2 support (since 4.1.0)
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Kevin Wolf

bdrv_create options specified with -o have no effect when skipping image creation with -n, so this doesn't make sense. Warn against the misuse and deprecate the combination so we can make it a hard error later.

---

- Hopefully removed the "finger-wagging" that John saw, without stating that the combination doesn't have a well-defined behaviour (because skipping image creation and therefore ignoring -o is well-defined behaviour).

The problem is that e.g. the man page never says that -o gives creation options. It says that “options is a [...] list of format specific options”, nothing more.

Quoted 3 lines
 qemu-img.c           | 5 +++++
 qemu-deprecated.texi | 7 +++++++
 2 files changed, 12 insertions(+)
Reviewed-by on v2 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

bdrv_create options specified with -o have no effect when skipping image creation with -n, so this doesn't make sense. Warn against the misuse and deprecate the combination so we can make it a hard error later.

---

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v2 1/1
#3 lore raw
In reply to Kevin Wolf
Quoted 4 lines · Kevin Wolf

bdrv_create options specified with -o have no effect when skipping image creation with -n, so this doesn't make sense. Warn against the misuse and deprecate the combination so we can make it a hard error later.

Quoted 8 lines

---

- Hopefully removed the "finger-wagging" that John saw, without stating that the combination doesn't have a well-defined behaviour (because skipping image creation and therefore ignoring -o is well-defined behaviour).

I'm sorry if that critique was in itself a finger-wag :( I'm not always the best with tone in written language myself.

Arguably this is supposed to be my primary language, too.

Quoted 29 lines
 qemu-img.c           | 5 +++++
 qemu-deprecated.texi | 7 +++++++
 2 files changed, 12 insertions(+)
qemu-img.c +5 -0
index 79983772de..d9321f6418 100644
@@ -2231,6 +2231,11 @@ static int img_convert(int argc, char **argv)
         goto fail_getopt;
     }
 
+    if (skip_create && options) {
+        warn_report("-o has no effect when skipping image creation");
+        warn_report("This will become an error in future QEMU versions.");
+    }
+
     s.src_num = argc - optind - 1;
     out_filename = s.src_num >= 1 ? argv[argc - 1] : NULL;
 
qemu-deprecated.texi +0 -0
index fff07bb2a3..f7680c08e1 100644
@@ -305,6 +305,13 @@ to just export the entire image and then mount only /dev/nbd0p1 than
 it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
 subset of the image.
 

qemu-deprecated.texi to just export the entire image and then mount only /dev/nbd0p1 than · line 317

Quoted 10 lines
qemu-deprecated.texi +7 -0
+@subsection qemu-img convert -n -o (since 4.2.0)
+
+All options specified in @option{-o} are image creation options, so
+they have no effect when used with @option{-n} to skip image creation.
+Silently ignored options can be confusing, so this combination of
+options will be made an error in future versions.
+
 @section Build system
 
 @subsection Python 2 support (since 4.1.0)

I do think this reads more pleasantly, though, so thank you very much for that!