[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] The image size of instance VM keeps growing

From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] The image size of instance VM keeps growing
Date: Fri, 25 May 2012 12:36:53 +0100

On Thu, May 24, 2012 at 11:40 AM, Charles.Tsai-蔡清海-研究發展部
<address@hidden> wrote:
> Stefan,
>        Can you explain why a 64KB could be allocated for each sector write?

The default cluster size in qcow2 is 64 KB.  qcow2 manages space in 64
KB pieces.  Therefore, when you write to a region of the image that
has not been allocated yet, you incur the cost of allocating a new 64
KB cluster.

>        Right now, I am testing a VM with 8G virtual disk space.
>        The disk only has 12.6 MB free space left when I run the test.
>        I am going to see what will happen in this test case.

How much space is free on the file system inside the disk image has
nothing to do with the growth of the qcow2 image file on the host.

When you using a backing file in qocw2 you start like this:

backing.img <-- vm.qcow2 (empty)

The qcow2 file is empty, it should be very small (<1 MB) when you boot
the guest for the first time.

Now that the guest is running, every disk write does the following:

if this 64 KB cluster in the VM disk has not been touched yet:
    allocate the 64 KB cluster and write the data (the image file
grows by 64 KB)
    write the data in-place because we already have a cluster (no
allocation necessary and the image file does not grow)

The important thing to understand is that "has this cluster been
touched?" means "have we written to this cluster in vm.qcow2
previously?".  When you start the guest for the first time vm.qcow2 is
empty, so the first write is guaranteed to allocate a cluster
(remember we never write into the backing file, so we need to write
into vm.qcow2).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]