qemu: enable QEMU core dump by default on Linux

The Linux MADV_DONTDUMP flag was added to Linux kernels > 3.3,
back in 2012, and the dump-guest-core flag was added to QEMU
> 1.0 at the same time.

IOW, on Linux we have long been able to assume that QEMU core
dumps will exclude guest memory, unless the user has overridden
the host level defaults in the domain XML.

It is desirable to permit QEMU core dumps out of the box to make
it easier for users to report crashes to their OS vendor without
having to reconfigure and restart libvirt daemons and their
running guests.

While there is a risk that an admin may have set 'dump_guest_core'
to true, while leaving 'max_core' to 0, on balance the benefits
of easier troubleshooting outweigh the risk of changing the
defaults to permit core dumps.

Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-11-29 11:42:07 +00:00
parent dd217cd938
commit 57835f432f
2 changed files with 12 additions and 6 deletions

View File

@ -709,7 +709,9 @@
# As a special case it can be set to the string "unlimited" to # As a special case it can be set to the string "unlimited" to
# to allow arbitrarily sized core dumps. # to allow arbitrarily sized core dumps.
# #
# By default the core dump size is set to 0 disabling all dumps # By default the core dump size is set to unlimited on
# Linux where 'dump_guest_core' defaults to false, and
# is set to 0 on other platforms, disabling all dumps
# #
# Size is a positive integer specifying bytes or the # Size is a positive integer specifying bytes or the
# string "unlimited" # string "unlimited"
@ -717,8 +719,8 @@
#max_core = "unlimited" #max_core = "unlimited"
# Determine if guest RAM is included in QEMU core dumps. By # Determine if guest RAM is included in QEMU core dumps. By
# default guest RAM will be excluded if a new enough QEMU is # default guest RAM will be excluded on Linux platforms,
# present and host kernel supports it. Setting this to '1' will # and included on all other patforms. Setting this to '1' will
# force guest RAM to always be included in QEMU core dumps. # force guest RAM to always be included in QEMU core dumps.
# #
# This setting will be ignored if the guest XML has set the # This setting will be ignored if the guest XML has set the

View File

@ -291,10 +291,14 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
cfg->deprecationBehavior = g_strdup("none"); cfg->deprecationBehavior = g_strdup("none");
cfg->storageUseNbdkit = USE_NBDKIT_DEFAULT; cfg->storageUseNbdkit = USE_NBDKIT_DEFAULT;
#ifndef MADV_DONTDUMP #ifdef MADV_DONTDUMP
cfg->maxCore = ULLONG_MAX;
#else
/* QEMU uses Linux extensions to madvise() (MADV_DODUMP/MADV_DONTDUMP) to /* QEMU uses Linux extensions to madvise() (MADV_DODUMP/MADV_DONTDUMP) to
* include/exclude guest memory from core dump. These might be unavailable * include/exclude guest memory from core dump. On non-Linux systems
* on some systems. Provide sane default. */ * core dumps will unavoidably include all guest RAM, so toggle the
* default to reflect this and warn the admin.
*/
VIR_INFO("Host kernel doesn't support MADV_DONTDUMP. Enabling dump_guest_core"); VIR_INFO("Host kernel doesn't support MADV_DONTDUMP. Enabling dump_guest_core");
cfg->dumpGuestCore = true; cfg->dumpGuestCore = true;
#endif #endif