From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuZk-0003Up-9O for qemu-devel@nongnu.org; Thu, 16 May 2013 05:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcuZf-00039m-3p for qemu-devel@nongnu.org; Thu, 16 May 2013 05:34:16 -0400 Received: from mail-bk0-x22e.google.com ([2a00:1450:4008:c01::22e]:63389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuZe-00039Y-Sn for qemu-devel@nongnu.org; Thu, 16 May 2013 05:34:11 -0400 Received: by mail-bk0-f46.google.com with SMTP id my1so1558831bkb.33 for ; Thu, 16 May 2013 02:34:10 -0700 (PDT) Date: Thu, 16 May 2013 11:34:07 +0200 From: Stefan Hajnoczi Message-ID: <20130516093407.GC8853@stefanha-thinkpad.redhat.com> References: <1368607419-15178-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1368607419-15178-2-git-send-email-xiawenc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368607419-15178-2-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 2/2] qcow2: cancel the modification on fail in qcow2_snapshot_create() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org On Wed, May 15, 2013 at 04:43:39PM +0800, Wenchao Xia wrote: > Signed-off-by: Wenchao Xia > --- > block/qcow2-snapshot.c | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c > index a6065a9..ad030f9 100644 > --- a/block/qcow2-snapshot.c > +++ b/block/qcow2-snapshot.c > @@ -410,6 +410,17 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) > #endif > return 0; > > +restore_refcount: > + ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, > + s->l1_size, -1); > + if (ret < 0) { > + /* Nothing can be done none now, need image check later */ > + error_report("qcow2: Error in restoring refcount in snapshot"); > + } > + > +dealloc_cluster: > + qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size); > + > fail: > g_free(sn->id_str); > g_free(sn->name); This patch is missing goto restore_refcount and goto dealloc_cluster.