From nobody Sun Dec 22 08:31:30 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=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734628357671442.58237036984667; Thu, 19 Dec 2024 09:12:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8C6CD1881; Thu, 19 Dec 2024 12:12:36 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 550C2189A; Thu, 19 Dec 2024 12:08:30 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 26AAF17AB; Thu, 19 Dec 2024 12:08:24 -0500 (EST) Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 38B12180E for ; Thu, 19 Dec 2024 12:08:08 -0500 (EST) Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-71fbb0d035dso509409a34.2 for ; Thu, 19 Dec 2024 09:08:08 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc9807c0fsm325938a34.41.2024.12.19.09.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:06 -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.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,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=gmail.com; s=20230601; t=1734628087; x=1735232887; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q5fgYIVbZi9WYYQNQ2uIJb3lDEE7CZnZhIdQym+FSuM=; b=DVcTVqrzyJS8in50X+Gzqmf75mMmPQ70yobGpaZXnSGCExGnwg7H4x2qTAmw95hedt D/8IFJ/3J0I+h4XRNiwuFz3rY9u2TpDnbpOtYaDPiPzBs8VPVxwSS13Sw4lrlG1DDPFF QDU9lsaZiH3zgwfBsN2Dzy5LUNOAZ3+pL7A7Lr4JEAJzxQGYQnQV5xb58CBW/MTmEj0x sRf4ISKquUGv/6GA1PRHasPvAZFbmvoGE8aJfmyuY+KrD0DMadPTm99IvTXq3+bGIe9I wJ2bWp7bVEXFKJ6fIOB+03MvX1teTV3rQ3tO0OvCS9vWt9S9pk30wjuz3OHRfh4dAoKo m84w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628087; x=1735232887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q5fgYIVbZi9WYYQNQ2uIJb3lDEE7CZnZhIdQym+FSuM=; b=X7zDH69gB7aetSbGc/UvCMuXx17NKJ6SCL1LzJDcTu7zEn4ZSx31s/7qI4c7Hka4Xk VFK2KG17actCxtVTvbTI53g/aHXD5CF5i7nxKhKirzsQ0F3/RLYRCFCr23CBPp7/o5hy SKBfHh+rpiJg99Wg6BsVLSZX5ZlvmsATLwQe2ZTivjZwW0AZSPaiUMvERRi45ZthDAJX 0LV8RsD5ZvUt3M8npvIbC0Ke0rwEHmYNxre8XhddwQkR3ozW4X9LQYcNTRQ058dXkGQX mpJBAc+XC6R6JizxJ8wrZWJaVYqt6K0m/dgH2x1KaaSWl/IQeP4rJwROkuKv8MSojFR4 bDCQ== X-Gm-Message-State: AOJu0YxOI8SW5j+oDk8PzYA4bc/6WStxJxjY4tafowYJI7IqH3Hv5S01 utyGvnwSNdBHurih12TcLKZY45IN6RVLyO8tKikvnIBYHzwUZEnRw+7d3BgC X-Gm-Gg: ASbGncuJlwrkF/aHNzQfB9tIFn5Juh2xhs3whAdEy/s8GhJVb59zfbupelxEfXVHrfK /17xiygDAfdf6Mrfq2PURzIFOexRkPmN6lNHuAEk9BCAefUNZz//dt8zjJATQ13ORqUtnT7fnLX eEHqvszoyHFDz8pziuypi/pjTTtSMqD/2/5pbP9FX9ZtufEoTmHBhalqdwAbNvwG1eXNuRtnhyk PSs9SZkgosOPbg1JQnJ2C2biyXtp/+zalihEcYC X-Google-Smtp-Source: AGHT+IG1pHGZC/zTl8ICiitalW2OQATzPg3LUGGaxb0teEeaPOXJNaUQewXCxhpgD8jazbrineNjlg== X-Received: by 2002:a05:6830:3493:b0:71d:5209:5cec with SMTP id 46e09a7af769-71fc4e39150mr2264267a34.3.1734628086955; Thu, 19 Dec 2024 09:08:06 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 08/11] ch: Enable logging for ch domains Date: Thu, 19 Dec 2024 11:07:53 -0600 Message-ID: <20241219170756.30810-9-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219170756.30810-1-praveenkpaladugu@gmail.com> References: <20241219170756.30810-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SIEWFYYSLF3N7OH2XAIGW4GXXUZPOG4V X-Message-ID-Hash: SIEWFYYSLF3N7OH2XAIGW4GXXUZPOG4V X-MailFrom: praveenkpaladugu@gmail.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 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 (Header signature does not verify) X-ZM-MESSAGEID: 1734628359442116600 Content-Type: text/plain; charset="utf-8" Use domainLogContext to enable logging for ch domain process during create and restore steps. Signed-off-by: Praveen K Paladugu --- src/ch/ch_conf.h | 2 ++ src/ch/ch_monitor.c | 5 ++++- src/ch/ch_monitor.h | 3 ++- src/ch/ch_process.c | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index bac82a0170..b08573476e 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -45,6 +45,8 @@ struct _virCHDriverConfig { =20 uid_t user; gid_t group; + + bool stdioLogD; }; =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHDriverConfig, virObjectUnref); diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 690aea37c8..c9b08b0f75 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -536,7 +536,7 @@ chMonitorCreateSocket(const char *socket_path) } =20 virCHMonitor * -virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg) +virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg, int logfile) { g_autoptr(virCHMonitor) mon =3D NULL; g_autoptr(virCommand) cmd =3D NULL; @@ -572,6 +572,9 @@ virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cf= g) } =20 cmd =3D virCommandNew(vm->def->emulator); + virCommandSetOutputFD(cmd, &logfile); + virCommandSetErrorFD(cmd, &logfile); + virCommandNonblockingFDs(cmd); virCommandSetUmask(cmd, 0x002); socket_fd =3D chMonitorCreateSocket(mon->socketpath); if (socket_fd < 0) { diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index 9ec58e5b20..5c02447116 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -103,7 +103,8 @@ struct _virCHMonitor { virCHMonitorThreadInfo *threads; }; =20 -virCHMonitor *virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg); +virCHMonitor *virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg, + int logfile); void virCHMonitorClose(virCHMonitor *mon); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHMonitor, virCHMonitorClose); =20 diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 61e263b62b..af44aa81a2 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -29,6 +29,7 @@ #include "ch_process.h" #include "domain_cgroup.h" #include "domain_interface.h" +#include "domain_logcontext.h" #include "viralloc.h" #include "virerror.h" #include "virfile.h" @@ -49,12 +50,13 @@ VIR_LOG_INIT("ch.ch_process"); =20 static virCHMonitor * virCHProcessConnectMonitor(virCHDriver *driver, - virDomainObj *vm) + virDomainObj *vm, + int logfile) { virCHMonitor *monitor =3D NULL; virCHDriverConfig *cfg =3D virCHDriverGetConfig(driver); =20 - monitor =3D virCHMonitorNew(vm, cfg); + monitor =3D virCHMonitorNew(vm, cfg, logfile); =20 virObjectUnref(cfg); return monitor; @@ -890,6 +892,8 @@ virCHProcessStart(virCHDriver *driver, g_autoptr(virCHDriverConfig) cfg =3D virCHDriverGetConfig(priv->driver= ); g_autofree int *nicindexes =3D NULL; size_t nnicindexes =3D 0; + g_autoptr(domainLogContext) logCtxt =3D NULL; + int logfile =3D -1; =20 if (virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -901,6 +905,16 @@ virCHProcessStart(virCHDriver *driver, return -1; } =20 + VIR_DEBUG("Creating domain log file for %s domain", vm->def->name); + if (!(logCtxt =3D domainLogContextNew(cfg->stdioLogD, cfg->logDir, + CH_DRIVER_NAME, + vm, driver->privileged, + vm->def->name))) { + virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); + return -1; + } + logfile =3D domainLogContextGetWriteFD(logCtxt); + if (virCHProcessPrepareDomain(vm) < 0) { return -1; } @@ -910,7 +924,7 @@ virCHProcessStart(virCHDriver *driver, =20 if (!priv->monitor) { /* And we can get the first monitor connection now too */ - if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm))) { + if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm, log= file))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create connection to CH socket")); goto cleanup; @@ -1047,10 +1061,22 @@ virCHProcessStartRestore(virCHDriver *driver, virDo= mainObj *vm, const char *from size_t ntapfds =3D 0; size_t nnicindexes =3D 0; int ret =3D -1; + g_autoptr(domainLogContext) logCtxt =3D NULL; + int logfile =3D -1; + + VIR_DEBUG("Creating domain log file for %s domain", vm->def->name); + if (!(logCtxt =3D domainLogContextNew(cfg->stdioLogD, cfg->logDir, + CH_DRIVER_NAME, + vm, driver->privileged, + vm->def->name))) { + virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); + return -1; + } + logfile =3D domainLogContextGetWriteFD(logCtxt); =20 if (!priv->monitor) { /* Get the first monitor connection if not already */ - if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm))) { + if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm, log= file))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create connection to CH socket")); goto cleanup; --=20 2.47.0