From nobody Sun Dec 22 09:35:40 2024 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 1733132924297707.8482999445699; Mon, 2 Dec 2024 01:48:44 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4165314B8; Mon, 2 Dec 2024 04:48:43 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 852721A7C; Mon, 2 Dec 2024 04:46:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6232C17F0; Mon, 2 Dec 2024 04:46:11 -0500 (EST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 8BC1017F0 for ; Mon, 2 Dec 2024 04:46:05 -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 DC47E2053059; Mon, 2 Dec 2024 01:46:03 -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=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, 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 DC47E2053059 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733132764; bh=YbGqwrUoLcxgnkZuntuhyAzNqlDpOFavqasZ+I383uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEC4oO01QHvo0h87Fpd5u7NcyvnflXdZvcEsE/QPKnKv0vsQhcxZuhevLLAmHKv/a ZOFtJZdIdBwxD/QvnbX3PwLcqE+MntLcZiTCEJjWmD8d6PfN6pu3PCRb3VY0QX+TCC Tv1ib3WfEJmD+k7Aaya9OKkz3KhsxGCnuToJ3rMo= From: Purna Pavan Chandra Aekkaladevi To: devel@lists.libvirt.org Subject: [PATCH v4 1/5] ch: pass --event-monitor option to cloud-hypervisor Date: Mon, 2 Dec 2024 09:45:58 +0000 Message-Id: <20241202094602.288683-2-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202094602.288683-1-paekkaladevi@linux.microsoft.com> References: <20241202094602.288683-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: S5HTBCPKGKVPYPPPKJXHHIPENVBFTBKY X-Message-ID-Hash: S5HTBCPKGKVPYPPPKJXHHIPENVBFTBKY 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: prasad.krishnan@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, jnadimpalli@microsoft.com, paekkaladevi@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: 1733132925555116600 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 690aea37c8..59117d72b6 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -540,7 +540,6 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g) { 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) @@ -556,11 +555,13 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *= cfg) } =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 @@ -585,6 +586,9 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g) 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; @@ -630,6 +634,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 9ec58e5b20..7f72626c2b 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -95,6 +95,8 @@ struct _virCHMonitor { =20 char *socketpath; =20 + char *eventmonitorpath; + pid_t pid; =20 virDomainObj *vm; --=20 2.34.1