From nobody Mon Feb 9 09:39:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726746343797274.11257396994984; Thu, 19 Sep 2024 04:45:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 85DCC1511; Thu, 19 Sep 2024 07:45:42 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 359851576; Thu, 19 Sep 2024 07:44:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7E85014D9; Thu, 19 Sep 2024 07:44:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F2DF314D6 for ; Thu, 19 Sep 2024 07:44:42 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-y5aHs0coMEum2ug_RDgoOg-1; Thu, 19 Sep 2024 07:44:41 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E3771955F40 for ; Thu, 19 Sep 2024 11:44:40 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EF60830001A1 for ; Thu, 19 Sep 2024 11:44:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726746282; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dYp6i0xiTpHBp2w8D12ewzFP/GfjE0VsqsjmGpPjrzY=; b=BBfJmA+KWMhPhTDMK+gXdJqGXr+jeQfkWRC4APe6ERZ8rC910W4f2/JXz1RDnCkV2FL7TE tGInC6mlBAPIO1AwDc+TOz6bwIzfCbz6o18gEI/BDTIb3GP53bsQQxckVMDN4x8imitZfL csOWZW/MYaQv0e6wEF331duHhFhND4s= X-MC-Unique: y5aHs0coMEum2ug_RDgoOg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH v2 2/2] qemu: Provide sane default for dump_guest_core Date: Thu, 19 Sep 2024 13:44:35 +0200 Message-ID: <74ec6f1e3aecd66414bba7384543a8cd10296b8b.1726746177.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YMRSFQTGVTGYRPCP5AHYERCR4NYF6UTF X-Message-ID-Hash: YMRSFQTGVTGYRPCP5AHYERCR4NYF6UTF X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726746344269116600 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 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 --- meson.build | 1 + src/qemu/qemu.conf.in | 4 ++-- src/qemu/qemu_conf.c | 12 ++++++++++++ tests/testutilsqemu.c | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 4c6e5a088e..aa6b8ce5aa 100644 --- a/meson.build +++ b/meson.build @@ -676,6 +676,7 @@ headers =3D [ 'sched.h', 'sys/auxv.h', 'sys/ioctl.h', + 'sys/mman.h', 'sys/mount.h', 'sys/syscall.h', 'sys/ucred.h', diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index e1f3046177..59af58b4d4 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -710,8 +710,8 @@ =20 # 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 element. diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b36bede6c3..0f09e22730 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -26,6 +26,10 @@ #include #include =20 +#ifdef WITH_SYS_MMAN_H +# include +#endif + #include "virerror.h" #include "qemu_conf.h" #include "qemu_capabilities.h" @@ -287,6 +291,14 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privi= leged, cfg->deprecationBehavior =3D g_strdup("none"); cfg->storageUseNbdkit =3D USE_NBDKIT_DEFAULT; =20 +#ifndef MADV_DONTDUMP + /* QEMU uses Linux extensions to madvise() (MADV_DODUMP/MADV_DONTDUMP)= to + * include/exclude guest memory from core dump. These might be unavail= able + * on some systems. Provide sane default. */ + VIR_INFO("Host kernel doesn't support MADV_DONTDUMP. Enabling dump_gue= st_core"); + cfg->dumpGuestCore =3D true; +#endif + return g_steal_pointer(&cfg); } =20 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index ee6cae218a..4daee432e5 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -407,6 +407,8 @@ int qemuTestDriverInit(virQEMUDriver *driver) cfg->hugetlbfs[0].deflt =3D true; cfg->hugetlbfs[1].size =3D 1048576; =20 + cfg->dumpGuestCore =3D false; + driver->privileged =3D true; =20 return 0; --=20 2.44.2