[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/27] qemu-img: snapshot: allow specifying -f fmt
From: |
Michael Tokarev |
Subject: |
[PATCH 14/27] qemu-img: snapshot: allow specifying -f fmt |
Date: |
Wed, 24 Apr 2024 11:50:22 +0300 |
For consistency with other commands, and since it already
accepts --image-opts, allow specifying -f fmt too.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
docs/tools/qemu-img.rst | 2 +-
qemu-img-cmds.hx | 4 ++--
qemu-img.c | 9 ++++++---
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index 3653adb963..9b628c4da5 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -663,7 +663,7 @@ Command description:
bitmap support, or 0 if bitmaps are supported but there is nothing
to copy.
-.. option:: snapshot [--object OBJECTDEF] [--image-opts] [-U] [-q] [-l | -a
SNAPSHOT | -c SNAPSHOT | -d SNAPSHOT] FILENAME
+.. option:: snapshot [--object OBJECTDEF] [-f FMT | --image-opts] [-U] [-q]
[-l | -a SNAPSHOT | -c SNAPSHOT | -d SNAPSHOT] FILENAME
List, apply, create or delete snapshots in image *FILENAME*.
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index c9dd70a892..2c5a8a28f9 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -84,9 +84,9 @@ SRST
ERST
DEF("snapshot", img_snapshot,
- "snapshot [--object objectdef] [--image-opts] [-U] [-q] [-l | -a snapshot
| -c snapshot | -d snapshot] filename")
+ "snapshot [--object objectdef] [-f fmt | --image-opts] [-U] [-q] [-l | -a
snapshot | -c snapshot | -d snapshot] filename")
SRST
-.. option:: snapshot [--object OBJECTDEF] [--image-opts] [-U] [-q] [-l | -a
SNAPSHOT | -c SNAPSHOT | -d SNAPSHOT] FILENAME
+.. option:: snapshot [--object OBJECTDEF] [-f FMT | --image-opts] [-U] [-q]
[-l | -a SNAPSHOT | -c SNAPSHOT | -d SNAPSHOT] FILENAME
ERST
DEF("rebase", img_rebase,
diff --git a/qemu-img.c b/qemu-img.c
index 84e2e53fb7..8adc324496 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3595,7 +3595,7 @@ static int img_snapshot(const img_cmd_t *ccmd, int argc,
char **argv)
BlockBackend *blk;
BlockDriverState *bs;
QEMUSnapshotInfo sn;
- char *filename, *snapshot_name = NULL;
+ char *filename, *fmt = NULL, *snapshot_name = NULL;
int c, ret = 0, bdrv_oflags;
int action = 0;
bool quiet = false;
@@ -3614,7 +3614,7 @@ static int img_snapshot(const img_cmd_t *ccmd, int argc,
char **argv)
{"force-share", no_argument, 0, 'U'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, ":la:c:d:hqU",
+ c = getopt_long(argc, argv, ":la:c:d:f:hqU",
long_options, NULL);
if (c == -1) {
break;
@@ -3629,6 +3629,9 @@ static int img_snapshot(const img_cmd_t *ccmd, int argc,
char **argv)
case 'h':
help();
return 0;
+ case 'f':
+ fmt = optarg;
+ break;
case 'l':
if (action) {
error_exit(argv[0], "Cannot mix '-l', '-a', '-c', '-d'");
@@ -3682,7 +3685,7 @@ static int img_snapshot(const img_cmd_t *ccmd, int argc,
char **argv)
filename = argv[optind++];
/* Open the image */
- blk = img_open(image_opts, filename, NULL, bdrv_oflags, false, quiet,
+ blk = img_open(image_opts, filename, fmt, bdrv_oflags, false, quiet,
force_share);
if (!blk) {
return 1;
--
2.39.2
- [PATCH 03/27] qemu-img: global option processing and error printing, (continued)
- [PATCH 03/27] qemu-img: global option processing and error printing, Michael Tokarev, 2024/04/24
- [PATCH 04/27] qemu-img: pass current cmd info into command handlers, Michael Tokarev, 2024/04/24
- [PATCH 05/27] qemu-img: create: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 06/27] qemu-img: factor out parse_output_format() and use it in the code, Michael Tokarev, 2024/04/24
- [PATCH 10/27] qemu-img: compare: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 11/27] qemu-img: convert: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 07/27] qemu-img: check: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 08/27] qemu-img: simplify --repair error message, Michael Tokarev, 2024/04/24
- [PATCH 09/27] qemu-img: commit: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 13/27] qemu-img: map: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 14/27] qemu-img: snapshot: allow specifying -f fmt,
Michael Tokarev <=
- [PATCH 12/27] qemu-img: info: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 15/27] qemu-img: snapshot: make -l (list) the default, simplify option handling, Michael Tokarev, 2024/04/24
- [PATCH 16/27] qemu-img: snapshot: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 17/27] qemu-img: rebase: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 18/27] qemu-img: resize: do not always eat last argument, Michael Tokarev, 2024/04/24
- [PATCH 20/27] qemu-img: amend: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 19/27] qemu-img: resize: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 22/27] qemu-img: bitmap: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 21/27] qemu-img: bench: refresh options/--help, Michael Tokarev, 2024/04/24
- [PATCH 23/27] qemu-img: dd: refresh options/--help, Michael Tokarev, 2024/04/24