From nobody Fri Dec 19 06:32:51 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=1742913374; cv=none; d=zohomail.com; s=zohoarc; b=TN0Mmkg605bf9P6C8spIGRqkxB9a/EutIsj5w8U37aaIp2T0mCyi9vjCM4RYkO0crClmmfdYjI8DF8+ga8idGELwx+q4eGgttI6may/8w/wxy5kuihRNXRR8AKMGv3Dci0c9k3UJ03VETvq5GjE6AUP5jx6qG3KZAHWCD4yMjHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742913374; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=++v/Zl6N4N7MEkU2zKoh2hK5UwW29Gw0F6EcJyEdXSw=; b=lmrPw/67XR0mXjPxcYkb3ycifM4XG08IR+XZw1LprN8F5X4376kPydRvvSHt+GG8taHch803HZSgRinbRaMC9pNu9bQK4UGet0ta4KI1v2O51gbPAEUkXIu/JPhku82IefgHkNAql5ucb/qLjGOMnhellYhDVSBBh/VXz5+gTfc= 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 1742913374010991.5681404811177; Tue, 25 Mar 2025 07:36:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 49C6314F9; Tue, 25 Mar 2025 10:36:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9BDA51662; Tue, 25 Mar 2025 10:35:35 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FC511574; Tue, 25 Mar 2025 10:35:30 -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 4AFEF1574 for ; Tue, 25 Mar 2025 10:35:24 -0400 (EDT) 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-489-T0Nf2wsxN0Wg8J9jS7F-wQ-1; Tue, 25 Mar 2025 10:35:22 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 028F8196D2D8 for ; Tue, 25 Mar 2025 14:35:22 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 178E21801756; Tue, 25 Mar 2025 14:35:20 +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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, 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=1742913323; 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=hFvP3D1hZP/ZACkv1g7frLRWT7/Wr92nBZTCBVcO8TQ=; b=MtEq3WnFI48IbLZ8X59hxDQya5RkCRljVujip/StUY0gbCZA99Fm5VXR0wECrvcbEGGHO1 CIMUm2+HwECmDRfzw3ZWsyAIhsJs21XZj/ImJBNZ4Mck//B6ry7M+12WIyS4Cb3f0O7qUJ 0ggVkLD6hom/PnhYDH0wytAraFN6nCM= X-MC-Unique: T0Nf2wsxN0Wg8J9jS7F-wQ-1 X-Mimecast-MFC-AGG-ID: T0Nf2wsxN0Wg8J9jS7F-wQ_1742913322 To: devel@lists.libvirt.org Subject: [PATCH 1/3] ch: virCHMonitorNew() run new CH monitor daemonized Date: Tue, 25 Mar 2025 15:11:57 +0100 Message-ID: <20250325143501.728342-2-kshcheti@redhat.com> In-Reply-To: <20250325143501.728342-1-kshcheti@redhat.com> References: <20250325143501.728342-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YNCUSyjbsFh7IRzkgBHQLTegbcNrSchCtKphKs9voUs_1742913322 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DMO5XTR6TYK2JXZIPEVOXVSCD3I3AT6U X-Message-ID-Hash: DMO5XTR6TYK2JXZIPEVOXVSCD3I3AT6U 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: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742913376105019000 Content-Type: text/plain; charset="utf-8"; x-default="true" When the new CH monitor was started, it ran as a non-daemonized process and was a child of the CH driver process. This led to a situation where if the CH driver died, the monitor process were killed too, terminating the running VM under the monitor. This led to termination of all VM started under the libvirt. Make new monitor running daemonized to avoid VMs shutdown when driver dies. Also added a pidfile its preparetion to be able to aquire daemon's PID. Signed-off-by: Kirill Shchetiniuk Reviewed-by: Michal Privoznik --- src/ch/ch_domain.c | 1 + src/ch/ch_domain.h | 1 + src/ch/ch_monitor.c | 24 ++++++++++++++++++++++-- src/ch/ch_process.c | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index a08b18c5b9..c0c9acd85b 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -68,6 +68,7 @@ virCHDomainObjPrivateFree(void *data) virBitmapFree(priv->autoCpuset); virBitmapFree(priv->autoNodeset); virCgroupFree(priv->cgroup); + g_free(priv->pidfile); g_free(priv); } =20 diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h index 8dea2b2123..69a657f6af 100644 --- a/src/ch/ch_domain.h +++ b/src/ch/ch_domain.h @@ -36,6 +36,7 @@ struct _virCHDomainObjPrivate { virBitmap *autoCpuset; virBitmap *autoNodeset; virCgroup *cgroup; + char *pidfile; }; =20 #define CH_DOMAIN_PRIVATE(vm) \ diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 0ba927a194..1dc085a755 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -27,6 +27,7 @@ =20 #include "datatypes.h" #include "ch_conf.h" +#include "ch_domain.h" #include "ch_events.h" #include "ch_interface.h" #include "ch_monitor.h" @@ -37,6 +38,7 @@ #include "virfile.h" #include "virjson.h" #include "virlog.h" +#include "virpidfile.h" #include "virstring.h" =20 #define VIR_FROM_THIS VIR_FROM_CH @@ -584,6 +586,8 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g, int logfile) { g_autoptr(virCHMonitor) mon =3D NULL; g_autoptr(virCommand) cmd =3D NULL; + virCHDomainObjPrivate *priv =3D vm->privateData; + int rv; int socket_fd =3D 0; int event_monitor_fd; =20 @@ -644,6 +648,7 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g, int logfile) virCommandSetErrorFD(cmd, &logfile); virCommandNonblockingFDs(cmd); virCommandSetUmask(cmd, 0x002); + socket_fd =3D chMonitorCreateSocket(mon->socketpath); if (socket_fd < 0) { virReportSystemError(errno, @@ -655,13 +660,28 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *= cfg, int logfile) virCommandAddArg(cmd, "--api-socket"); virCommandAddArgFormat(cmd, "fd=3D%d", socket_fd); virCommandPassFD(cmd, socket_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - virCommandAddArg(cmd, "--event-monitor"); virCommandAddArgFormat(cmd, "path=3D%s", mon->eventmonitorpath); + virCommandSetPidFile(cmd, priv->pidfile); + virCommandDaemonize(cmd); =20 /* launch Cloud-Hypervisor socket */ - if (virCommandRunAsync(cmd, &mon->pid) < 0) + rv =3D virCommandRun(cmd, NULL); + + if (rv =3D=3D 0) { + if ((rv =3D virPidFileReadPath(priv->pidfile, &mon->pid)) < 0) { + virReportSystemError(-rv, + _("Domain %1$s didn't show up"), + vm->def->name); + return NULL; + } + VIR_DEBUG("CH vm=3D%p name=3D%s running with pid=3D%lld", + vm, vm->def->name, (long long)vm->pid); + } else { + VIR_DEBUG("CH vm=3D%p name=3D%s failed to spawn", + vm, vm->def->name); return NULL; + } =20 /* open the reader end of fifo before start Event Handler */ while ((event_monitor_fd =3D open(mon->eventmonitorpath, O_RDONLY)) < = 0) { diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index b3eddd61e8..0954de6180 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -36,6 +36,7 @@ #include "virjson.h" #include "virlog.h" #include "virnuma.h" +#include "virpidfile.h" #include "virstring.h" #include "ch_interface.h" #include "ch_hostdev.h" @@ -850,6 +851,21 @@ virCHProcessPrepareHost(virCHDriver *driver, virDomain= Obj *vm) if (virCHHostdevPrepareDomainDevices(driver, vm->def, hostdev_flags) <= 0) return -1; =20 + VIR_FREE(priv->pidfile); + if (!(priv->pidfile =3D virPidFileBuildPath(cfg->stateDir, vm->def->na= me))) { + virReportSystemError(errno, + "%s", _("Failed to build pidfile path.")); + return -1; + } + + if (unlink(priv->pidfile) < 0 && + errno !=3D ENOENT) { + virReportSystemError(errno, + _("Cannot remove stale PID file %1$s"), + priv->pidfile); + return -1; + } + /* Ensure no historical cgroup for this VM is lying around */ VIR_DEBUG("Ensuring no historical cgroup is lying around"); virDomainCgroupRemoveCgroup(vm, priv->cgroup, priv->machineName); --=20 2.48.1 From nobody Fri Dec 19 06:32:51 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=1742913402; cv=none; d=zohomail.com; s=zohoarc; b=GsAw2ctmZSZgH3FLDrYv/1hkmrB/a2cL1zP5oXLBvIyaFru4xDiRglQSqA4aP67ciralcJVML05WLOvhkY9YkBvQS5bvS4ovBr6aPXLhzUSYXGOENO4mgePF1CifefCf9zCBkQ2g0KSuH9ObGeUkHH36SazmsMTlDfPdaa5hi+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742913402; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=ZHmUsgk2tSprygk7dcb8epRHRhHVBrsZqDgheUqA0io=; b=BH4QQ3WbwVm6T1qMvhWTeSBMq4iZD9pd+y81GVSf3pileo2AT6WSGOb6R8p+yPWADrgFMwJKGj/aK00lx8hdqp8AEDnsehjremS/tAoXXEUW4rZusYNx7RPezoH9/iF77xd9RZ0L05Gj5P5JAaadwW5ENNwtredRjbdoMYvd63c= 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 174291340288615.341882276289198; Tue, 25 Mar 2025 07:36:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 42F431557; Tue, 25 Mar 2025 10:36:42 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F09601589; Tue, 25 Mar 2025 10:35:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9CFE4163F; Tue, 25 Mar 2025 10:35:37 -0400 (EDT) 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 5127F163F for ; Tue, 25 Mar 2025 10:35:28 -0400 (EDT) Received: from mx-prod-mc-04.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-586-_BLewN6cPxq6qd2nM_hwlQ-1; Tue, 25 Mar 2025 10:35:26 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9177818DB8E1 for ; Tue, 25 Mar 2025 14:35:25 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A46F0180176A; Tue, 25 Mar 2025 14:35:24 +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, 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=1742913327; 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=u99nYJy7Wr6TWeelmaCe7viQKySzkq91SAuqDYUcQhY=; b=amBUNO/7MtMUYOCYZJKS+qMaaHpACq5+scLU2LyOAbSuPbvGU7duYLIpXwF4JWocJeLMiY Sg3yXPpKC3KBGoxXjvEvoe5POi1Fj3A9ONKgQJ2Vy6ZJNgCXMadntktD34xZ3ulYahdhHb LVktVaElzpRVp0/DtACYiY8FjE2+lsI= X-MC-Unique: _BLewN6cPxq6qd2nM_hwlQ-1 X-Mimecast-MFC-AGG-ID: _BLewN6cPxq6qd2nM_hwlQ_1742913325 To: devel@lists.libvirt.org Subject: [PATCH 2/3] ch: virCHProcessEvent() update domain info after reboot Date: Tue, 25 Mar 2025 15:11:58 +0100 Message-ID: <20250325143501.728342-3-kshcheti@redhat.com> In-Reply-To: <20250325143501.728342-1-kshcheti@redhat.com> References: <20250325143501.728342-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6wUzo3onew_qAKdjdQ5SL8NQPDm2FZSU40y6WV6mLfE_1742913325 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 23SZ3JHM5Y5CHKBD2DUML5QK6UOV7YTE X-Message-ID-Hash: 23SZ3JHM5Y5CHKBD2DUML5QK6UOV7YTE 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: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742913404033019000 Content-Type: text/plain; charset="utf-8"; x-default="true" When the domain was rebooted, some of its properties were changed but not updated in the transient domain definition. This led to the inability to connect to the serial console as its path had changed during the reboot but was not updated in the domain definition. Added VIR_CH_EVENT_VM_REBOOTED event handling to update the information in transient domain definition after domain's reboot is completed to maintain it in consistent state. Signed-off-by: Kirill Shchetiniuk Reviewed-by: Michal Privoznik --- src/ch/ch_events.c | 6 +++++- src/ch/ch_process.c | 2 +- src/ch/ch_process.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 2dd3e7ecc2..32846ba4e5 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -97,7 +97,6 @@ virCHProcessEvent(virCHMonitor *mon, case VIR_CH_EVENT_VM_BOOTING: case VIR_CH_EVENT_VM_BOOTED: case VIR_CH_EVENT_VM_REBOOTING: - case VIR_CH_EVENT_VM_REBOOTED: case VIR_CH_EVENT_VM_PAUSING: case VIR_CH_EVENT_VM_PAUSED: case VIR_CH_EVENT_VM_RESUMING: @@ -120,6 +119,11 @@ virCHProcessEvent(virCHMonitor *mon, virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_SH= UTDOWN); virObjectUnlock(vm); break; + case VIR_CH_EVENT_VM_REBOOTED: + virObjectLock(vm); + virCHProcessUpdateInfo(vm); + virObjectUnlock(vm); + break; case VIR_CH_EVENT_LAST: default: VIR_WARN("%s: Unknown event: %s", vm->def->name, full_event); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 0954de6180..31aa49b3a5 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -131,7 +131,7 @@ virCHProcessUpdateConsole(virDomainObj *vm, virCHProcessUpdateConsoleDevice(vm, config, "serial"); } =20 -static int +int virCHProcessUpdateInfo(virDomainObj *vm) { g_autoptr(virJSONValue) info =3D NULL; diff --git a/src/ch/ch_process.h b/src/ch/ch_process.h index 38bfce3b7f..7a6995b7cf 100644 --- a/src/ch/ch_process.h +++ b/src/ch/ch_process.h @@ -36,3 +36,5 @@ int virCHProcessSetupVcpu(virDomainObj *vm, int virCHProcessStartRestore(virCHDriver *driver, virDomainObj *vm, const char *from); + +int virCHProcessUpdateInfo(virDomainObj *vm); --=20 2.48.1 From nobody Fri Dec 19 06:32:51 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=1742913418; cv=none; d=zohomail.com; s=zohoarc; b=d+o62TSNGrpxjWODrbU8/kob5eNReodwPIKtEE4EAWpn9HbBqJpVgYyrAGhHR0p292VvfaYJnko1HwCnOlNEGrZnFFsSfbXmA/j7lGqXaQ1b3z4XVLWTH3oqzN7+9m5R1j4R9HATdOeSBqBLfrbGm9BYIRhTCCkBnsO3bIv7L0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742913418; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=v7YUoz20TfxlNF5r7rhaoHCyrMmIbvrVDC9BLMmweCU=; b=Xa4vlh9W7Lmd+yfOEwjMwiodDObUgG70XEy2zmeimyXdCCKjrpdxxg49d2pDmey/F99hlApcu4UiMdDRlTsAb9G3luQlQnsdgH0KKB5pfDgYADPEZMRQY0O6qCaaW0sHvcIfWETG/IQIvHNhokwNaun8FTSHbkk6o81k+K+sNuc= 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 1742913418885892.3544805606188; Tue, 25 Mar 2025 07:36:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 53B351291; Tue, 25 Mar 2025 10:36:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 86B1D16AD; Tue, 25 Mar 2025 10:35:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 88D1F149B; Tue, 25 Mar 2025 10:35:40 -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 21C52154B for ; Tue, 25 Mar 2025 10:35:31 -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-73-Dk3KzjaUNYifQitnpBU18Q-1; Tue, 25 Mar 2025 10:35:29 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 5DEE9196B373 for ; Tue, 25 Mar 2025 14:35:28 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 70F9E1801756; Tue, 25 Mar 2025 14:35:27 +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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, 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=1742913330; 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=czX7x8JdEQgC9C+ckLaqs8U3vS0G2ZasY2i/m1AFNww=; b=KleE+GkmEHhnwIZcmYdkikzJDjNKh7jbQtpXB2Wyss03AegrjBqHwtKuFx0aYh3TLck6V6 aYVJTdoTHcmWaFq9atcKN2wULgqiaBE+oN9NwjIX0j4MK8mr7x1HcyyOuA3zoN4f41uYGg UmSu/xw8lO5oCrq4p8HjPDBQNf11d3s= X-MC-Unique: Dk3KzjaUNYifQitnpBU18Q-1 X-Mimecast-MFC-AGG-ID: Dk3KzjaUNYifQitnpBU18Q_1742913328 To: devel@lists.libvirt.org Subject: [PATCH 3/3] ch: virCHProcessEvent() vm shutdown event handler fix Date: Tue, 25 Mar 2025 15:11:59 +0100 Message-ID: <20250325143501.728342-4-kshcheti@redhat.com> In-Reply-To: <20250325143501.728342-1-kshcheti@redhat.com> References: <20250325143501.728342-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: F7eafR1ORAPMDjBKQwbswSVTzQibZ2EDKnJ8-mDpF1c_1742913328 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: A4S7AQV6QR4T7OO23CU3FZSITZSKD4EM X-Message-ID-Hash: A4S7AQV6QR4T7OO23CU3FZSITZSKD4EM 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: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742913419882019000 Content-Type: text/plain; charset="utf-8"; x-default="true" When the domain shutdown was executed from virsh, only the VM process (a child of the CH monitor) was terminated. Since we assume only one VM per monitor, the monitor process should also be terminated. Modified the VM shutdown event handler to match the VMM shutdown behavior, ensuring the VM monitor stops along with the VM. Also updated the virCHEventStopProcess job type, as it only destroys the domain rather than modifying anything. Signed-off-by: Kirill Shchetiniuk Reviewed-by: Michal Privoznik --- src/ch/ch_events.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 32846ba4e5..f1dc5c6f4c 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -57,7 +57,7 @@ virCHEventStopProcess(virDomainObj *vm, virCHDriver *driver =3D ((virCHDomainObjPrivate *)vm->privateData)->d= river; =20 virObjectLock(vm); - if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY)) + if (virDomainObjBeginJob(vm, VIR_JOB_DESTROY)) return -1; virCHProcessStop(driver, vm, reason); virDomainObjEndJob(vm); @@ -108,17 +108,13 @@ virCHProcessEvent(virCHMonitor *mon, case VIR_CH_EVENT_VM_DELETED: break; case VIR_CH_EVENT_VMM_SHUTDOWN: + case VIR_CH_EVENT_VM_SHUTDOWN: if (virCHEventStopProcess(vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN)) { VIR_WARN("Failed to mark the VM(%s) as SHUTDOWN!", vm->def->name); ret =3D -1; } break; - case VIR_CH_EVENT_VM_SHUTDOWN: - virObjectLock(vm); - virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_SH= UTDOWN); - virObjectUnlock(vm); - break; case VIR_CH_EVENT_VM_REBOOTED: virObjectLock(vm); virCHProcessUpdateInfo(vm); --=20 2.48.1