summaryrefslogtreecommitdiffstats
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-07-22 22:58:43 +0200
committerKevin Wolf <kwolf@redhat.com>2014-08-22 14:54:48 +0200
commitbd39e6ed0b88a1473c652c97e731a156cccf16e2 (patch)
tree68cd59ae096c360b62b9f55a6062979fb15ac7de /qemu-img.c
parent40055951a7afbfc037c6c7351d72a5c5d83ed99b (diff)
downloadhqemu-bd39e6ed0b88a1473c652c97e731a156cccf16e2.zip
hqemu-bd39e6ed0b88a1473c652c97e731a156cccf16e2.tar.gz
qemu-img: Allow cache mode specification for amend
qemu-img amend may extensively modify the target image, depending on the options to be amended (e.g. conversion to qcow2 compat level 0.10 from 1.1 for an image with many unallocated zero clusters). Therefore it makes sense to allow the user to specify the cache mode to be used. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/qemu-img.c b/qemu-img.c
index df85405..c843420 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2778,12 +2778,14 @@ static int img_amend(int argc, char **argv)
char *options = NULL;
QemuOptsList *create_opts = NULL;
QemuOpts *opts = NULL;
- const char *fmt = NULL, *filename;
+ const char *fmt = NULL, *filename, *cache;
+ int flags;
bool quiet = false;
BlockDriverState *bs = NULL;
+ cache = BDRV_DEFAULT_CACHE;
for (;;) {
- c = getopt(argc, argv, "hqf:o:");
+ c = getopt(argc, argv, "ho:f:t:q");
if (c == -1) {
break;
}
@@ -2810,6 +2812,9 @@ static int img_amend(int argc, char **argv)
case 'f':
fmt = optarg;
break;
+ case 't':
+ cache = optarg;
+ break;
case 'q':
quiet = true;
break;
@@ -2832,8 +2837,14 @@ static int img_amend(int argc, char **argv)
error_exit("Expecting one image file name");
}
- bs = bdrv_new_open("image", filename, fmt,
- BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
+ flags = BDRV_O_FLAGS | BDRV_O_RDWR;
+ ret = bdrv_parse_cache_flags(cache, &flags);
+ if (ret < 0) {
+ error_report("Invalid cache option: %s", cache);
+ goto out;
+ }
+
+ bs = bdrv_new_open("image", filename, fmt, flags, true, quiet);
if (!bs) {
error_report("Could not open image '%s'", filename);
ret = -1;
OpenPOWER on IntegriCloud