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