From patchwork Fri Mar 22 13:16:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 230012 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 94AFC2C00AC for ; Sat, 23 Mar 2013 00:18:34 +1100 (EST) Received: from localhost ([::1]:36357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ1rc-0007jq-NH for incoming@patchwork.ozlabs.org; Fri, 22 Mar 2013 09:18:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ1pY-0004ro-78 for qemu-devel@nongnu.org; Fri, 22 Mar 2013 09:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ1pT-00086F-Em for qemu-devel@nongnu.org; Fri, 22 Mar 2013 09:16:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ1pT-000867-5v for qemu-devel@nongnu.org; Fri, 22 Mar 2013 09:16:19 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2MDGIYd000847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Mar 2013 09:16:18 -0400 Received: from localhost.localdomain.com (vpn1-5-126.ams2.redhat.com [10.36.5.126]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2MDGBBd008641; Fri, 22 Mar 2013 09:16:17 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2013 14:16:01 +0100 Message-Id: <56e4cc47636aba23bddc2bfe14e7d7dd33a4de39.1363957855.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Pavel Hrdina , armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v2 02/12] block: add error parameter to del_existing_snapshots() 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 Signed-off-by: Pavel Hrdina Reviewed-by: Eric Blake --- savevm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/savevm.c b/savevm.c index fadde55..7b1867b 100644 --- a/savevm.c +++ b/savevm.c @@ -2110,7 +2110,7 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, /* * Deletes snapshots of a given name in all opened images. */ -static int del_existing_snapshots(Monitor *mon, const char *name) +static int del_existing_snapshots(const char *name, Error **errp) { BlockDriverState *bs; QEMUSnapshotInfo sn1, *snapshot = &sn1; @@ -2123,9 +2123,8 @@ static int del_existing_snapshots(Monitor *mon, const char *name) { ret = bdrv_snapshot_delete(bs, name); if (ret < 0) { - monitor_printf(mon, - "Error while deleting snapshot on '%s'\n", - bdrv_get_device_name(bs)); + error_setg(errp, "Error while deleting snapshot on '%s'", + bdrv_get_device_name(bs)); return -1; } } @@ -2145,6 +2144,7 @@ void do_savevm(Monitor *mon, const QDict *qdict) qemu_timeval tv; struct tm tm; const char *name = qdict_get_try_str(qdict, "name"); + Error *local_err = NULL; /* Verify if there is a device that doesn't support snapshots and is writable */ bs = NULL; @@ -2193,7 +2193,9 @@ void do_savevm(Monitor *mon, const QDict *qdict) } /* Delete old snapshots of the same name */ - if (name && del_existing_snapshots(mon, name) < 0) { + if (name && del_existing_snapshots(name, &local_err) < 0) { + monitor_printf(mon, "%s\n", error_get_pretty(local_err)); + error_free(local_err); goto the_end; }