|
|
9ae3a8 |
From bb18c8167f4b3a912e57ca4185e9e58d4d3a149b Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 24 Oct 2014 08:17:58 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 10/19] qemu-img: Allow cache mode specification for amend
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1414138680-19600-3-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 61863
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH v2 2/4] qemu-img: Allow cache mode specification for amend
|
|
|
9ae3a8 |
Bugzilla: 1138691
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu-img amend may extensively modify the target image, depending on the
|
|
|
9ae3a8 |
options to be amended (e.g. conversion to qcow2 compat level 0.10 from
|
|
|
9ae3a8 |
1.1 for an image with many unallocated zero clusters). Therefore it
|
|
|
9ae3a8 |
makes sense to allow the user to specify the cache mode to be used.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit bd39e6ed0b88a1473c652c97e731a156cccf16e2)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-img.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
QemuOpts are not used throughout the downstream block layer.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-img-cmds.hx | 4 ++--
|
|
|
9ae3a8 |
qemu-img.c | 19 +++++++++++++++----
|
|
|
9ae3a8 |
qemu-img.texi | 2 +-
|
|
|
9ae3a8 |
3 files changed, 18 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
|
|
9ae3a8 |
index e590d46..5efdfe9 100644
|
|
|
9ae3a8 |
--- a/qemu-img-cmds.hx
|
|
|
9ae3a8 |
+++ b/qemu-img-cmds.hx
|
|
|
9ae3a8 |
@@ -70,8 +70,8 @@ STEXI
|
|
|
9ae3a8 |
ETEXI
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
DEF("amend", img_amend,
|
|
|
9ae3a8 |
- "amend [-q] [-f fmt] -o options filename")
|
|
|
9ae3a8 |
+ "amend [-q] [-f fmt] [-t cache] -o options filename")
|
|
|
9ae3a8 |
STEXI
|
|
|
9ae3a8 |
-@item amend [-q] [-f @var{fmt}] -o @var{options} @var{filename}
|
|
|
9ae3a8 |
+@item amend [-q] [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename}
|
|
|
9ae3a8 |
@end table
|
|
|
9ae3a8 |
ETEXI
|
|
|
9ae3a8 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
9ae3a8 |
index 25fdc37..1f28729 100644
|
|
|
9ae3a8 |
--- a/qemu-img.c
|
|
|
9ae3a8 |
+++ b/qemu-img.c
|
|
|
9ae3a8 |
@@ -2659,12 +2659,14 @@ static int img_amend(int argc, char **argv)
|
|
|
9ae3a8 |
int c, ret = 0;
|
|
|
9ae3a8 |
char *options = NULL;
|
|
|
9ae3a8 |
QEMUOptionParameter *create_options = NULL, *options_param = NULL;
|
|
|
9ae3a8 |
- const char *fmt = NULL, *filename;
|
|
|
9ae3a8 |
+ const char *fmt = NULL, *filename, *cache;
|
|
|
9ae3a8 |
+ int flags;
|
|
|
9ae3a8 |
bool quiet = false;
|
|
|
9ae3a8 |
BlockDriverState *bs = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ cache = BDRV_DEFAULT_CACHE;
|
|
|
9ae3a8 |
for (;;) {
|
|
|
9ae3a8 |
- c = getopt(argc, argv, "hqf:o:");
|
|
|
9ae3a8 |
+ c = getopt(argc, argv, "ho:f:t:q");
|
|
|
9ae3a8 |
if (c == -1) {
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -2691,6 +2693,9 @@ static int img_amend(int argc, char **argv)
|
|
|
9ae3a8 |
case 'f':
|
|
|
9ae3a8 |
fmt = optarg;
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
+ case 't':
|
|
|
9ae3a8 |
+ cache = optarg;
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
case 'q':
|
|
|
9ae3a8 |
quiet = true;
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
@@ -2713,8 +2718,14 @@ static int img_amend(int argc, char **argv)
|
|
|
9ae3a8 |
help();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bs = bdrv_new_open("image", filename, fmt,
|
|
|
9ae3a8 |
- BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
|
|
|
9ae3a8 |
+ flags = BDRV_O_FLAGS | BDRV_O_RDWR;
|
|
|
9ae3a8 |
+ ret = bdrv_parse_cache_flags(cache, &flags);
|
|
|
9ae3a8 |
+ if (ret < 0) {
|
|
|
9ae3a8 |
+ error_report("Invalid cache option: %s", cache);
|
|
|
9ae3a8 |
+ goto out;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ bs = bdrv_new_open("image", filename, fmt, flags, true, quiet);
|
|
|
9ae3a8 |
if (!bs) {
|
|
|
9ae3a8 |
error_report("Could not open image '%s'", filename);
|
|
|
9ae3a8 |
ret = -1;
|
|
|
9ae3a8 |
diff --git a/qemu-img.texi b/qemu-img.texi
|
|
|
9ae3a8 |
index 3d06e91..078fe81 100644
|
|
|
9ae3a8 |
--- a/qemu-img.texi
|
|
|
9ae3a8 |
+++ b/qemu-img.texi
|
|
|
9ae3a8 |
@@ -370,7 +370,7 @@ After using this command to grow a disk image, you must use file system and
|
|
|
9ae3a8 |
partitioning tools inside the VM to actually begin using the new space on the
|
|
|
9ae3a8 |
device.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-@item amend [-f @var{fmt}] -o @var{options} @var{filename}
|
|
|
9ae3a8 |
+@item amend [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Amends the image format specific @var{options} for the image file
|
|
|
9ae3a8 |
@var{filename}. Not all file formats support this operation.
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|