mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:51 +00:00
qemu-img: resize: 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-21-mjt@tls.msk.ru> [kwolf: Fixed up qemu-iotests] Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
committed by
Kevin Wolf
parent
8737b342e2
commit
a8ce9adfe1
52
qemu-img.c
52
qemu-img.c
@@ -4329,36 +4329,48 @@ static int img_resize(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},
|
||||
{"preallocation", required_argument, 0, OPTION_PREALLOCATION},
|
||||
{"shrink", no_argument, 0, OPTION_SHRINK},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"object", required_argument, 0, OPTION_OBJECT},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
c = getopt_long(argc, argv, "-:f:hq",
|
||||
c = getopt_long(argc, argv, "-hf:q",
|
||||
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();
|
||||
break;
|
||||
cmd_help(ccmd, "[-f FMT | --image-opts] [--preallocation PREALLOC] [--shrink]\n"
|
||||
" [-q] [--object OBJDEF] FILE [+-]SIZE[bkKMGTPE]\n"
|
||||
,
|
||||
" -f, --format FMT\n"
|
||||
" specify FILE 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"
|
||||
" --shrink\n"
|
||||
" allow operation when the new size is smaller than the original\n"
|
||||
" --preallocation PREALLOC\n"
|
||||
" specify FMT-specific preallocation type for the new areas\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 option string (key=value,..)\n"
|
||||
" with --image-opts, to operate on\n"
|
||||
" [+-]SIZE[bkKMGTPE]\n"
|
||||
" new image size or amount by which to shrink (-)/grow (+),\n"
|
||||
" with optional multiplier suffix (powers of 1024, default is bytes)\n"
|
||||
);
|
||||
return 0;
|
||||
case 'f':
|
||||
fmt = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = true;
|
||||
break;
|
||||
case OPTION_OBJECT:
|
||||
user_creatable_process_cmdline(optarg);
|
||||
break;
|
||||
case OPTION_IMAGE_OPTS:
|
||||
image_opts = true;
|
||||
break;
|
||||
@@ -4373,6 +4385,12 @@ static int img_resize(const img_cmd_t *ccmd, int argc, char **argv)
|
||||
case OPTION_SHRINK:
|
||||
shrink = true;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = true;
|
||||
break;
|
||||
case OPTION_OBJECT:
|
||||
user_creatable_process_cmdline(optarg);
|
||||
break;
|
||||
case 1: /* a non-optional argument */
|
||||
if (!filename) {
|
||||
filename = optarg;
|
||||
@@ -4391,6 +4409,8 @@ static int img_resize(const img_cmd_t *ccmd, int argc, char **argv)
|
||||
error_exit(argv[0], "Extra argument(s) in command line");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tryhelp(argv[0]);
|
||||
}
|
||||
}
|
||||
if (!filename && optind < argc) {
|
||||
|
||||
@@ -128,8 +128,8 @@ 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'
|
||||
Try 'qemu-img --help' for more information
|
||||
qemu-img resize: invalid option -- 'U'
|
||||
Try 'qemu-img resize --help' for more information
|
||||
|
||||
_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
|
||||
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
|
||||
@@ -252,8 +252,8 @@ 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'
|
||||
Try 'qemu-img --help' for more information
|
||||
qemu-img resize: invalid option -- 'U'
|
||||
Try 'qemu-img resize --help' for more information
|
||||
|
||||
_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
|
||||
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
|
||||
@@ -357,8 +357,8 @@ 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'
|
||||
Try 'qemu-img --help' for more information
|
||||
qemu-img resize: invalid option -- 'U'
|
||||
Try 'qemu-img resize --help' for more information
|
||||
|
||||
_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user