From patchwork Wed Jan 13 15:43:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 567030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0A7261402DE for ; Thu, 14 Jan 2016 02:58:19 +1100 (AEDT) Received: from localhost ([::1]:37831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJNoO-0008C0-QA for incoming@patchwork.ozlabs.org; Wed, 13 Jan 2016 10:58:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJNaR-00047U-T0 for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJNaQ-0001Ac-En for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJNaQ-0001AE-7t for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:50 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D4075368E3 for ; Wed, 13 Jan 2016 15:43:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-28.phx2.redhat.com [10.3.113.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0DFhkut014351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 13 Jan 2016 10:43:49 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B02A13004F95; Wed, 13 Jan 2016 16:43:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 13 Jan 2016 16:43:28 +0100 Message-Id: <1452699819-26608-31-git-send-email-armbru@redhat.com> In-Reply-To: <1452699819-26608-1-git-send-email-armbru@redhat.com> References: <1452699819-26608-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 30/41] migration: Use error_reportf_err() instead of monitor_printf() 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 Both error_reportf_err() and monitor_printf() print to the same destination when monitor_printf() is used correctly, i.e. within an HMP monitor. Elsewhere, monitor_printf() does nothing, while error_reportf_err() reports to stderr. Both changed functions are HMP command handlers. These should only run within an HMP monitor. Unlike monitor_printf(), error_reportf_err() uses the error whole instead of just its message obtained with error_get_pretty(). This avoids suppressing its hint (see commit 50b7b00), but I don't think the errors touched in this commit can come with hints. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1450452927-8346-15-git-send-email-armbru@redhat.com> --- migration/savevm.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index e277b72..bcaeb70 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1927,10 +1927,9 @@ void hmp_savevm(Monitor *mon, const QDict *qdict) /* Delete old snapshots of the same name */ if (name && bdrv_all_delete_snapshot(name, &bs1, &local_err) < 0) { - monitor_printf(mon, - "Error while deleting snapshot on device '%s': %s\n", - bdrv_get_device_name(bs1), error_get_pretty(local_err)); - error_free(local_err); + error_reportf_err(local_err, + "Error while deleting snapshot on device '%s': ", + bdrv_get_device_name(bs1)); return; } @@ -2108,10 +2107,9 @@ void hmp_delvm(Monitor *mon, const QDict *qdict) const char *name = qdict_get_str(qdict, "name"); if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) { - monitor_printf(mon, - "Error while deleting snapshot on device '%s': %s\n", - bdrv_get_device_name(bs), error_get_pretty(err)); - error_free(err); + error_reportf_err(err, + "Error while deleting snapshot on device '%s': ", + bdrv_get_device_name(bs)); } }