Skip to contentSkip to conversation

qemu-img: Make create hint at protocol options

PATCH Applied Max Reitz 3 participants 5 messages Apr 13, 2019 – Apr 29, 2019

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

cover qemu-img: Make create hint at protocol options

https://bugzilla.redhat.com/show_bug.cgi?id=1698863 reports that while "qemu-img create -f raw" supports the "preallocation" option, it is not listed under "-o help".

It turns out it is, but only if you specify a target filename. Users may not realize this, but a note should help.

Max Reitz (2):
iotests: Perform the correct test in 082
qemu-img: Make create hint at protocol options

 qemu-img.c                 | 13 ++++++++++++-
 tests/qemu-iotests/082     |  5 ++++-
 tests/qemu-iotests/082.out | 25 ++++++++++++++++++-------
 3 files changed, 34 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/2 iotests: Perform the correct test in 082

In the "amend" section of 082, we perform a single "convert" test (namely "convert -o help"). That does not make sense, especially because we have done exactly that "convert" test earlier in 082 already.

Replacing "convert" by "amend" yields an error, which is correct because there is no point in "amend" having a default format. The user has to either specify the format, or give a file for qemu-img to probe.

---
 tests/qemu-iotests/082     | 5 ++++-
 tests/qemu-iotests/082.out | 5 ++---
 2 files changed, 6 insertions(+), 4 deletions(-)
tests/qemu-iotests/082 +4 -1
index d0afa46e9a..278511dba4 100755
@@ -212,7 +212,10 @@ run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_I
 
 # Leave out everything that isn't needed
 run_qemu_img amend -f $IMGFMT -o help
-run_qemu_img convert -o help
+
+# amend requires specifying either a format explicitly, or a file
+# which it can probe
+run_qemu_img amend -o help
 
 # Try help option for a format that does not support amendment
 run_qemu_img amend -f bochs -o help
tests/qemu-iotests/082.out +2 -3
index d36938da9b..9a23b68511 100644
@@ -831,9 +831,8 @@ Creation options for 'qcow2':
 
 Note that not all of these options may be amendable.
 
-Testing: convert -o help
-Supported options:
-  size=<size>            - Virtual disk size
+Testing: amend -o help
+qemu-img: Expecting one image file name
 
 Testing: amend -f bochs -o help
 qemu-img: Format driver 'bochs' does not support option amendment
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH 2/2 qemu-img: Make create hint at protocol options

In reply to Max Reitz

qemu-img create allows giving just a format and "-o help" to get a list of the options supported by that format. Users may not realize that the protocol level may offer even more options, which they only get to see by specifying a filename.

This patch adds a note to hint at that fact.

---
 qemu-img.c                 | 13 ++++++++++++-
 tests/qemu-iotests/082.out | 20 ++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)
qemu-img.c +12 -1
index aa6f81f1ea..0016e24efe 100644
@@ -269,9 +269,20 @@ static int print_block_option_help(const char *filename, const char *fmt)
         create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
     }
 
-    printf("Supported options:\n");
+    if (filename) {
+        printf("Supported options:\n");
+    } else {
+        printf("Supported %s options:\n", fmt);
+    }
     qemu_opts_print_help(create_opts, false);
     qemu_opts_free(create_opts);
+
+    if (!filename) {
+        printf("\n"
+               "The protocol level may support further options.\n"
+               "Specify the target filename to include those options.\n");
+    }
+
     return 0;
 }
 
tests/qemu-iotests/082.out +16 -4
index 9a23b68511..7e25706813 100644
@@ -242,7 +242,7 @@ Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR
 qemu-img: Invalid option list: ,,
 
 Testing: create -f qcow2 -o help
-Supported options:
+Supported qcow2 options:
   backing_file=<str>     - File name of a base image
   backing_fmt=<str>      - Image format of the base image
   cluster_size=<size>    - qcow2 cluster size
@@ -263,10 +263,16 @@ Supported options:
   refcount_bits=<num>    - Width of a reference count entry in bits
   size=<size>            - Virtual disk size
 
+The protocol level may support further options.
+Specify the target filename to include those options.
+
 Testing: create -o help
-Supported options:
+Supported raw options:
   size=<size>            - Virtual disk size
 
+The protocol level may support further options.
+Specify the target filename to include those options.
+
 Testing: create -f bochs -o help
 qemu-img: Format driver 'bochs' does not support image creation
 
@@ -516,7 +522,7 @@ Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DI
 qemu-img: Invalid option list: ,,
 
 Testing: convert -O qcow2 -o help
-Supported options:
+Supported qcow2 options:
   backing_file=<str>     - File name of a base image
   backing_fmt=<str>      - Image format of the base image
   cluster_size=<size>    - qcow2 cluster size
@@ -537,10 +543,16 @@ Supported options:
   refcount_bits=<num>    - Width of a reference count entry in bits
   size=<size>            - Virtual disk size
 
+The protocol level may support further options.
+Specify the target filename to include those options.
+
 Testing: convert -o help
-Supported options:
+Supported raw options:
   size=<size>            - Virtual disk size
 
+The protocol level may support further options.
+Specify the target filename to include those options.
+
 Testing: convert -O bochs -o help
 qemu-img: Format driver 'bochs' does not support image creation
 
Signature · 1 line
2.20.1
Reviewed-by on the v1 series
#3 lore raw
In reply to Max Reitz
Quoted 8 lines · Max Reitz

https://bugzilla.redhat.com/show_bug.cgi?id=1698863 reports that while "qemu-img create -f raw" supports the "preallocation" option, it is not listed under "-o help".

It turns out it is, but only if you specify a target filename. Users may not realize this, but a note should help.

Quoted 9 lines

Max Reitz (2):
iotests: Perform the correct test in 082
qemu-img: Make create hint at protocol options

 qemu-img.c                 | 13 ++++++++++++-
 tests/qemu-iotests/082     |  5 ++++-
 tests/qemu-iotests/082.out | 25 ++++++++++++++++++-------
 3 files changed, 34 insertions(+), 9 deletions(-)

Seems like an improvement to me.

Applied
#4 lore raw
In reply to Max Reitz

Am 13.04.2019 um 17:20 hat Max Reitz geschrieben:

Quoted 6 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1698863 reports that while "qemu-img create -f raw" supports the "preallocation" option, it is not listed under "-o help".

It turns out it is, but only if you specify a target filename. Users may not realize this, but a note should help.

Thanks, applied to the block branch.

Kevin