QEMU uses Linux extensions to madvise() to include/exclude guest
memory from core dump. These are obviously not available
everywhere. Currently, users have two options:
1) configure <memory dumpCore=''/> in domain XML, or
2) configure dump_guest_core in qemu.conf
While these work, they may harm user experience as "things just
don't work" out of the box. Provide sane default in
virQEMUDriverConfigNew() so neither of two options is required.
To have predictable results in tests, explicitly set
cfg->dumpGuestCore to false in qemuTestDriverInit() (which
creates cfg object for tests).
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/679
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
'sched.h',
'sys/auxv.h',
'sys/ioctl.h',
+ 'sys/mman.h',
'sys/mount.h',
'sys/syscall.h',
'sys/ucred.h',
# Determine if guest RAM is included in QEMU core dumps. By
# default guest RAM will be excluded if a new enough QEMU is
-# present. Setting this to '1' will force guest RAM to always
-# be included in QEMU core dumps.
+# present and host kernel supports it. 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
# dumpCore attribute on the <memory> element.
#include <unistd.h>
#include <fcntl.h>
+#ifdef WITH_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+
#include "virerror.h"
#include "qemu_conf.h"
#include "qemu_capabilities.h"
cfg->deprecationBehavior = g_strdup("none");
cfg->storageUseNbdkit = USE_NBDKIT_DEFAULT;
+#ifndef MADV_DONTDUMP
+ /* 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. */
+ VIR_INFO("Host kernel doesn't support MADV_DONTDUMP. Enabling dump_guest_core");
+ cfg->dumpGuestCore = true;
+#endif
+
return g_steal_pointer(&cfg);
}
cfg->hugetlbfs[0].deflt = true;
cfg->hugetlbfs[1].size = 1048576;
+ cfg->dumpGuestCore = false;
+
driver->privileged = true;
return 0;