diff options
author | Jason Baron <jbaron@redhat.com> | 2012-08-02 15:44:16 -0400 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-08-16 13:41:15 -0500 |
commit | ddb97f1debbb6be8d871f3b565f7b8befebf0f4f (patch) | |
tree | a81ce727e2c5f9d058d156b0754bdbaaafd00d25 /exec.c | |
parent | 3c4a4d0dcbf4269e125f92df06816db1c1e86d20 (diff) | |
download | qemu-ddb97f1debbb6be8d871f3b565f7b8befebf0f4f.zip qemu-ddb97f1debbb6be8d871f3b565f7b8befebf0f4f.tar.gz qemu-ddb97f1debbb6be8d871f3b565f7b8befebf0f4f.tar.bz2 |
memory: add -machine dump-guest-core=on|off
Add a new '[,dump-guest-core=on|off]' option to the '-machine' option. When
'dump-guest-core=off' is specified, guest memory is omitted from the core dump.
The default behavior continues to be to include guest memory when a core dump is
triggered. In my testing, this brought the core dump size down from 384MB to 6MB
on a 2GB guest.
Is anything additional required to preserve this setting for migration or
savevm? I don't believe so.
Changelog:
v3:
Eliminate globals as per Anthony's suggestion
set no dump from qemu_ram_remap() as well
v2:
move the option from -m to -machine, rename option dump -> dump-guest-core
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -2475,6 +2475,24 @@ static ram_addr_t last_ram_offset(void) return last; } +static void qemu_ram_setup_dump(void *addr, ram_addr_t size) +{ + int ret; + QemuOpts *machine_opts; + + /* Use MADV_DONTDUMP, if user doesn't want the guest memory in the core */ + machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (machine_opts && + !qemu_opt_get_bool(machine_opts, "dump-guest-core", true)) { + ret = qemu_madvise(addr, size, QEMU_MADV_DONTDUMP); + if (ret) { + perror("qemu_madvise"); + fprintf(stderr, "madvise doesn't support MADV_DONTDUMP, " + "but dump_guest_core=off specified\n"); + } + } +} + void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) { RAMBlock *new_block, *block; @@ -2554,6 +2572,8 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, 0, size >> TARGET_PAGE_BITS); cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff); + qemu_ram_setup_dump(new_block->host, size); + if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); @@ -2670,6 +2690,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) exit(1); } qemu_madvise(vaddr, length, QEMU_MADV_MERGEABLE); + qemu_ram_setup_dump(vaddr, length); } return; } |