From nobody Tue Jan 21 07:22:28 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=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737134008805298.879990270005; Fri, 17 Jan 2025 09:13:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 27B641AFC; Fri, 17 Jan 2025 12:13:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4D8B31B43; Fri, 17 Jan 2025 12:11:24 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4F31718E6; Fri, 17 Jan 2025 12:11:16 -0500 (EST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id B076A18E8 for ; Fri, 17 Jan 2025 12:11:15 -0500 (EST) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 9001A20BEBFC; Fri, 17 Jan 2025 09:11:10 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9001A20BEBFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1737133870; bh=QNtQO43MDSp7DX/sT6E3S1JkIEBy2eBYhhxUdR5Y4qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SAEB/JBcyjwdO9uaWSd0BepQQ3NdJB2giCeimLWxuQEt0QTUxR+LUiRlX71FGl01j IdTb7hnO4C8g9YMmXZ8oan4xLhcZEcuhcwgoppsljK79jSzM/FUIaEbhPEsXRhIDGG qztPuJ03qAxC4Jki/z7J1CqXJTpPMuI+bsJyqilU= From: Purna Pavan Chandra Aekkaladevi To: devel@lists.libvirt.org Subject: [PATCH v5 1/5] ch: pass --event-monitor option to cloud-hypervisor Date: Fri, 17 Jan 2025 17:11:05 +0000 Message-Id: <20250117171109.639464-2-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117171109.639464-1-paekkaladevi@linux.microsoft.com> References: <20250117171109.639464-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Z62E7665RXPKPE24JNC2CWKWG5F7RQ3X X-Message-ID-Hash: Z62E7665RXPKPE24JNC2CWKWG5F7RQ3X X-MailFrom: paekkaladevi@linux.microsoft.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: liuwe@microsoft.com, paekkaladevi@microsoft.com, jnadimpalli@microsoft.com, prasad.krishnan@microsoft.com, prapal@linux.microsoft.com, Purna Pavan Chandra Aekkaladevi 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 (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1737134009708019000 Content-Type: text/plain; charset="utf-8" The `--event-monitor` option in cloud-hypervisor outputs events to a specified file. This file can then be used to monitor VM lifecycle, other vmm events and trigger appropriate actions. Signed-off-by: Purna Pavan Chandra Aekkaladevi Co-authored-by: Vineeth Pillai --- src/ch/ch_monitor.c | 20 ++++++++++++++++---- src/ch/ch_monitor.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index d3f969e01a..a72ee40aa1 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -541,7 +541,6 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g, int logfile) { g_autoptr(virCHMonitor) mon =3D NULL; g_autoptr(virCommand) cmd =3D NULL; - const char *socketdir =3D cfg->stateDir; int socket_fd =3D 0; =20 if (virCHMonitorInitialize() < 0) @@ -557,11 +556,13 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *= cfg, int logfile) } =20 /* prepare to launch Cloud-Hypervisor socket */ - mon->socketpath =3D g_strdup_printf("%s/%s-socket", socketdir, vm->def= ->name); - if (g_mkdir_with_parents(socketdir, 0777) < 0) { + mon->socketpath =3D g_strdup_printf("%s/%s-socket", cfg->stateDir, vm-= >def->name); + mon->eventmonitorpath =3D g_strdup_printf("%s/%s-event-monitor", + cfg->stateDir, vm->def->name); + if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) { virReportSystemError(errno, _("Cannot create socket directory '%1$s'"), - socketdir); + cfg->stateDir); return NULL; } =20 @@ -589,6 +590,9 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g, int logfile) virCommandAddArgFormat(cmd, "fd=3D%d", socket_fd); virCommandPassFD(cmd, socket_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); =20 + virCommandAddArg(cmd, "--event-monitor"); + virCommandAddArgFormat(cmd, "path=3D%s", mon->eventmonitorpath); + /* launch Cloud-Hypervisor socket */ if (virCommandRunAsync(cmd, &mon->pid) < 0) return NULL; @@ -634,6 +638,14 @@ void virCHMonitorClose(virCHMonitor *mon) g_clear_pointer(&mon->socketpath, g_free); } =20 + if (mon->eventmonitorpath) { + if (virFileRemove(mon->eventmonitorpath, -1, -1) < 0) { + VIR_WARN("Unable to remove CH event monitor file '%s'", + mon->eventmonitorpath); + } + g_clear_pointer(&mon->eventmonitorpath, g_free); + } + virObjectUnref(mon); } =20 diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index ca23301723..67dc54f9f4 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -96,6 +96,8 @@ struct _virCHMonitor { =20 char *socketpath; =20 + char *eventmonitorpath; + pid_t pid; =20 virDomainObj *vm; --=20 2.34.1