Skip to contentSkip to conversation

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

PATCH Superseded Kevin Wolf 5 participants 5 messages Aug 9, 2019 – Aug 12, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

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

---
 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..7673d079c5 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. This
+combination never made sense and shows that the user misunderstood the
+effect of the options, so this 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 v1 1/1
#1 lore raw
Quoted 15 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.

---
 qemu-img.c           | 5 +++++
 qemu-deprecated.texi | 7 +++++++
 2 files changed, 12 insertions(+)
qemu-img.c +0 -0
index 79983772de..d9321f6418 100644

qemu-img.c static int img_convert(int argc, char **argv) · line 2236

Quoted 6 lines
qemu-img.c +3 -0
@@ -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.");

It looks a bit odd to have two output lines, where one is a phrase and the other is a full sentence. But I don't have any better ideas how to represent it, so

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 9 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.

---
 qemu-img.c           | 5 +++++
 qemu-deprecated.texi | 7 +++++++
 2 files changed, 12 insertions(+)
#3 lore raw
In reply to Kevin Wolf
Quoted 37 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.

---
 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..7673d079c5 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)

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

Quoted 5 lines
qemu-deprecated.texi +5 -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. This
+combination never made sense and shows that the user misunderstood the
+effect of the options, so this will be made an error in future versions.

The user misunderstood by not reading qemu code?

Both the online help and the manual page do not mention anything about that, so I think
they should be fixed to explain the behavior, and this text should mention that the behavior
was never documented.

Nir

Quoted 9 lines

+
@section Build system

@subsection Python 2 support (since 4.1.0)
--
2.20.1

Reviewed-by on v1 1/1
#4 lore raw
In reply to Kevin Wolf
Quoted 31 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.

---
 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..7673d079c5 100644

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

Quoted 10 lines
qemu-deprecated.texi +7 -0
@@ -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. This
+combination never made sense and shows that the user misunderstood the
+effect of the options, so this will be made an error in future versions.
+

I would avoid too much finger-wagging here. We can just say that the combination never had a well-defined behavior, so it will now be treated as an error.

Otherwise: