From nobody Wed Mar 12 12:57:09 2025 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 1741257083041505.1567942215796; Thu, 6 Mar 2025 02:31:23 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3A68C1653; Thu, 6 Mar 2025 05:31:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C853C1521; Thu, 6 Mar 2025 05:31:01 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 82F9C1253; Thu, 6 Mar 2025 05:30:58 -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 C455011AA for ; Thu, 6 Mar 2025 05:30:57 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-Ns5ctc4JNYez1s6icczMZg-1; Thu, 06 Mar 2025 05:30:56 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6CFE2180AF4D for ; Thu, 6 Mar 2025 10:30:55 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 79FEA1955F2D; Thu, 6 Mar 2025 10:30:54 +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_H2,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=1741257057; 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: in-reply-to:in-reply-to:references:references; bh=H+aXPLk4RGo57tXFHNZGVzphs82UKIcl84UcVInATm0=; b=gwEELM8Xx9fTJTt/MXaOCmHbuGHZam6Ih83RyM6dMgfPUO6FdvfPfqmhxAJUPNpNQuLm6K 3jo+L7RtnXTfw7PdsaXHgJzeVBEOM2OHv8KCYxan+X1bLLkC49puUXLizjqjMxwMsDdmMV c3dO6Oz9I0r55Sm+yw/lutb9HIIkADc= X-MC-Unique: Ns5ctc4JNYez1s6icczMZg-1 X-Mimecast-MFC-AGG-ID: Ns5ctc4JNYez1s6icczMZg_1741257055 From: Kirill Shchetiniuk To: devel@lists.libvirt.org Subject: [PATCH 1/2] ch: memory (segmentation fault) fix Date: Thu, 6 Mar 2025 11:27:07 +0100 Message-ID: <20250306103021.363175-2-kshcheti@redhat.com> In-Reply-To: <20250306103021.363175-1-kshcheti@redhat.com> References: <20250306103021.363175-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: H0JplS-HTfOObMyqpUOp4eq_7x5JSdfICGH5jlidC2M_1741257055 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: F43P4JOYPKEXUC7LLQ3YY7RVOTAVXJWF X-Message-ID-Hash: F43P4JOYPKEXUC7LLQ3YY7RVOTAVXJWF X-MailFrom: kshcheti@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 CC: Kirill Shchetiniuk 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: 1741257084706019000 Content-Type: text/plain; charset="utf-8"; x-default="true" Move monitor object unreference from virCHStartEventHandler to virCHEventHandlerLoop. Put VM unreference after debug print in virCHEventHandlerLoop. Signed-off-by: Kirill Shchetiniuk --- src/ch/ch_events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 1cce30836a..20e7fbd705 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -286,9 +286,10 @@ virCHEventHandlerLoop(void *data) } } =20 - g_clear_pointer(&mon->event_buffer.buffer, g_free); - virObjectUnref(vm); + g_clear_pointer(&(mon->event_buffer.buffer), g_free); VIR_DEBUG("%s: Event handler loop thread exiting", vm->def->name); + virObjectUnref(vm); + virObjectUnref(mon); return; } =20 @@ -308,7 +309,6 @@ virCHStartEventHandler(virCHMonitor *mon) virObjectUnref(mon); return -1; } - virObjectUnref(mon); =20 g_atomic_int_set(&mon->event_handler_stop, 0); return 0; --=20 2.48.1 From nobody Wed Mar 12 12:57:09 2025 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 1741257111312794.2429579612475; Thu, 6 Mar 2025 02:31:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5221111D7; Thu, 6 Mar 2025 05:31:50 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 68E6411AA; Thu, 6 Mar 2025 05:31:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id ECE6F1651; Thu, 6 Mar 2025 05:31:21 -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 65A17A11 for ; Thu, 6 Mar 2025 05:31:16 -0500 (EST) Received: from mx-prod-mc-05.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-628-s_-_WzSIM4q8GYgMDoQ0dA-1; Thu, 06 Mar 2025 05:31:10 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAAD21954B19 for ; Thu, 6 Mar 2025 10:31:06 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B8AE6195609D; Thu, 6 Mar 2025 10:31:05 +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_H2,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=1741257076; 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: in-reply-to:in-reply-to:references:references; bh=hqzy9Hbmy64gJYnpmdtbUfwcejySfGGGhq8WGNy6knM=; b=e1ZzorInuvGyIlJFpULOxyGZ9fK7K3BVGyjygkmBoNoxJtAPh+q8mGAcD+foKsJvjxk3Jt m8vefnponDHkNeaDwVnOPpKWNefjVk7sB2XhOnS8HT0pMesX3CquA/D4OQ5GwcYw7GN2sr UreIqzlxOL6T1XySLT8a9uoWb+a7Ma8= X-MC-Unique: s_-_WzSIM4q8GYgMDoQ0dA-1 X-Mimecast-MFC-AGG-ID: s_-_WzSIM4q8GYgMDoQ0dA_1741257066 From: Kirill Shchetiniuk To: devel@lists.libvirt.org Subject: [PATCH 2/2] ch: preserve last error before stop fix Date: Thu, 6 Mar 2025 11:27:08 +0100 Message-ID: <20250306103021.363175-3-kshcheti@redhat.com> In-Reply-To: <20250306103021.363175-1-kshcheti@redhat.com> References: <20250306103021.363175-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sTQh65yMGN0VkRVxRZVYGqNvRDZN_L5an_-wLtUVeYI_1741257066 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5GJVJD77F5JZ7D2DP6N7HMEBQSXD6OHA X-Message-ID-Hash: 5GJVJD77F5JZ7D2DP6N7HMEBQSXD6OHA X-MailFrom: kshcheti@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 CC: Kirill Shchetiniuk 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: 1741257112373019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Add last meaningful error preservation to virCHProcessStop. Signed-off-by: Kirill Shchetiniuk Reviewed-by: Peter Krempa --- src/ch/ch_process.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 9a85f7869e..38d466eaeb 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -995,11 +995,15 @@ virCHProcessStop(virCHDriver *driver, virCHDomainObjPrivate *priv =3D vm->privateData; virCHDriverConfig *cfg =3D virCHDriverGetConfig(driver); virDomainDef *def =3D vm->def; + virErrorPtr orig_err =3D NULL; size_t i; =20 VIR_DEBUG("Stopping VM name=3D%s pid=3D%d reason=3D%d", vm->def->name, (int)vm->pid, (int)reason); =20 + /* Preserve origin error */ + virErrorPreserveLast(&orig_err); + if (priv->monitor) { g_clear_pointer(&priv->monitor, virCHMonitorClose); } @@ -1032,6 +1036,8 @@ virCHProcessStop(virCHDriver *driver, =20 virHostdevReAttachDomainDevices(driver->hostdevMgr, CH_DRIVER_NAME, de= f, hostdev_flags); + + virErrorRestore(&orig_err); return 0; } =20 --=20 2.48.1