From nobody Sun Feb 8 04:02:45 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 1732881684323662.5027667718429; Fri, 29 Nov 2024 04:01:24 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 980E51975; Fri, 29 Nov 2024 07:01:23 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 165A51988; Fri, 29 Nov 2024 07:01:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 88EDC18C1; Fri, 29 Nov 2024 07:00:59 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 ACE0A18C3 for ; Fri, 29 Nov 2024 07:00:57 -0500 (EST) Received: from mx-prod-mc-01.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-116-MZHyi_0AMLytooTVmXQD6A-1; Fri, 29 Nov 2024 07:00:54 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 848F71955F43 for ; Fri, 29 Nov 2024 12:00:53 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.37]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6915D1955D45; Fri, 29 Nov 2024 12:00:52 +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.8 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,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,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=1732881657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wsF3ufEB7Av0RABYWaKXOfrpYccJHbRD2mbB8RiCR0k=; b=Z9eD95IPaL19fv+D2SNPXYnPXuV6MmvFHZKElRpj5smYdFB4WIa2jMO8EefJzWGbVKtVtY IZBEN9UdsyU+NdZ2G9NhdLGJGjYhg+/efOu+nDveKRZNzsrzgH8pInrnZeGdrGA7L6Elpq w+54h4OJz2wzX7wwTB7JZM88Z8Vh5XE= X-MC-Unique: MZHyi_0AMLytooTVmXQD6A-1 X-Mimecast-MFC-AGG-ID: MZHyi_0AMLytooTVmXQD6A From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: "Richard W . M . Jones" , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH] qemu: enable QEMU core dump by default on Linux Date: Fri, 29 Nov 2024 12:00:51 +0000 Message-ID: <20241129120051.680874-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MzTfZdez8b-QdybPiEdywxW_YrKzAvS3_yTyF2Ca8bs_1732881653 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O6JQ4WJNHW7NEIAU5AJ7QACHL6BK5RNW X-Message-ID-Hash: O6JQ4WJNHW7NEIAU5AJ7QACHL6BK5RNW X-MailFrom: berrange@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: 1732881685397019100 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Richard W.M. Jones --- src/qemu/qemu.conf.in | 8 +++++--- src/qemu/qemu_conf.c | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 89c9b6b913..d853136f10 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -709,7 +709,9 @@ # 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" @@ -717,8 +719,8 @@ #max_core =3D "unlimited" =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 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 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 7c15c521c7..8b9fe4e381 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -291,10 +291,14 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool priv= ileged, cfg->deprecationBehavior =3D g_strdup("none"); cfg->storageUseNbdkit =3D USE_NBDKIT_DEFAULT; =20 -#ifndef MADV_DONTDUMP +#ifdef MADV_DONTDUMP + cfg->maxCore =3D ULLONG_MAX; +#else /* 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. */ + * 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_gue= st_core"); cfg->dumpGuestCore =3D true; #endif --=20 2.46.0