From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu0wa-0004co-2z for qemu-devel@nongnu.org; Fri, 20 Dec 2013 09:20:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu0wR-0006nG-M5 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 09:20:48 -0500 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:48104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu0wR-0006n3-5e for qemu-devel@nongnu.org; Fri, 20 Dec 2013 09:20:39 -0500 Received: by mail-wi0-f181.google.com with SMTP id hq4so3740759wib.2 for ; Fri, 20 Dec 2013 06:20:38 -0800 (PST) Date: Fri, 20 Dec 2013 15:20:34 +0100 From: Stefan Hajnoczi Message-ID: <20131220142034.GB9296@stefanha-thinkpad.redhat.com> References: <1386244972-528-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1386244972-528-5-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: <1386244972-528-5-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH V7 4/6] 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, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com On Thu, Dec 05, 2013 at 08:02:50PM +0800, Wenchao Xia wrote: > +restore_refcount: > + if (qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, -1) > + < 0 && errp) { > + /* Nothing can be done now, need image check later */ > + error_setg(&err, "%s\nqcow2: Error in restoring refcount in snapshot", > + error_get_pretty(*errp)); > + error_free(*errp); > + *errp = NULL; > + error_propagate(errp, err); > + } We get here if writing the new snapshot list failed. If qcow2_update_snapshot_refcount(..., -1) also fails I think we should skip qcow2_free_clusters() below. We don't know the exact state of the disk image anymore - better to leak clusters than to have a dangling reference. > +dealloc_cluster: > + qcow2_free_clusters(bs, sn->l1_table_offset, > + sn->l1_size * sizeof(uint64_t), > + QCOW2_DISCARD_ALWAYS); > + > fail: > g_free(sn->id_str); > g_free(sn->name); > -- > 1.7.1 > >