From patchwork Thu Oct 11 21:27:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 191008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 107E32C0083 for ; Fri, 12 Oct 2012 08:46:51 +1100 (EST) Received: from localhost ([::1]:33394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQHf-0001LO-80 for incoming@patchwork.ozlabs.org; Thu, 11 Oct 2012 17:27:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQGq-0007dV-5U for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMQGo-0005Uz-V8 for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQGo-0005Uc-Lp for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9BLQHFN018585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Oct 2012 17:26:18 -0400 Received: from localhost (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9BLQG74032564; Thu, 11 Oct 2012 17:26:17 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 11 Oct 2012 18:27:01 -0300 Message-Id: <1349990825-2659-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1349990825-2659-1-git-send-email-lcapitulino@redhat.com> References: <1349990825-2659-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [RFC 3/7] block: bdrv_img_create(): move param printing to qemu-img X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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;