From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPYaJ-0002AW-Qx for qemu-devel@nongnu.org; Tue, 09 Apr 2013 09:27:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPYaE-0000W7-Ut for qemu-devel@nongnu.org; Tue, 09 Apr 2013 09:27:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPYaE-0000Vz-MB for qemu-devel@nongnu.org; Tue, 09 Apr 2013 09:27:34 -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 r39DRY7O008524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Apr 2013 09:27:34 -0400 From: Markus Armbruster References: <451dff8502328bfb24afa139cbdfeeebc60d3e67.1364565637.git.phrdina@redhat.com> Date: Tue, 09 Apr 2013 15:27:32 +0200 In-Reply-To: <451dff8502328bfb24afa139cbdfeeebc60d3e67.1364565637.git.phrdina@redhat.com> (Pavel Hrdina's message of "Fri, 29 Mar 2013 15:12:29 +0100") Message-ID: <87mwt7debf.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 02/11] block: add error parameter to del_existing_snapshots() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Pavel Hrdina writes: > 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 77c5291..dc1f4a4 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -2224,7 +2224,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; > @@ -2237,9 +2237,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; > } > } Any particular reason for de-capitalizing "Error"? > @@ -2259,6 +2258,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; > @@ -2307,7 +2307,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; > } Could use hmp_handle_error(), except it's static in hmp.c. On the other hand, even hmp.c doesn't always use it... Luiz, what do you think?