[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 3/7] block: bdrv_img_create(): move param printing to
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [RFC 3/7] block: bdrv_img_create(): move param printing to qemu-img |
Date: |
Thu, 11 Oct 2012 18:27:01 -0300 |
bdrv_img_create() is being used by the transaction QMP command and
therefore shouldn't print directly to the user.
Move the param printing to qemu-img instead. Has the side effect of
only printing it when the bdrv_img_create() call succeeds, otherwise
we can print errors before the action being taken, eg:
~/work/virt/ ./qemu-img create -f qcow2 /foo/foo 10G
qemu-img: /foo/foo: error while creating qcow2: No such file or directory
Formatting '/foo/foo', fmt=qcow2 size=10737418240 encryption=off
cluster_size=65536 lazy_refcounts=off
Signed-off-by: Luiz Capitulino <address@hidden>
---
block.c | 4 ----
qemu-img.c | 10 +++++++++-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 13cf04d..235423e 100644
--- a/block.c
+++ b/block.c
@@ -4411,10 +4411,6 @@ int bdrv_img_create(const char *filename, const char
*fmt,
}
}
- printf("Formatting '%s', fmt=%s ", filename, fmt);
- print_option_parameters(param);
- puts("");
-
ret = bdrv_create(drv, filename, param);
if (ret < 0) {
diff --git a/qemu-img.c b/qemu-img.c
index b841012..ac66459 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -301,6 +301,7 @@ static int img_create(int argc, char **argv)
const char *filename;
const char *base_filename = NULL;
char *options = NULL;
+ QEMUOptionParameter *params = NULL;
for(;;) {
c = getopt(argc, argv, "F:b:f:he6o:");
@@ -362,7 +363,14 @@ static int img_create(int argc, char **argv)
}
ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
- options, img_size, BDRV_O_FLAGS, NULL);
+ options, img_size, BDRV_O_FLAGS, ¶ms);
+ if (ret == 0 && params) {
+ printf("Formatting '%s', fmt=%s ", filename, fmt);
+ print_option_parameters(params);
+ free_option_parameters(params);
+ puts("");
+ }
+
out:
if (ret) {
return 1;
--
1.7.12.315.g682ce8b
- [Qemu-devel] [RFC 0/7] block: bdrv_img_create(): propagate errors, Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 1/7] error: add error_set_errno and error_setg_errno, Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 2/7] block: bdrv_img_create(): add param_ret argument, Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 3/7] block: bdrv_img_create(): move param printing to qemu-img,
Luiz Capitulino <=
- [Qemu-devel] [RFC 5/7] qemu-img: img_create(): use Error object, Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 4/7] block: bdrv_img_create(): add Error ** argument, Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 6/7] qmp: qmp_transaction(): pass Error object to bdrv_img_create(), Luiz Capitulino, 2012/10/11
- [Qemu-devel] [RFC 7/7] block: bdrv_img_create(): drop unused code, Luiz Capitulino, 2012/10/11
- Re: [Qemu-devel] [RFC 0/7] block: bdrv_img_create(): propagate errors, Paolo Bonzini, 2012/10/12