From nobody Sun Oct 5 00:06:50 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757424935; cv=none; d=zohomail.com; s=zohoarc; b=eSK2ZXj8wFqDg+K+msP/uvhqY2aW3FwN8c+alkrLrksdYWp2hJfzzElQHIrEjFPDEwHha5kJaLU3F+lNodWVZtqmN2IfC6GsZaYfJhLKVZ/mPQklDil2x4Gpwn2/HnUbLafoJ11I4f/yO2LteQDABG1J/ia8IOcurUj8QqmiEkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757424935; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=vgR59rOa7GmamUmFYYSbzM9x6UnBTU2of/6wVA5kJ14=; b=A+zTQOglArzbuKBj+JwjwblN+kHh+SCyNQQxKguBqDeKLqMyPBY6/M5aZU6pYaIaqlTgFnnjhdEfq3bYxRpePk70jFl9Abw0xIimjdnE4s5tlxVjgyGiA5fkRYV/hsVhhLtYYNAbbpBFr5QCZUlrpwJrrwTlz3qW3SXDzKnxTyk= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757424935246944.3984529702153; Tue, 9 Sep 2025 06:35:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4BD8341B66; Tue, 9 Sep 2025 09:35:33 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id F01FB43E16; Tue, 9 Sep 2025 09:32:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8F924418E3; Tue, 9 Sep 2025 09:32:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BC1C341B0E for ; Tue, 9 Sep 2025 09:32:13 -0400 (EDT) Received: from mx-prod-mc-02.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-465-OUEqAIIMMXOSUOOK-XkJkg-1; Tue, 09 Sep 2025 09:32:09 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B301B195609F for ; Tue, 9 Sep 2025 13:32:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 05189300018D for ; Tue, 9 Sep 2025 13:32:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757424732; 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=vgR59rOa7GmamUmFYYSbzM9x6UnBTU2of/6wVA5kJ14=; b=FcY8gNCGH6uhAl9oFjJra8sPLMBAk6VINNhykpXLBKIlhPPVKN2DLSxq1Wehsfu/C+9d6K gGV9BUswr+0ywNDmCohdPMNjAgZDXqIqBuJWISUfa8sirSl7pGmggwtu7T3pAyGwy7lt5N 9bFQfHFcYCSuMgS/Yz1GUSpkqFBJ8XM= X-MC-Unique: OUEqAIIMMXOSUOOK-XkJkg-1 X-Mimecast-MFC-AGG-ID: OUEqAIIMMXOSUOOK-XkJkg_1757424728 To: devel@lists.libvirt.org Subject: [PATCH 1/4] virprocess: Report errno if virProcessAbort() fails Date: Tue, 9 Sep 2025 15:31:59 +0200 Message-ID: <8d5e29a120849ec60fbcbc3a9c682403d1679c14.1757424690.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-MFC-PROC-ID: aPm0Weuafu_CDOP59ehli74DJfetm93AIwVHRC4DuFU_1757424728 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: X2P7WCXE5RKMZUVXSANRWFXDNLH35JNN X-Message-ID-Hash: X2P7WCXE5RKMZUVXSANRWFXDNLH35JNN X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757424935801116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The aim of virProcessAbort() is to reap a child process. It does so by waitpid()-ing and possibly sending SIGTERM/SIGKILL to the child process (and waitpid()-ing again). Nevertheless, if everything fails a debug message is printed. But the message mentions only the PID and not errno (set by previous waitpid()) which may be useful. For instance when virProcessAbort() is called over a PID that's not our child: failed to reap child 16325, abandoning it: No child processes Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virprocess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 3889ba90f9..e8120c1bdc 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -168,7 +168,8 @@ virProcessAbort(pid_t pid) } } } - VIR_DEBUG("failed to reap child %lld, abandoning it", (long long) pid); + VIR_DEBUG("failed to reap child %lld, abandoning it: %s", + (long long) pid, g_strerror(errno)); =20 cleanup: errno =3D saved_errno; --=20 2.49.1 From nobody Sun Oct 5 00:06:50 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757424834; cv=none; d=zohomail.com; s=zohoarc; b=RReHX+kWKlpEcrIcrA+6ERo9xI0/hbBV1kZRnHY9sSGTAUV49FfLuDAIaPpU0Z/+omb3IEX8GXZQGcdoVeDVYPJyeFJeCuSRS5Ecd9qCOkPdm6ahKN1fHZi4/J3a79DbQCzxKvdCUBD90X7FhyRnAuHAbQ1aTclygg/RgtBFUjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757424834; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=XJraZb4prTILQJ8Lr+/jGUKZZDfRbCk+1nCe8I1dRyA=; b=HkIaS7JzxYu+5KZiA4vmfm1QAJHcyCxwMygJTAQgahCM+SsiU5KW8ervzemicCd0gzjC89a1SIoi7TJm69ioVmWrrA/9AubxFPXjOvjsAs49Wk31RmswCeCSnvztOXrFv18BzBM6rTYcgKz7QycRtnU1Spo05gb4njJw2TijEpc= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757424833997341.93889008928727; Tue, 9 Sep 2025 06:33:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 79E0941B20; Tue, 9 Sep 2025 09:33:50 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1446141B74; Tue, 9 Sep 2025 09:32:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id EF42C41B0F; Tue, 9 Sep 2025 09:32:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 34E4F41932 for ; Tue, 9 Sep 2025 09:32:13 -0400 (EDT) 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-452-_c27AATUPlaig80li3G0yQ-1; Tue, 09 Sep 2025 09:32:11 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 48CCC19560BE for ; Tue, 9 Sep 2025 13:32:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8EAAA300070A for ; Tue, 9 Sep 2025 13:32:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757424732; 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=XJraZb4prTILQJ8Lr+/jGUKZZDfRbCk+1nCe8I1dRyA=; b=CCdEKZ2S5RFUHyQc5SGWbmZQ9RiYCoQU+QX9M7M4NWgDOatGePrFGFrlxt2kTW0zh2LJA2 tWCLKMpHWp3TMGqd5CDD7H+b/sBgLSM3wP7VkZdgsB7l6nNk0k717xWz4nscpzfp6E2Hjg lmHrTNOEZupziDi7GZZeSVPYA1pdnqg= X-MC-Unique: _c27AATUPlaig80li3G0yQ-1 X-Mimecast-MFC-AGG-ID: _c27AATUPlaig80li3G0yQ_1757424730 To: devel@lists.libvirt.org Subject: [PATCH 2/4] ch: Make sure the cloud-hypervisor process is killed in virCHProcessStop() Date: Tue, 9 Sep 2025 15:32:00 +0200 Message-ID: <8f6c8ce7b255ad825ebe08be1e04dce0f3b270c8.1757424690.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-MFC-PROC-ID: I2Ov4Yv1PdgF6LwZK8l-427ctTslk3L9hpsW8eVJdcA_1757424730 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ITKFYKRDIT3RY3AWFH2UGFGLUNW5KB4W X-Message-ID-Hash: ITKFYKRDIT3RY3AWFH2UGFGLUNW5KB4W X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757424836286124100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Currently, virCHProcessStop() is called either when the cloud-hypervisor process dies gracefully (e.g. on shutdown initiated from within the guest) or when virDomainDestroy() is called (or on failed start attempt, but that's not important right now). At any rate, if the cloud-hypervisor process is running it's not a child process of libvirtd rather than the init (per virCommandDaemonize() called inside of virCHMonitorNew()). This distinction is important because virCHProcessStop() then calls virProcessAbort() thinking it'll kill the process. Well, virProcessAbort() works only on child processes. Switch to virProcessKillPainfully() which does work in such cases. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 5195d3f5da..6b779285e1 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -1028,7 +1028,7 @@ virCHProcessStop(virCHDriver *driver, virErrorPreserveLast(&orig_err); =20 if (priv->monitor) { - virProcessAbort(vm->pid); + virProcessKillPainfully(vm->pid, true); g_clear_pointer(&priv->monitor, virCHMonitorClose); } =20 --=20 2.49.1 From nobody Sun Oct 5 00:06:50 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757424885; cv=none; d=zohomail.com; s=zohoarc; b=gEK275BQGFciDmPWJlN64jPMuglvi6mSxP+7G1o35TGAzwurBrQRPgikdJT6v82en/U9oX9Ad2GVsMoSx0junpTR9kS8nxtmREhM4LXkIcfReTc4xw+V1I+MGsG7jT3RIMuCqu7h0PDQ92nf3/+GSI8D+wq35tW7bcTbEzyjoIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757424885; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=/obb5hxuD9SuVS7jzHuwQawDxEDSoS6UyqhO2g7HQy8=; b=QR8yYkYnmFV9T2jqPOrSx/WB3BA0uivt1Ifyj69qVVQhsNCOAiBFh7/yEk5IRUNqeyYbWPpWYQECI/JEr3e+YveKNrqkS3UnmxO1rX8LsZp6L2O88tmP/qZUqeaqdOsFTQMQIMfmNlCw0hGbjeSlKiY3w30AFqRmZYMgDf/Bdmw= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757424885686315.6472813932911; Tue, 9 Sep 2025 06:34:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8BA0A41A10; Tue, 9 Sep 2025 09:34:42 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 4390241BA9; Tue, 9 Sep 2025 09:32:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6103741932; Tue, 9 Sep 2025 09:32:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A591941B0D for ; Tue, 9 Sep 2025 09:32:13 -0400 (EDT) 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-468-C49-n9STNPaMTca29iWftA-1; Tue, 09 Sep 2025 09:32:12 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 58BEF180034D for ; Tue, 9 Sep 2025 13:32:11 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AB453300018D for ; Tue, 9 Sep 2025 13:32:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757424733; 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=/obb5hxuD9SuVS7jzHuwQawDxEDSoS6UyqhO2g7HQy8=; b=VcZJm1+lP+kNva4qXyxkyU5tt7oJbdbe0reeMOE0ErjDh011hRTAxKeKPlzFIQWs2bydHk i+Ia5oJrxqCvHLKVKxs72Tke4i8cEpgeRC7vb+Mb6sqlaC0s36wPztMTG/iQ0YBGdmZW1B Jmu8uaKVYj02KkYDS1T+HjTfgGDfZ2Y= X-MC-Unique: C49-n9STNPaMTca29iWftA-1 X-Mimecast-MFC-AGG-ID: C49-n9STNPaMTca29iWftA_1757424731 To: devel@lists.libvirt.org Subject: [PATCH 3/4] ch: Introduce flags to virCHProcessStop() Date: Tue, 9 Sep 2025 15:32:01 +0200 Message-ID: <5027793a2c84b2b1f9e5a7d83e2db8c7c82956b3.1757424690.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-MFC-PROC-ID: ZpqIF6ut1ZG09To0Fw9BOd5fMAGEpYmk0bJqzgfu6K0_1757424731 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NYFMGPKNXPA7V6Y72QIBHCIJPZAZVP63 X-Message-ID-Hash: NYFMGPKNXPA7V6Y72QIBHCIJPZAZVP63 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757424887469116601 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik A caller (e.g. chDomainDestroyFlags()) might want to chose whether to kill emulator process forcefully or gracefully (the @force argument of virProcessKillPainfully()). Invent a flag to virCHProcessStop() for this. And to keep consistent behaviour, pass the flag everywhere for now. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_driver.c | 8 ++++++-- src/ch/ch_events.c | 2 +- src/ch/ch_process.c | 22 ++++++++++++++++------ src/ch/ch_process.h | 8 +++++++- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 760fccba82..019994b202 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -686,8 +686,11 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int fl= ags) if (virDomainObjCheckActive(vm) < 0) goto endjob; =20 - if (virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED) < 0) + if (virCHProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_DESTROYED, + VIR_CH_PROCESS_STOP_FORCE) < 0) { goto endjob; + } =20 event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -818,7 +821,8 @@ chDoDomainSave(virCHDriver *driver, goto end; } =20 - if (virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED) < 0) { + if (virCHProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_SAVED, VIR_CH_PROCESS_STOP_FOR= CE) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to shutoff after domain save")); goto end; diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 3d4e3c41e1..be572dfde3 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -59,7 +59,7 @@ virCHEventStopProcess(virDomainObj *vm, virObjectLock(vm); if (virDomainObjBeginJob(vm, VIR_JOB_DESTROY)) return -1; - virCHProcessStop(driver, vm, reason); + virCHProcessStop(driver, vm, reason, VIR_CH_PROCESS_STOP_FORCE); virDomainObjEndJob(vm); virObjectUnlock(vm); =20 diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 6b779285e1..54b21b0baf 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -1003,7 +1003,9 @@ virCHProcessStart(virCHDriver *driver, =20 cleanup: if (ret) - virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); + virCHProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_FAILED, + VIR_CH_PROCESS_STOP_FORCE); =20 return ret; } @@ -1011,7 +1013,8 @@ virCHProcessStart(virCHDriver *driver, int virCHProcessStop(virCHDriver *driver, virDomainObj *vm, - virDomainShutoffReason reason) + virDomainShutoffReason reason, + unsigned int flags) { g_autoptr(virCHDriverConfig) cfg =3D virCHDriverGetConfig(driver); int ret; @@ -1022,13 +1025,18 @@ virCHProcessStop(virCHDriver *driver, 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); + VIR_DEBUG("Stopping VM name=3D%s pid=3D%d reason=3D%d flags=3D0x%x", + vm->def->name, (int)vm->pid, (int)reason, flags); =20 virErrorPreserveLast(&orig_err); =20 if (priv->monitor) { - virProcessKillPainfully(vm->pid, true); + bool force =3D false; + + if (flags & VIR_CH_PROCESS_STOP_FORCE) + force =3D true; + + virProcessKillPainfully(vm->pid, force); g_clear_pointer(&priv->monitor, virCHMonitorClose); } =20 @@ -1180,6 +1188,8 @@ virCHProcessStartRestore(virCHDriver *driver, virDoma= inObj *vm, const char *from if (tapfds) chCloseFDs(tapfds, ntapfds); if (ret) - virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); + virCHProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_FAILED, + VIR_CH_PROCESS_STOP_FORCE); return ret; } diff --git a/src/ch/ch_process.h b/src/ch/ch_process.h index 70ae8f700d..a22790bb5c 100644 --- a/src/ch/ch_process.h +++ b/src/ch/ch_process.h @@ -26,9 +26,15 @@ int virCHProcessStart(virCHDriver *driver, virDomainObj *vm, virDomainRunningReason reason); + +typedef enum { + VIR_CH_PROCESS_STOP_FORCE =3D 1 << 0, +} virCHProcessStopFlags; + int virCHProcessStop(virCHDriver *driver, virDomainObj *vm, - virDomainShutoffReason reason); + virDomainShutoffReason reason, + unsigned int flags); =20 int virCHProcessStartRestore(virCHDriver *driver, virDomainObj *vm, --=20 2.49.1 From nobody Sun Oct 5 00:06:50 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757425002; cv=none; d=zohomail.com; s=zohoarc; b=RgXt+UPwtaMJExJ0m/iWP688IMYr6ljPS6FpZfB6atlXpN4NOGINtDYo3DtrcA2/J+WiJZyoZt3TmuYbPfg5p/OqHuINjw8vr5mdtJGo7iGodjUZUa02EO4Oyky+NJOJ8OuvR3w9NmI+i03I+5/FxFNbhyS1rjLf5WBslye0Gdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757425002; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=gqyG1qfcMESlyOqP9Kg4BhzCcgcKgUEQwNUNMh3ehnY=; b=dvf/gQ9DHwQG/pk1Em29NrIO8etIvpXme4rVVaDXF5BaLr3lO8Q47IDaBMgOvCzmk6uoKc5pabLvIRCf1I4ns8WGFGzOt7+fYJ0DiA0+2mXFYj5HkV2K0EQtSe+70xTI4YrSEauTIEmwU7yP8T1SHDAsu5Ng2rBRmo0Xt3iNkcI= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1757425002111638.9379347389392; Tue, 9 Sep 2025 06:36:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1028441B42; Tue, 9 Sep 2025 09:36:41 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id CB9D941B22; Tue, 9 Sep 2025 09:33:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 886A3418E3; Tue, 9 Sep 2025 09:32:17 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6768041B0F for ; Tue, 9 Sep 2025 09:32:16 -0400 (EDT) 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-252-ISftLTpkM5-7vk-LwQSvVA-1; Tue, 09 Sep 2025 09:32:14 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 507601956096 for ; Tue, 9 Sep 2025 13:32:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 38BD6300018D for ; Tue, 9 Sep 2025 13:32:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757424736; 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=gqyG1qfcMESlyOqP9Kg4BhzCcgcKgUEQwNUNMh3ehnY=; b=L0MXl467D7aAcQi1ChWJ+COIu0O6/FHe+iM63b4as+ljPQweey1AVv9Y6jax84QansTQGG pW/xnT/bTPwQ45qI+xW/SltMtvMhWmU9IphR4U1vjzhtepbnRvtgs8QYwLc5tJO1czGBNA Vqk79B4p25q04T38dAq3K2ZTc69HAlg= X-MC-Unique: ISftLTpkM5-7vk-LwQSvVA-1 X-Mimecast-MFC-AGG-ID: ISftLTpkM5-7vk-LwQSvVA_1757424733 To: devel@lists.libvirt.org Subject: [PATCH 4/4] ch: Implement VIR_DOMAIN_DESTROY_GRACEFUL flag support Date: Tue, 9 Sep 2025 15:32:02 +0200 Message-ID: <6f234030a94ac449118acaeb91ae6c3dc39dc0cc.1757424690.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-MFC-PROC-ID: HDj7IMj_Wg6V0TUcjwWIaJKZV4Oa3kXs3h-XBMyOl8E_1757424733 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EMUFHCOXKBICSIFJ66YMJLTZ3MEFUYRC X-Message-ID-Hash: EMUFHCOXKBICSIFJ66YMJLTZ3MEFUYRC X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757425004902116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The virDomainDestroyFlags() API has several flags, including VIR_DOMAIN_DESTROY_GRACEFUL which is documented to send only SIGTERM to the emulator process. Implement its support into CH driver. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_driver.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 019994b202..0a516f3384 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -670,9 +670,13 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int fl= ags) virCHDriver *driver =3D dom->conn->privateData; virDomainObj *vm; virObjectEvent *event =3D NULL; + unsigned int stopFlags =3D 0; int ret =3D -1; =20 - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_DESTROY_GRACEFUL, -1); + + if (!(flags & VIR_DOMAIN_DESTROY_GRACEFUL)) + stopFlags |=3D VIR_CH_PROCESS_STOP_FORCE; =20 if (!(vm =3D virCHDomainObjFromDomain(dom))) goto cleanup; @@ -687,8 +691,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int fla= gs) goto endjob; =20 if (virCHProcessStop(driver, vm, - VIR_DOMAIN_SHUTOFF_DESTROYED, - VIR_CH_PROCESS_STOP_FORCE) < 0) { + VIR_DOMAIN_SHUTOFF_DESTROYED, stopFlags) < 0) { goto endjob; } =20 --=20 2.49.1