aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2025-05-31 20:16:00 +0300
committerKevin Wolf <kwolf@redhat.com>2025-07-15 20:49:01 +0200
commitc1563952521d4d5947b4279efe8dcc432791287e (patch)
treeae337c87fd856ccffb4559402271306be5019c7c
parent9fd7e6658cd42cc09905f0b950cd6e9acfc81354 (diff)
downloadqemu-c1563952521d4d5947b4279efe8dcc432791287e.zip
qemu-c1563952521d4d5947b4279efe8dcc432791287e.tar.gz
qemu-c1563952521d4d5947b4279efe8dcc432791287e.tar.bz2
qemu-img: rebase: refresh options/--help (short option change)
Add missing long options and --help output, reorder options for consistency. Use -B for --backing-format, keep -F for backwards compatibility. Options added: --format, --cache - for the image in question --backing, --backing-format, --backing-cache, --backing-unsafe - for the new backing file (was eg CACHE vs SRC_CACHE, which is unclear). Probably should rename local variables. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20250531171609.197078-19-mjt@tls.msk.ru> [kwolf: Removed command description from the argument list] Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--docs/tools/qemu-img.rst2
-rw-r--r--qemu-img.c87
2 files changed, 63 insertions, 26 deletions
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index a346988..5e7b850 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -667,7 +667,7 @@ Command description:
List, apply, create or delete snapshots in image *FILENAME*.
-.. option:: rebase [--object OBJECTDEF] [--image-opts] [-U] [-q] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-p] [-u] [-c] -b BACKING_FILE [-F BACKING_FMT] FILENAME
+.. option:: rebase [--object OBJECTDEF] [--image-opts] [-U] [-q] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-p] [-u] [-c] -b BACKING_FILE [-B BACKING_FMT] FILENAME
Changes the backing file of an image. Only the formats ``qcow2`` and
``qed`` support changing the backing file.
diff --git a/qemu-img.c b/qemu-img.c
index cc26ae9..a02d271 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3798,45 +3798,89 @@ static int img_rebase(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},
- {"force-share", no_argument, 0, 'U'},
+ {"cache", required_argument, 0, 't'},
{"compress", no_argument, 0, 'c'},
+ {"backing", required_argument, 0, 'b'},
+ {"backing-format", required_argument, 0, 'B'},
+ {"backing-cache", required_argument, 0, 'T'},
+ {"backing-unsafe", no_argument, 0, 'u'},
+ {"force-share", no_argument, 0, 'U'},
+ {"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:F:b:upt:T:qUc",
+ c = getopt_long(argc, argv, "hf:t:cb:F:B:T:uUpq",
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 FMT | --image-opts] [-t CACHE]\n"
+" [-b BACKING_FILE [-B BACKING_FMT] [-T BACKING_CACHE]] [-u]\n"
+" [-c] [-U] [-p] [-q] [--object OBJDEF] FILE\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"
+" -t, --cache CACHE\n"
+" cache mode for FILE (default: " BDRV_DEFAULT_CACHE ")\n"
+" -b, --backing BACKING_FILE|\"\"\n"
+" rebase onto this file (specify empty name for no backing file)\n"
+" -B, --backing-format BACKING_FMT (was -F in <=10.0)\n"
+" specify format for BACKING_FILE explicitly (default: probing is used)\n"
+" -T, --backing-cache CACHE\n"
+" BACKING_FILE cache mode (default: " BDRV_DEFAULT_CACHE ")\n"
+" -u, --backing-unsafe\n"
+" do not fail if BACKING_FILE can not be read\n"
+" -c, --compress\n"
+" compress image (when image supports this)\n"
+" -U, --force-share\n"
+" open image in shared mode for concurrent access\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 option string (key=value,..)\n"
+" with --image-opts, to operate on\n"
+);
return 0;
case 'f':
fmt = optarg;
break;
- case 'F':
- out_basefmt = optarg;
+ case OPTION_IMAGE_OPTS:
+ image_opts = true;
+ break;
+ case 't':
+ cache = optarg;
break;
case 'b':
out_baseimg = optarg;
break;
+ case 'F': /* <=10.0 */
+ case 'B':
+ out_basefmt = optarg;
+ break;
case 'u':
unsafe = 1;
break;
+ case 'c':
+ compress = true;
+ break;
+ case 'U':
+ force_share = true;
+ break;
case 'p':
progress = 1;
break;
- case 't':
- cache = optarg;
- break;
case 'T':
src_cache = optarg;
break;
@@ -3846,15 +3890,8 @@ static int img_rebase(const img_cmd_t *ccmd, int argc, char **argv)
case OPTION_OBJECT:
user_creatable_process_cmdline(optarg);
break;
- case OPTION_IMAGE_OPTS:
- image_opts = true;
- break;
- case 'U':
- force_share = true;
- break;
- case 'c':
- compress = true;
- break;
+ default:
+ tryhelp(argv[0]);
}
}