action #40538
open
Reset/Clear guest RAM when it reboots in QEMU to reduce RAM snapshot size
Added by rpalethorpe about 6 years ago.
Updated over 4 years ago.
Category:
Feature requests
Description
During installation 4GB+ of RAM can be used by the guest. Most of the time the RAM usage is much lower than this.
After installation completes the system is rebooted and then a snapshot is taken. In theory the snapshot should be very small because the system has only just booted, however it appears that QEMU thinks all the RAM is still in use and saves it to the snapshot. This might not be unexpected because on bare metal the RAM is preserved between reboots on modern systems. However, assuming that it is not relied upon by the guest OS, we don't need it to happen and can save some time.
Some ideas to solve this:
- Use the virtio memory balloon
- Use the -no-reboot switch and restart the QEMU process if it exits unexpectedly.
- Patch QEMU to clear (some of) the RAM when the guest initiates a reboot.
Related issues
1 (1 open — 0 closed)
What about to drop disk caches in VM before taking snapshot? something like:
sync; sync
echo 3 > /proc/sys/vm/drop_caches
- Status changed from New to In Progress
I think the virtio-balloon driver can force the kernel to reclaim that memory. Although I suppose dropping the caches would be quicker.
Anyhoo I have implemented ballooning and it seems to work to some extent, please see the bugzilla entry and https://github.com/os-autoinst/os-autoinst/pull/1020
Also from the bugzilla thread:
Alexander Graf from comment #19
QEMU's RAM migration code treats all-0 pages special, so maybe it's enough to just make as many pages as we can contain all zeros?
For that, it should be enough to do something like
$ dd if=/dev/zero of=/dev/null bs=4G count=1
and wait for it to crash ;). Or the slightly nicer way might be to run
$ dd if=/dev/zero of=/dev/garbage bs=1M; rm -f /dev/garbage
which however will be limited by the /dev tmpfs size.
- Status changed from In Progress to Workable
I am reasonably happy with ballooning for now, although it doesn't seem to work perfectly. However the PR needs reviewing and merging.
- Category set to Feature requests
- Related to action #59109: use ballooning to improve snapshot performance added
- Priority changed from Normal to Low
- Target version set to future
- Subject changed from [tools] Reset/Clear guest RAM when it reboots in QEMU to reduce RAM snapshot size to Reset/Clear guest RAM when it reboots in QEMU to reduce RAM snapshot size
Not currently on the backlog of "QA tools team"
Also available in: Atom
PDF