aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2025-05-31 20:15:51 +0300
committerKevin Wolf <kwolf@redhat.com>2025-07-15 20:49:01 +0200
commita79d282fc9e1dfa887b13e079279277ea257162a (patch)
tree5a52b909e08392fda3a5025cb11b08c74179477a
parentbf1e1cd357b0dd395f880ac9a9cb436c0c304139 (diff)
downloadqemu-a79d282fc9e1dfa887b13e079279277ea257162a.zip
qemu-a79d282fc9e1dfa887b13e079279277ea257162a.tar.gz
qemu-a79d282fc9e1dfa887b13e079279277ea257162a.tar.bz2
qemu-img: commit: refresh options/--help
Add missing long options and --help output, reorder options for consistency. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20250531171609.197078-10-mjt@tls.msk.ru> [kwolf: Fixed up qemu-iotests] Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--qemu-img.c68
-rwxr-xr-xtests/qemu-iotests/1532
-rw-r--r--tests/qemu-iotests/153.out12
3 files changed, 55 insertions, 27 deletions
diff --git a/qemu-img.c b/qemu-img.c
index ec6802b..9d2eba3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1047,38 +1047,73 @@ static int img_commit(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},
+ {"format", required_argument, 0, 'f'},
{"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
+ {"cache", required_argument, 0, 't'},
+ {"drop", no_argument, 0, 'd'},
+ {"base", required_argument, 0, 'b'},
+ {"rate-limit", required_argument, 0, 'r'},
+ {"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, ":f:ht:b:dpqr:",
+ c = getopt_long(argc, argv, "hf:t:db:r:pq",
long_options, NULL);
if (c == -1) {
break;
}
switch(c) {
- case ':':
- missing_argument(argv[optind - 1]);
- break;
- case '?':
- unrecognized_option(argv[optind - 1]);
- break;
case 'h':
- help();
+ cmd_help(ccmd, "[-f FMT | --image-opts] [-t CACHE_MODE] [-b BASE_IMG]\n"
+" [-d] [-r RATE] [-q] [--object OBJDEF] FILE\n"
+,
+" -f, --format FMT\n"
+" specify FILE image format explicitly (default: probing is used)\n"
+" --image-opts\n"
+" treat FILE as an option string (key=value,..), not a file name\n"
+" (incompatible with -f|--format)\n"
+" -t, --cache CACHE_MODE image cache mode (default: " BDRV_DEFAULT_CACHE ")\n"
+" -d, --drop\n"
+" skip emptying FILE on completion\n"
+" -b, --base BASE_IMG\n"
+" image in the backing chain to commit change to\n"
+" (default: immediate backing file; implies --drop)\n"
+" -r, --rate-limit RATE\n"
+" I/O rate limit, in bytes per second\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"
+" FILE\n"
+" name of the image file, or an option string (key=value,..)\n"
+" with --image-opts, to operate on\n"
+);
break;
case 'f':
fmt = optarg;
break;
+ case OPTION_IMAGE_OPTS:
+ image_opts = true;
+ break;
case 't':
cache = optarg;
break;
+ case 'd':
+ drop = true;
+ break;
case 'b':
base = optarg;
/* -b implies -d */
drop = true;
break;
- case 'd':
- drop = true;
+ case 'r':
+ rate_limit = cvtnum("rate limit", optarg);
+ if (rate_limit < 0) {
+ return 1;
+ }
break;
case 'p':
progress = true;
@@ -1086,18 +1121,11 @@ static int img_commit(const img_cmd_t *ccmd, int argc, char **argv)
case 'q':
quiet = true;
break;
- case 'r':
- rate_limit = cvtnum("rate limit", optarg);
- if (rate_limit < 0) {
- return 1;
- }
- break;
case OPTION_OBJECT:
user_creatable_process_cmdline(optarg);
break;
- case OPTION_IMAGE_OPTS:
- image_opts = true;
- break;
+ default:
+ tryhelp(argv[0]);
}
}
diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
index 9bc3be8..1e02f6a 100755
--- a/tests/qemu-iotests/153
+++ b/tests/qemu-iotests/153
@@ -63,7 +63,7 @@ _supported_proto file
_run_cmd()
{
echo
- (echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir
+ (echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir | _filter_qemu_img
}
_do_run_qemu()
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index ff8e558..a8ffd01 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -124,8 +124,8 @@ qemu-img: unrecognized option '-U'
Try 'qemu-img --help' for more information
_qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
-Try 'qemu-img --help' for more information
+qemu-img commit: invalid option -- 'U'
+Try 'qemu-img commit --help' for more information
_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
qemu-img: unrecognized option '-U'
@@ -248,8 +248,8 @@ qemu-img: unrecognized option '-U'
Try 'qemu-img --help' for more information
_qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
-Try 'qemu-img --help' for more information
+qemu-img commit: invalid option -- 'U'
+Try 'qemu-img commit --help' for more information
_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
qemu-img: unrecognized option '-U'
@@ -353,8 +353,8 @@ qemu-img: unrecognized option '-U'
Try 'qemu-img --help' for more information
_qemu_img_wrapper commit -U TEST_DIR/t.qcow2
-qemu-img: unrecognized option '-U'
-Try 'qemu-img --help' for more information
+qemu-img commit: invalid option -- 'U'
+Try 'qemu-img commit --help' for more information
_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M
qemu-img: unrecognized option '-U'