From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 42/57] qemu-img: convert: refresh options/--help (short option change)
Date: Tue, 15 Jul 2025 21:03:15 +0200 [thread overview]
Message-ID: <20250715190330.378764-43-kwolf@redhat.com> (raw)
In-Reply-To: <20250715190330.378764-1-kwolf@redhat.com>
From: Michael Tokarev <mjt@tls.msk.ru>
Add missing long options and --help output.
Reorder options for consistency.
Use -b for --backing, and recognize -B for backwards
compatibility. Unfortunately we can't use -B to
specify backing format.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Message-ID: <20250715140702.131321-1-mjt@tls.msk.ru>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
docs/tools/qemu-img.rst | 2 +-
qemu-img.c | 230 +++++++++++++++++++++++++++-------------
2 files changed, 159 insertions(+), 73 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index a21e439082..23715811e2 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -419,7 +419,7 @@ Command description:
4
Error on reading data
-.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE [-F BACKING_FMT]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
+.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-b BACKING_FILE [-F BACKING_FMT]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
Convert the disk image *FILENAME* or a snapshot *SNAPSHOT_PARAM*
to disk image *OUTPUT_FILENAME* using format *OUTPUT_FMT*. It can
diff --git a/qemu-img.c b/qemu-img.c
index 5697e45ae6..950f319a97 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2390,53 +2390,122 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv)
for(;;) {
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
- {"object", required_argument, 0, OPTION_OBJECT},
+ {"source-format", required_argument, 0, 'f'},
+ /*
+ * XXX: historic --image-opts acts on source file only,
+ * it seems better to have it affect both source and target,
+ * and have separate --source-image-opts for source,
+ * but this might break existing setups.
+ */
{"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
- {"force-share", no_argument, 0, 'U'},
- {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS},
- {"salvage", no_argument, 0, OPTION_SALVAGE},
- {"target-is-zero", no_argument, 0, OPTION_TARGET_IS_ZERO},
+ {"source-cache", required_argument, 0, 'T'},
+ {"snapshot", required_argument, 0, 'l'},
{"bitmaps", no_argument, 0, OPTION_BITMAPS},
{"skip-broken-bitmaps", no_argument, 0, OPTION_SKIP_BROKEN},
+ {"salvage", no_argument, 0, OPTION_SALVAGE},
+ {"target-format", required_argument, 0, 'O'},
+ {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS},
+ {"target-format-options", required_argument, 0, 'o'},
+ {"target-cache", required_argument, 0, 't'},
+ {"backing", required_argument, 0, 'b'},
+ {"backing-format", required_argument, 0, 'F'},
+ {"sparse-size", required_argument, 0, 'S'},
+ {"no-create", no_argument, 0, 'n'},
+ {"target-is-zero", no_argument, 0, OPTION_TARGET_IS_ZERO},
+ {"force-share", no_argument, 0, 'U'},
+ {"rate-limit", required_argument, 0, 'r'},
+ {"parallel", required_argument, 0, 'm'},
+ {"oob-writes", no_argument, 0, 'W'},
+ {"copy-range-offloading", no_argument, 0, 'C'},
+ {"progress", no_argument, 0, 'p'},
+ {"quiet", no_argument, 0, 'q'},
+ {"object", required_argument, 0, OPTION_OBJECT},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, ":hf:O:B:CcF:o:l:S:pt:T:qnm:WUr:",
+ c = getopt_long(argc, argv, "hf:O:b:B:CcF:o:l:S:pt:T:nm:WUr:q",
long_options, NULL);
if (c == -1) {
break;
}
- switch(c) {
- case ':':
- missing_argument(argv[optind - 1]);
- break;
- case '?':
- unrecognized_option(argv[optind - 1]);
- break;
+ switch (c) {
case 'h':
- help();
+ cmd_help(ccmd, "[-f SRC_FMT | --image-opts] [-T SRC_CACHE]\n"
+" [-l SNAPSHOT] [--bitmaps [--skip-broken-bitmaps]] [--salvage]\n"
+" [-O TGT_FMT | --target-image-opts] [-o TGT_FMT_OPTS] [-t TGT_CACHE]\n"
+" [-b BACKING_FILE [-F BACKING_FMT]] [-S SPARSE_SIZE]\n"
+" [-n] [--target-is-zero] [-c]\n"
+" [-U] [-r RATE] [-m NUM_PARALLEL] [-W] [-C] [-p] [-q] [--object OBJDEF]\n"
+" SRC_FILE [SRC_FILE2...] TGT_FILE\n"
+,
+" -f, --source-format SRC_FMT\n"
+" specify format of all SRC_FILEs explicitly (default: probing is used)\n"
+" --image-opts\n"
+" treat each SRC_FILE as an option string (key=value,...), not a file name\n"
+" (incompatible with -f|--source-format)\n"
+" -T, --source-cache SRC_CACHE\n"
+" source image(s) cache mode (" BDRV_DEFAULT_CACHE ")\n"
+" -l, --snapshot SNAPSHOT\n"
+" specify source snapshot\n"
+" --bitmaps\n"
+" also copy any persistent bitmaps present in source\n"
+" --skip-broken-bitmaps\n"
+" skip (do not error out) any broken bitmaps\n"
+" --salvage\n"
+" ignore errors on input (convert unreadable areas to zeros)\n"
+" -O, --target-format TGT_FMT\n"
+" specify TGT_FILE image format (default: raw)\n"
+" --target-image-opts\n"
+" treat TGT_FILE as an option string (key=value,...), not a file name\n"
+" (incompatible with -O|--target-format)\n"
+" -o, --target-format-options TGT_FMT_OPTS\n"
+" TGT_FMT-specific options\n"
+" -t, --target-cache TGT_CACHE\n"
+" cache mode when opening output image (default: unsafe)\n"
+" -b, --backing BACKING_FILE (was -B in <= 10.0)\n"
+" create target image to be a CoW on top of BACKING_FILE\n"
+" -F, --backing-format BACKING_FMT\n" /* -B used for -b in <=10.0 */
+" specify BACKING_FILE image format explicitly (default: probing is used)\n"
+" -S, --sparse-size SPARSE_SIZE[bkKMGTPE]\n"
+" specify number of consecutive zero bytes to treat as a gap on output\n"
+" (rounded down to nearest 512 bytes), with optional multiplier suffix\n"
+" -n, --no-create\n"
+" omit target volume creation (e.g. on rbd)\n"
+" --target-is-zero\n"
+" indicates that the target volume is pre-zeroed\n"
+" -c, --compress\n"
+" create compressed output image (qcow and qcow2 formats only)\n"
+" -U, --force-share\n"
+" open images in shared mode for concurrent access\n"
+" -r, --rate-limit RATE\n"
+" I/O rate limit, in bytes per second\n"
+" -m, --parallel NUM_PARALLEL\n"
+" specify parallelism (default: 8)\n"
+" -C, --copy-range-offloading\n"
+" try to use copy offloading\n"
+" -W, --oob-writes\n"
+" enable out-of-order writes to improve performance\n"
+" -p, --progress\n"
+" display progress information\n"
+" -q, --quiet\n"
+" quiet mode (produce only error messages if any)\n"
+" --object OBJDEF\n"
+" defines QEMU user-creatable object\n"
+" SRC_FILE...\n"
+" one or more source image file names,\n"
+" or option strings (key=value,..) with --source-image-opts\n"
+" TGT_FILE\n"
+" target (output) image file name,\n"
+" or option string (key=value,..) with --target-image-opts\n"
+);
break;
case 'f':
fmt = optarg;
break;
- case 'O':
- out_fmt = optarg;
- break;
- case 'B':
- out_baseimg = optarg;
- break;
- case 'C':
- s.copy_range = true;
- break;
- case 'c':
- s.compressed = true;
- break;
- case 'F':
- backing_fmt = optarg;
+ case OPTION_IMAGE_OPTS:
+ image_opts = true;
break;
- case 'o':
- if (accumulate_options(&options, optarg) < 0) {
- goto fail_getopt;
- }
+ case 'T':
+ src_cache = optarg;
break;
case 'l':
if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
@@ -2451,6 +2520,36 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv)
snapshot_name = optarg;
}
break;
+ case OPTION_BITMAPS:
+ bitmaps = true;
+ break;
+ case OPTION_SKIP_BROKEN:
+ skip_broken = true;
+ break;
+ case OPTION_SALVAGE:
+ s.salvage = true;
+ break;
+ case 'O':
+ out_fmt = optarg;
+ break;
+ case OPTION_TARGET_IMAGE_OPTS:
+ tgt_image_opts = true;
+ break;
+ case 'o':
+ if (accumulate_options(&options, optarg) < 0) {
+ goto fail_getopt;
+ }
+ break;
+ case 't':
+ cache = optarg;
+ break;
+ case 'B': /* <=10.0 */
+ case 'b':
+ out_baseimg = optarg;
+ break;
+ case 'F': /* can't use -B as it used as -b in <=10.0 */
+ backing_fmt = optarg;
+ break;
case 'S':
{
int64_t sval;
@@ -2471,20 +2570,28 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv)
explict_min_sparse = true;
break;
}
- case 'p':
- progress = true;
+ case 'n':
+ skip_create = true;
break;
- case 't':
- cache = optarg;
+ case OPTION_TARGET_IS_ZERO:
+ /*
+ * The user asserting that the target is blank has the
+ * same effect as the target driver supporting zero
+ * initialisation.
+ */
+ s.has_zero_init = true;
break;
- case 'T':
- src_cache = optarg;
+ case 'c':
+ s.compressed = true;
break;
- case 'q':
- s.quiet = true;
+ case 'U':
+ force_share = true;
break;
- case 'n':
- skip_create = true;
+ case 'r':
+ rate_limit = cvtnum("rate limit", optarg);
+ if (rate_limit < 0) {
+ goto fail_getopt;
+ }
break;
case 'm':
if (qemu_strtol(optarg, NULL, 0, &s.num_coroutines) ||
@@ -2497,41 +2604,20 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv)
case 'W':
s.wr_in_order = false;
break;
- case 'U':
- force_share = true;
+ case 'C':
+ s.copy_range = true;
break;
- case 'r':
- rate_limit = cvtnum("rate limit", optarg);
- if (rate_limit < 0) {
- goto fail_getopt;
- }
+ case 'p':
+ progress = true;
+ break;
+ case 'q':
+ s.quiet = true;
break;
case OPTION_OBJECT:
user_creatable_process_cmdline(optarg);
break;
- case OPTION_IMAGE_OPTS:
- image_opts = true;
- break;
- case OPTION_SALVAGE:
- s.salvage = true;
- break;
- case OPTION_TARGET_IMAGE_OPTS:
- tgt_image_opts = true;
- break;
- case OPTION_TARGET_IS_ZERO:
- /*
- * The user asserting that the target is blank has the
- * same effect as the target driver supporting zero
- * initialisation.
- */
- s.has_zero_init = true;
- break;
- case OPTION_BITMAPS:
- bitmaps = true;
- break;
- case OPTION_SKIP_BROKEN:
- skip_broken = true;
- break;
+ default:
+ tryhelp(argv[0]);
}
}
--
2.50.1
next prev parent reply other threads:[~2025-07-15 19:41 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 19:02 [PULL 00/57] Block layer patches Kevin Wolf
2025-07-15 19:02 ` [PULL 01/57] block: never use atomics to access bs->quiesce_counter Kevin Wolf
2025-07-15 19:02 ` [PULL 02/57] block: add bdrv_graph_wrlock_drained() convenience wrapper Kevin Wolf
2025-07-15 19:02 ` [PULL 03/57] block/mirror: switch to bdrv_set_backing_hd_drained() variant Kevin Wolf
2025-07-15 19:02 ` [PULL 04/57] block/commit: " Kevin Wolf
2025-07-15 19:02 ` [PULL 05/57] block: call bdrv_set_backing_hd() while unlocked in bdrv_open_backing_file() Kevin Wolf
2025-07-15 19:02 ` [PULL 06/57] block: mark bdrv_set_backing_hd() as GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:02 ` [PULL 07/57] blockdev: avoid locking and draining multiple times in external_snapshot_abort() Kevin Wolf
2025-07-15 19:02 ` [PULL 08/57] block: drop wrapper for bdrv_set_backing_hd_drained() Kevin Wolf
2025-07-15 19:02 ` [PULL 09/57] block-backend: mark blk_drain_all() as GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:02 ` [PULL 10/57] block/snapshot: mark bdrv_all_delete_snapshot() " Kevin Wolf
2025-07-15 19:02 ` [PULL 11/57] block/stream: mark stream_prepare() " Kevin Wolf
2025-07-15 19:02 ` [PULL 12/57] block: mark bdrv_reopen_queue() and bdrv_reopen_multiple() " Kevin Wolf
2025-07-15 19:02 ` [PULL 13/57] block: mark bdrv_inactivate() as GRAPH_RDLOCK and move drain to callers Kevin Wolf
2025-07-15 19:02 ` [PULL 14/57] block: mark bdrv_inactivate_all() as GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:02 ` [PULL 15/57] block: mark blk_remove_bs() " Kevin Wolf
2025-07-15 19:02 ` [PULL 16/57] block: mark blk_drain() " Kevin Wolf
2025-07-15 19:02 ` [PULL 17/57] block-backend: mark blk_io_limits_disable() " Kevin Wolf
2025-07-15 19:02 ` [PULL 18/57] block/commit: mark commit_abort() " Kevin Wolf
2025-07-15 19:02 ` [PULL 19/57] block: Allow bdrv_new() with and without graph lock Kevin Wolf
2025-07-15 19:02 ` [PULL 20/57] block: mark bdrv_replace_child_bs() as GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:02 ` [PULL 21/57] block: mark bdrv_insert_node() " Kevin Wolf
2025-07-15 19:02 ` [PULL 22/57] block: mark bdrv_drop_intermediate() " Kevin Wolf
2025-07-15 19:02 ` [PULL 23/57] block: mark bdrv_close_all() " Kevin Wolf
2025-07-15 19:02 ` [PULL 24/57] block: mark bdrv_close() " Kevin Wolf
2025-07-15 19:02 ` [PULL 25/57] block: mark bdrv_open_child_common() and its callers GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:02 ` [PULL 26/57] blockjob: mark block_job_remove_all_bdrv() as GRAPH_UNLOCKED Kevin Wolf
2025-07-15 19:03 ` [PULL 27/57] block/qapi: include child references in block device info Kevin Wolf
2025-07-15 19:03 ` [PULL 28/57] block/qapi: make @node-name in @BlockDeviceInfo non-optional Kevin Wolf
2025-07-15 19:03 ` [PULL 29/57] file-posix: Fix aio=threads performance regression after enablign FUA Kevin Wolf
2025-07-15 19:03 ` [PULL 30/57] iotests: add test for changing the 'drive' property via 'qom-set' Kevin Wolf
2025-07-15 19:03 ` [PULL 31/57] qemu-img: measure: convert img_size to signed, simplify handling Kevin Wolf
2025-07-15 19:03 ` [PULL 32/57] qemu-img: create: " Kevin Wolf
2025-07-15 19:03 ` [PULL 33/57] qemu-img: global option processing and error printing Kevin Wolf
2025-07-15 19:03 ` [PULL 34/57] qemu-img: pass current cmd info into command handlers Kevin Wolf
2025-07-15 19:03 ` [PULL 35/57] qemu-img: create: refresh options/--help (short option change) Kevin Wolf
2025-07-15 19:03 ` [PULL 36/57] qemu-img: factor out parse_output_format() and use it in the code Kevin Wolf
2025-07-15 19:03 ` [PULL 37/57] qemu-img: check: refresh options/--help Kevin Wolf
2025-07-15 19:03 ` [PULL 38/57] qemu-img: simplify --repair error message Kevin Wolf
2025-07-15 19:03 ` [PULL 39/57] qemu-img: commit: refresh options/--help Kevin Wolf
2025-07-15 19:03 ` [PULL 40/57] qemu-img: compare: use helper function for --object Kevin Wolf
2025-07-15 19:03 ` [PULL 41/57] qemu-img: compare: refresh options/--help Kevin Wolf
2025-07-15 19:03 ` Kevin Wolf [this message]
2025-07-15 19:03 ` [PULL 43/57] qemu-img: info: " Kevin Wolf
2025-07-15 19:03 ` [PULL 44/57] qemu-img: map: " Kevin Wolf
2025-07-15 19:03 ` [PULL 45/57] qemu-img: snapshot: allow specifying -f fmt Kevin Wolf
2025-07-15 19:03 ` [PULL 46/57] qemu-img: snapshot: make -l (list) the default, simplify option handling Kevin Wolf
2025-07-15 19:03 ` [PULL 47/57] qemu-img: snapshot: refresh options/--help Kevin Wolf
2025-07-15 19:03 ` [PULL 48/57] qemu-img: rebase: refresh options/--help (short option change) Kevin Wolf
2025-07-15 19:03 ` [PULL 49/57] qemu-img: resize: do not always eat last argument Kevin Wolf
2025-07-15 19:03 ` [PULL 50/57] qemu-img: resize: refresh options/--help Kevin Wolf
2025-07-15 19:03 ` [PULL 51/57] qemu-img: amend: " Kevin Wolf
2025-07-15 19:03 ` [PULL 52/57] qemu-img: bench: " Kevin Wolf
2025-07-15 19:03 ` [PULL 53/57] qemu-img: bitmap: " Kevin Wolf
2025-07-15 19:03 ` [PULL 54/57] qemu-img: dd: " Kevin Wolf
2025-07-15 19:03 ` [PULL 55/57] qemu-img: measure: " Kevin Wolf
2025-07-15 19:03 ` [PULL 56/57] qemu-img: implement short --help, remove global help() function Kevin Wolf
2025-07-15 19:03 ` [PULL 57/57] qemu-img: extend cvtnum() and use it in more places Kevin Wolf
2025-07-16 12:41 ` [PULL 00/57] Block layer patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250715190330.378764-43-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.