|
|
26ba25 |
From 267e29969f1e835db7a3fb7d5f9e9befe6e8dcad Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
Date: Mon, 18 Jun 2018 14:59:40 +0200
|
|
|
26ba25 |
Subject: [PATCH 067/268] qemu-img: Add print_amend_option_help()
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
Message-id: <20180618145943.4489-5-mreitz@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 80753
|
|
|
26ba25 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 4/7] qemu-img: Add print_amend_option_help()
|
|
|
26ba25 |
Bugzilla: 1537956
|
|
|
26ba25 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
The more generic print_block_option_help() function is not really
|
|
|
26ba25 |
suitable for qemu-img amend, for a couple of reasons:
|
|
|
26ba25 |
(1) We do not need to append the protocol-level options, as amendment
|
|
|
26ba25 |
happens only on one node and does not descend downwards to its
|
|
|
26ba25 |
children.
|
|
|
26ba25 |
(2) print_block_option_help() says those options are "supported". For
|
|
|
26ba25 |
option amendment, we do not really know that. So this new function
|
|
|
26ba25 |
explicitly says that those options are the creation options, and not
|
|
|
26ba25 |
all of them may be supported.
|
|
|
26ba25 |
(3) If the driver does not support option amendment, we should not print
|
|
|
26ba25 |
anything (except for an error message that amendment is not
|
|
|
26ba25 |
supported).
|
|
|
26ba25 |
|
|
|
26ba25 |
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1537956
|
|
|
26ba25 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
26ba25 |
Message-id: 20180509210023.20283-5-mreitz@redhat.com
|
|
|
26ba25 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
(cherry picked from commit 51641351420e4f9dc6613d0dd03a5f0f214ed5b6)
|
|
|
26ba25 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
qemu-img.c | 30 ++++++++++++++++++++++++++++--
|
|
|
26ba25 |
tests/qemu-iotests/082.out | 44 +++++++++++++++++++++++++++-----------------
|
|
|
26ba25 |
2 files changed, 55 insertions(+), 19 deletions(-)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
26ba25 |
index cdeb01b..d4cbb63 100644
|
|
|
26ba25 |
--- a/qemu-img.c
|
|
|
26ba25 |
+++ b/qemu-img.c
|
|
|
26ba25 |
@@ -3609,6 +3609,32 @@ static void amend_status_cb(BlockDriverState *bs,
|
|
|
26ba25 |
qemu_progress_print(100.f * offset / total_work_size, 0);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
+static int print_amend_option_help(const char *format)
|
|
|
26ba25 |
+{
|
|
|
26ba25 |
+ BlockDriver *drv;
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ /* Find driver and parse its options */
|
|
|
26ba25 |
+ drv = bdrv_find_format(format);
|
|
|
26ba25 |
+ if (!drv) {
|
|
|
26ba25 |
+ error_report("Unknown file format '%s'", format);
|
|
|
26ba25 |
+ return 1;
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ if (!drv->bdrv_amend_options) {
|
|
|
26ba25 |
+ error_report("Format driver '%s' does not support option amendment",
|
|
|
26ba25 |
+ format);
|
|
|
26ba25 |
+ return 1;
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ /* Every driver supporting amendment must have create_opts */
|
|
|
26ba25 |
+ assert(drv->create_opts);
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ printf("Creation options for '%s':\n", format);
|
|
|
26ba25 |
+ qemu_opts_print_help(drv->create_opts);
|
|
|
26ba25 |
+ printf("\nNote that not all of these options may be amendable.\n");
|
|
|
26ba25 |
+ return 0;
|
|
|
26ba25 |
+}
|
|
|
26ba25 |
+
|
|
|
26ba25 |
static int img_amend(int argc, char **argv)
|
|
|
26ba25 |
{
|
|
|
26ba25 |
Error *err = NULL;
|
|
|
26ba25 |
@@ -3708,7 +3734,7 @@ static int img_amend(int argc, char **argv)
|
|
|
26ba25 |
if (fmt && has_help_option(options)) {
|
|
|
26ba25 |
/* If a format is explicitly specified (and possibly no filename is
|
|
|
26ba25 |
* given), print option help here */
|
|
|
26ba25 |
- ret = print_block_option_help(filename, fmt);
|
|
|
26ba25 |
+ ret = print_amend_option_help(fmt);
|
|
|
26ba25 |
goto out;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
@@ -3737,7 +3763,7 @@ static int img_amend(int argc, char **argv)
|
|
|
26ba25 |
|
|
|
26ba25 |
if (has_help_option(options)) {
|
|
|
26ba25 |
/* If the format was auto-detected, print option help here */
|
|
|
26ba25 |
- ret = print_block_option_help(filename, fmt);
|
|
|
26ba25 |
+ ret = print_amend_option_help(fmt);
|
|
|
26ba25 |
goto out;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
|
|
|
26ba25 |
index 1527fbe..4e52dce 100644
|
|
|
26ba25 |
--- a/tests/qemu-iotests/082.out
|
|
|
26ba25 |
+++ b/tests/qemu-iotests/082.out
|
|
|
26ba25 |
@@ -546,7 +546,7 @@ cluster_size: 65536
|
|
|
26ba25 |
=== amend: help for -o ===
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -564,10 +564,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -585,10 +586,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -606,10 +608,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -627,10 +630,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -648,10 +652,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -669,10 +674,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -690,10 +696,11 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -711,7 +718,8 @@ cluster_size qcow2 cluster size
|
|
|
26ba25 |
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
-nocow Turn off copy-on-write (valid only on btrfs)
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2
|
|
|
26ba25 |
|
|
|
26ba25 |
@@ -731,7 +739,7 @@ Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/
|
|
|
26ba25 |
qemu-img: Invalid option list: ,,
|
|
|
26ba25 |
|
|
|
26ba25 |
Testing: amend -f qcow2 -o help
|
|
|
26ba25 |
-Supported options:
|
|
|
26ba25 |
+Creation options for 'qcow2':
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
compat Compatibility level (0.10 or 1.1)
|
|
|
26ba25 |
backing_file File name of a base image
|
|
|
26ba25 |
@@ -750,6 +758,8 @@ preallocation Preallocation mode (allowed values: off, metadata, falloc, full
|
|
|
26ba25 |
lazy_refcounts Postpone refcount updates
|
|
|
26ba25 |
refcount_bits Width of a reference count entry in bits
|
|
|
26ba25 |
|
|
|
26ba25 |
+Note that not all of these options may be amendable.
|
|
|
26ba25 |
+
|
|
|
26ba25 |
Testing: convert -o help
|
|
|
26ba25 |
Supported options:
|
|
|
26ba25 |
size Virtual disk size
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|