From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L4hu9-00069v-DE for qemu-devel@nongnu.org; Mon, 24 Nov 2008 15:19:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L4hu7-00068M-RW for qemu-devel@nongnu.org; Mon, 24 Nov 2008 15:19:32 -0500 Received: from [199.232.76.173] (port=57316 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4hu7-00068E-Cb for qemu-devel@nongnu.org; Mon, 24 Nov 2008 15:19:31 -0500 Received: from mx2.redhat.com ([66.187.237.31]:51305) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L4hu6-0001sk-Pw for qemu-devel@nongnu.org; Mon, 24 Nov 2008 15:19:31 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mAOKJTPB006741 for ; Mon, 24 Nov 2008 15:19:29 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAOKJTa6032167 for ; Mon, 24 Nov 2008 15:19:29 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mAOKJSpl003635 for ; Mon, 24 Nov 2008 15:19:28 -0500 Date: Mon, 24 Nov 2008 22:19:42 +0200 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCH 5/5] Change order of metadata update to prevent loosing guest data because of unexpected exit. Message-ID: <20081124201941.GE3482@redhat.com> References: <20081123145248.22178.36228.stgit@dhcp-1-237.tlv.redhat.com> <20081123145326.22178.36990.stgit@dhcp-1-237.tlv.redhat.com> <492ADB2A.7030700@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <492ADB2A.7030700@codemonkey.ws> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Mon, Nov 24, 2008 at 10:49:46AM -0600, Anthony Liguori wrote: >> diff --git a/block-qcow2.c b/block-qcow2.c >> index 0771281..c600517 100644 >> --- a/block-qcow2.c >> +++ b/block-qcow2.c >> @@ -852,6 +852,69 @@ static uint64_t alloc_compressed_cluster_offset(BlockDriverState *bs, >> return cluster_offset; >> } >> +typedef struct QCowL2Meta >> +{ >> + uint64_t offset; >> + int n_start; >> + int nb_available; >> + int nb_clusters; >> +} QCowL2Meta; >> + >> +static int alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset, >> + QCowL2Meta *m) >> +{ >> + BDRVQcowState *s = bs->opaque; >> + int i, j = 0, l2_index, ret; >> + uint64_t *old_cluster, start_sect, l2_offset, *l2_table; >> + >> + if (m->nb_clusters == 0) >> + return 0; >> + >> + if (!(old_cluster = qemu_malloc(m->nb_clusters * sizeof(uint64_t)))) >> + return -ENOMEM; >> > > This memory is never freed. > I swear there was free() there! Well, it probably fell a victim to one of the rewrites :) -- Gleb.