qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jun Li <junmuzi@gmail.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, juli@redhat.com, famz@redhat.com,
	Jun Li <junmuzi@gmail.com>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 0/2] qcow2: Patch for shrinking qcow2 disk image
Date: Mon, 13 Oct 2014 13:04:02 +0800	[thread overview]
Message-ID: <1413176644-11031-1-git-send-email-junmuzi@gmail.com> (raw)

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

             reply	other threads:[~2014-10-13  5:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-13  5:04 Jun Li [this message]
2014-10-13  5:04 ` [Qemu-devel] [PATCH v3 1/2] qcow2: Add qcow2_shrink_l1_and_l2_table for qcow2 shrinking Jun Li
2014-10-14 17:58   ` Jun Li
2014-10-13  5:04 ` [Qemu-devel] [PATCH v3 2/2] qcow2: add update refcount table realization for update_refcount Jun Li
2014-10-14 17:57   ` Jun Li
2014-10-14 17:56 ` [Qemu-devel] [PATCH v3 0/2] qcow2: Patch for shrinking qcow2 disk image Jun Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413176644-11031-1-git-send-email-junmuzi@gmail.com \
    --to=junmuzi@gmail.com \
    --cc=famz@redhat.com \
    --cc=juli@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).