]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: enable QEMU core dump by default on Linux
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 29 Nov 2024 11:42:07 +0000 (11:42 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 5 Dec 2024 09:42:37 +0000 (09:42 +0000)
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>
src/qemu/qemu.conf.in
src/qemu/qemu_conf.c

index 89c9b6b913c1fcceed0571e5729e9db83d1677a8..d853136f102c116f6e4c449b99202eb4bb0f98f2 100644 (file)
 # As a special case it can be set to the string "unlimited" to
 # 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
 # string "unlimited"
 #max_core = "unlimited"
 
 # Determine if guest RAM is included in QEMU core dumps. By
-# default guest RAM will be excluded if a new enough QEMU is
-# present and host kernel supports it. Setting this to '1' will
+# default guest RAM will be excluded on Linux platforms,
+# and included on all other patforms. Setting this to '1' will
 # force guest RAM to always be included in QEMU core dumps.
 #
 # This setting will be ignored if the guest XML has set the
index 7c15c521c73ae640e36d8caf1cac066d98fa6591..8b9fe4e381103a3829b66e2f936da4708570140a 100644 (file)
@@ -291,10 +291,14 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
     cfg->deprecationBehavior = g_strdup("none");
     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
-     * include/exclude guest memory from core dump. These might be unavailable
-     * on some systems. Provide sane default. */
+     * include/exclude guest memory from core dump. On non-Linux systems
+     * 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");
     cfg->dumpGuestCore = true;
 #endif