From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xe6LK-0002Ya-Mb for qemu-devel@nongnu.org; Tue, 14 Oct 2014 13:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xe6L9-0000P1-3F for qemu-devel@nongnu.org; Tue, 14 Oct 2014 13:57:06 -0400 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]:61153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xe6L8-0000OE-R4 for qemu-devel@nongnu.org; Tue, 14 Oct 2014 13:56:55 -0400 Received: by mail-pd0-f181.google.com with SMTP id z10so7983521pdj.12 for ; Tue, 14 Oct 2014 10:56:53 -0700 (PDT) Date: Wed, 15 Oct 2014 01:56:47 +0800 From: Jun Li Message-ID: <20141014175647.GA17845@localhost.localdomain> References: <1413176644-11031-1-git-send-email-junmuzi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1413176644-11031-1-git-send-email-junmuzi@gmail.com> Subject: Re: [Qemu-devel] [PATCH v3 0/2] qcow2: Patch for shrinking qcow2 disk image List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, juli@redhat.com, famz@redhat.com, stefanha@redhat.com Please ignore this patch, I have submit a new version. On Mon, 10/13 13:04, Jun Li wrote: > This is the third version for qcow2 shrinking. In this version, fixed host > cluster leak when shrinking a disk image. Such as: > Step 1, > # /opt/qemu-git-arm/bin/qemu-img info /home/lijun/Work/tmp/shrink.qcow2 > image: /home/lijun/Work/tmp/shrink.qcow2 > file format: qcow2 > virtual size: 2.0G (2147483648 bytes) > disk size: 2.0G > cluster_size: 65536 > Format specific information: > compat: 1.1 > lazy refcounts: false > corrupt: false > > Step 2, > # /opt/qemu-git-arm/bin/qemu-img resize /home/lijun/Work/tmp/shrink.qcow2 -100M > Image resized. > > Step 3, > # /opt/qemu-git-arm/bin/qemu-img info /home/lijun/Work/tmp/shrink.qcow2 > image: /home/lijun/Work/tmp/shrink.qcow2 > file format: qcow2 > virtual size: 1.9G (2042626048 bytes) > disk size: 1.9G > cluster_size: 65536 > Format specific information: > compat: 1.1 > lazy refcounts: false > corrupt: false > > Step 4, > # /opt/qemu-git-arm/bin/qemu-img check /home/lijun/Work/tmp/shrink.qcow2 > No errors were found on the image. > 31005/31168 = 99.48% allocated, 0.79% fragmented, 0.00% compressed clusters > Image end offset: 2033844224 > > As above show, in step 1, "disk size" and "virtual size" are all 2.0G. > After Step 3, "disk size" and "virtual size" are all 1.9G. > > BTW, above is also a simple testing. I will submit a test case for > qemu-iotests later. But I am not so familar with howto write qemu-iotests now. > > In file block/qcow2.c, just using ftruncate to fix host cluster leak. > > In file block/qcow2-cluster.c, just re-copy qcow2_grow_l1_table to > realize qcow2_shrink_l1_and_l2_table. > > In file block/qcow2-refcount.c, also update the realization to handle self-describing > refcount blocks in function update_refcount. > > Thanks. > > > Jun Li (2): > qcow2: Add qcow2_shrink_l1_and_l2_table for qcow2 shrinking > qcow2: add update refcount table realization for update_refcount > > block/qcow2-cluster.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++ > block/qcow2-refcount.c | 44 +++++++++++++ > block/qcow2.c | 40 ++++++++++-- > block/qcow2.h | 2 + > 4 files changed, 255 insertions(+), 4 deletions(-) > > -- > 1.9.3 >