Am 09.01.2023 um 13:45 hat Zhiyong Ye geschrieben: > Qemu provides powerful snapshot capabilities for different file > formats. But this is limited to the block backend being a file, and > support is not good enough when it is a block device. When creating > snapshots based on files, there is no need to specify the size of the > snapshot image, which can grow dynamically as the virtual machine is > used. But block devices are fixed in size at creation and cannot be > dynamically grown at a later time. > > So is there any way to support snapshots when the block backend is a > block device?
In order to have snapshots, you need to have an image format like qcow2. A qcow2 file can have a raw block device as its backing file, so even if you store the overlay image on a filesystem, you have technically snapshotted a block device. This may or may not be enough for your use case. It is also possible to store qcow2 files on block devices, though depending on your requirements, it can get very tricky because then you're responsible for making sure that there is always enough free space on the block device. 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. You could also use internal snapshots. In this case, you just need to make sure that the block device is a lot larger than the virtual disk, so that there is enough space left for storing the snapshots. At some point it will be full. And finally, for example if your block devices are actually LVs, you could start resizing the block device dynmically as needed. This becomes very complex quickly and you're on your own, but it is possible and has been done by oVirt. Kevin