qemu-block
[Top][All Lists]
Advanced

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

Re: Questions about how block devices use snapshots


From: Zhiyong Ye
Subject: Re: Questions about how block devices use snapshots
Date: Tue, 21 Feb 2023 21:27:24 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1


Hi Kevin,

Sorry to bother you again.

I intend to use this approach for snapshots of block devices, which, as you say, requires a lot of disk space to store snapshot data. So, to save disk space, after each successful external snapshot creation, I want to shrink the block device that stores the backing_file image to the size that qcow2 data actually occupies, since it has become read-only. But there is no way to get the actual size of qcow2 when it is stored in a block device.

Qemu-img info can easily get the actual size of qcow2 when it is stored in a file using the fstat function, but this will fail and return 0 for block devices. Therefore, it is necessary to implement the method of getting data occupancy inside qcow2. I think there may be two possible ways to do this:

- Add a cluster count field @nb_clusters in the BDRVQcow2State for each new cluster allocated and the actual size occupied by qcow2 is: nb_clusters * cluster_size. - Iterate through the refcount block to find the value with the largest host offset, and this is the actual size occupied by qcow2.

Since I'm not very familiar with qcow2, may I ask if you have any advice on getting the actual size when using qcow2?

Regards

Zhiyong

On 1/9/23 9:57 PM, Kevin Wolf wrote:

So a second, still very simple, approach could be taking a second block
device that is a little bit larger than the virtual disk (for the qcow2
metadata) and use that as the external snapshot. Obviously, you require
a lot of disk space this way, because each snapshots needs to be able to
store the full image.





reply via email to

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