Project

General

Profile

Actions

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.

Status:
Workable
Priority:
Low
Assignee:
-
Category:
Feature requests
Target version:
Start date:
2018-09-03
Due date:
% Done:

0%

Estimated time:

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 open0 closed)

Related to openQA Project - action #59109: use ballooning to improve snapshot performanceNew2019-11-05

Actions
Actions #2

Updated by thehejik about 6 years ago

What about to drop disk caches in VM before taking snapshot? something like:

sync; sync
echo 3 > /proc/sys/vm/drop_caches

Actions #3

Updated by rpalethorpe about 6 years ago

  • 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

Actions #4

Updated by rpalethorpe about 6 years ago

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.

Actions #5

Updated by rpalethorpe about 6 years ago

  • 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.

Actions #6

Updated by okurz over 5 years ago

  • Category set to Feature requests
Actions #7

Updated by okurz about 5 years ago

  • Related to action #59109: use ballooning to improve snapshot performance added
Actions #8

Updated by okurz over 4 years ago

  • Priority changed from Normal to Low
  • Target version set to future
Actions #9

Updated by okurz over 4 years ago

  • 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"

Actions

Also available in: Atom PDF