From nobody Tue Dec 16 13:50:41 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=1743676868; cv=none; d=zohomail.com; s=zohoarc; b=Q8+HOiZ5Fu4UQquHmN79XqVg7meZiOExJ8Vj07czK/JnEb3/lD1GV4+zEqwgpjyEeHZp260z3ge+5zTPoeMKrcxXdT9idk+UJiVh8HSel0iOaPxIodbpYbGSLia4ZRe2j+3TyQ3lOgKS8U8SbaAv3veqhKo20NLu5uboChRkCnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743676868; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=fqwpWsKKRyMzgwAqUAwFTOtm+rcSrZJL98dqltzxEGY=; b=keBIYrpa4bkJz8fu5eFdtfoCS7UT3P5UfPiCgF/MhasvvmhJZueO4s7m+kedYrSco0O7+pfhi86uZP3ONCkbSQCmdM3vQJ5SREhvRZK4/UKcD3y5Y0P/mNvIbHZBM4f25leSKyREPk3yOZYmVAjE2YVty0yX7g9nbYA0Zq+7SsM= 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 1743676868659863.9594741838231; Thu, 3 Apr 2025 03:41:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A7B1916F0; Thu, 3 Apr 2025 06:41:07 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5ECF41490; Thu, 3 Apr 2025 06:37:13 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B3784A5B; Thu, 3 Apr 2025 06:37:07 -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 49EC9A5B for ; Thu, 3 Apr 2025 06:36:53 -0400 (EDT) Received: from mx-prod-mc-06.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-341-27jnw4ydNLmc8ovFO3AhPw-1; Thu, 03 Apr 2025 06:36:51 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E69231800259 for ; Thu, 3 Apr 2025 10:36:50 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C9811955BC2 for ; Thu, 3 Apr 2025 10:36:50 +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=1743676612; 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=2DXyLTuc6WOawk5MMbXmEu2BSjyw7dxUArtNVN/FEFo=; b=N0OgOMWZ+4AI7C/S/EJgc1/xlV6cef1Nru489qicdwoe9+TsA4AcaVDuIR5EiUXk5IP4wV bkXBxNWepKPH/Y4L6icATLYD0j3KFWqjQt1yxaEtcTvkkspivYGxy7/3A/L3+SiEgsv1hJ NZTjelyiiOa6NI742mn1v3j4oYX/S48= X-MC-Unique: 27jnw4ydNLmc8ovFO3AhPw-1 X-Mimecast-MFC-AGG-ID: 27jnw4ydNLmc8ovFO3AhPw_1743676611 To: devel@lists.libvirt.org Subject: [PATCH 2/3] ch: Drop pid from monitor Date: Thu, 3 Apr 2025 12:36:44 +0200 Message-ID: <0cc946b5b89d4782a7855e48f17d073bf34125e7.1743676591.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lO2avjMuj2YZ8tHLhVDfuxvIPIh_Rzo89h3vpECwhEY_1743676611 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6W3Z354VEYXPPLJIZABZ3OABLTAV335Z X-Message-ID-Hash: 6W3Z354VEYXPPLJIZABZ3OABLTAV335Z 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: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1743676871499019100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The domain object already has a member that allows storing hypervisor's PID (vm->pid). There's no need to duplicate it in _virCHMonitor struct. Switch CH code to use the former. Signed-off-by: Michal Privoznik --- src/ch/ch_events.c | 2 +- src/ch/ch_monitor.c | 10 ++-------- src/ch/ch_monitor.h | 2 -- src/ch/ch_process.c | 3 +-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 9cb873d8cd..3d4e3c41e1 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -297,7 +297,7 @@ int virCHStartEventHandler(virCHMonitor *mon) { g_autofree char *name =3D NULL; - name =3D g_strdup_printf("ch-evt-%d", mon->pid); + name =3D g_strdup_printf("ch-evt-%d", mon->vm->pid); =20 virObjectRef(mon); if (virThreadCreateFull(&mon->event_handler_thread, diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 91899e873b..1c2c1f2858 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -672,14 +672,14 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *= cfg, int logfile) return NULL; } =20 - if ((rv =3D virPidFileReadPath(priv->pidfile, &mon->pid)) < 0) { + if ((rv =3D virPidFileReadPath(priv->pidfile, &vm->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)mon->pid); + vm, vm->def->name, (long long)vm->pid); =20 /* open the reader end of fifo before start Event Handler */ while ((event_monitor_fd =3D open(mon->eventmonitorpath, O_RDONLY)) < = 0) { @@ -727,12 +727,6 @@ void virCHMonitorClose(virCHMonitor *mon) if (!mon) return; =20 - if (mon->pid > 0) { - /* try cleaning up the Cloud-Hypervisor process */ - virProcessAbort(mon->pid); - mon->pid =3D 0; - } - if (mon->handle) curl_easy_cleanup(mon->handle); =20 diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index 185de0dbfd..ffac9e938e 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -108,8 +108,6 @@ struct _virCHMonitor { size_t buf_fill_sz; } event_buffer; =20 - pid_t pid; - virDomainObj *vm; =20 size_t nthreads; diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 6a59bf756a..a008b52752 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -957,7 +957,6 @@ virCHProcessStart(virCHDriver *driver, } } =20 - vm->pid =3D priv->monitor->pid; vm->def->id =3D vm->pid; priv->machineName =3D virCHDomainGetMachineName(vm); =20 @@ -1024,6 +1023,7 @@ virCHProcessStop(virCHDriver *driver, virErrorPreserveLast(&orig_err); =20 if (priv->monitor) { + virProcessAbort(vm->pid); g_clear_pointer(&priv->monitor, virCHMonitorClose); } =20 @@ -1117,7 +1117,6 @@ virCHProcessStartRestore(virCHDriver *driver, virDoma= inObj *vm, const char *from } } =20 - vm->pid =3D priv->monitor->pid; vm->def->id =3D vm->pid; priv->machineName =3D virCHDomainGetMachineName(vm); =20 --=20 2.49.0