[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 2/7] qemu-img: Add progress output for amend
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v4 2/7] qemu-img: Add progress output for amend |
Date: |
Mon, 27 Oct 2014 11:12:51 +0100 |
Now that bdrv_amend_options() supports a status callback, use it to
display a progress report.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
---
qemu-img-cmds.hx | 4 ++--
qemu-img.c | 25 ++++++++++++++++++++++---
qemu-img.texi | 2 +-
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 55aec6b..d83f3d0 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -70,8 +70,8 @@ STEXI
ETEXI
DEF("amend", img_amend,
- "amend [-q] [-f fmt] [-t cache] -o options filename")
+ "amend [-p] [-q] [-f fmt] [-t cache] -o options filename")
STEXI
address@hidden amend [-q] [-f @var{fmt}] [-t @var{cache}] -o @var{options}
@var{filename}
address@hidden amend [-p] [-q] [-f @var{fmt}] [-t @var{cache}] -o @var{options}
@var{filename}
@end table
ETEXI
diff --git a/qemu-img.c b/qemu-img.c
index 58973ef..9ec2c28 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2770,6 +2770,12 @@ out:
return 0;
}
+static void amend_status_cb(BlockDriverState *bs,
+ int64_t offset, int64_t total_work_size)
+{
+ qemu_progress_print(100.f * offset / total_work_size, 0);
+}
+
static int img_amend(int argc, char **argv)
{
int c, ret = 0;
@@ -2778,13 +2784,13 @@ static int img_amend(int argc, char **argv)
QemuOpts *opts = NULL;
const char *fmt = NULL, *filename, *cache;
int flags;
- bool quiet = false;
+ bool quiet = false, progress = false;
BlockBackend *blk = NULL;
BlockDriverState *bs = NULL;
cache = BDRV_DEFAULT_CACHE;
for (;;) {
- c = getopt(argc, argv, "ho:f:t:q");
+ c = getopt(argc, argv, "ho:f:t:pq");
if (c == -1) {
break;
}
@@ -2814,6 +2820,9 @@ static int img_amend(int argc, char **argv)
case 't':
cache = optarg;
break;
+ case 'p':
+ progress = true;
+ break;
case 'q':
quiet = true;
break;
@@ -2824,6 +2833,11 @@ static int img_amend(int argc, char **argv)
error_exit("Must specify options (-o)");
}
+ if (quiet) {
+ progress = false;
+ }
+ qemu_progress_init(progress, 1.0);
+
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
if (fmt && has_help_option(options)) {
/* If a format is explicitly specified (and possibly no filename is
@@ -2867,13 +2881,18 @@ static int img_amend(int argc, char **argv)
goto out;
}
- ret = bdrv_amend_options(bs, opts, NULL);
+ /* In case the driver does not call amend_status_cb() */
+ qemu_progress_print(0.f, 0);
+ ret = bdrv_amend_options(bs, opts, &amend_status_cb);
+ qemu_progress_print(100.f, 0);
if (ret < 0) {
error_report("Error while amending options: %s", strerror(-ret));
goto out;
}
out:
+ qemu_progress_end();
+
blk_unref(blk);
qemu_opts_del(opts);
qemu_opts_free(create_opts);
diff --git a/qemu-img.texi b/qemu-img.texi
index e3ef4a0..1889b5d 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -398,7 +398,7 @@ After using this command to grow a disk image, you must use
file system and
partitioning tools inside the VM to actually begin using the new space on the
device.
address@hidden amend [-f @var{fmt}] [-t @var{cache}] -o @var{options}
@var{filename}
address@hidden amend [-p] [-f @var{fmt}] [-t @var{cache}] -o @var{options}
@var{filename}
Amends the image format specific @var{options} for the image file
@var{filename}. Not all file formats support this operation.
--
1.9.3
- [Qemu-devel] [PATCH v4 0/7] block/qcow2: Improve zero cluster expansion, Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 1/7] block: Add status callback to bdrv_amend_options(), Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 2/7] qemu-img: Add progress output for amend,
Max Reitz <=
- [Qemu-devel] [PATCH v4 3/7] qemu-img: Fix insignificant memleak, Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 4/7] block/qcow2: Implement status CB for amend, Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 5/7] block/qcow2: Make get_refcount() global, Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 6/7] block/qcow2: Simplify shared L2 handling in amend, Max Reitz, 2014/10/27
- [Qemu-devel] [PATCH v4 7/7] iotests: Expand test 061, Max Reitz, 2014/10/27
- Re: [Qemu-devel] [PATCH v4 0/7] block/qcow2: Improve zero cluster expansion, Kevin Wolf, 2014/10/28
- Re: [Qemu-devel] [PATCH v4 0/7] block/qcow2: Improve zero cluster expansion, Stefan Hajnoczi, 2014/10/29