From nobody Sun Dec 22 08:07:24 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 1734619831464217.98621840793646; Thu, 19 Dec 2024 06:50:31 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 65BDC171E; Thu, 19 Dec 2024 09:50:30 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C889B16FD; Thu, 19 Dec 2024 09:46:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id ED4E11532; Thu, 19 Dec 2024 09:46:12 -0500 (EST) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 3BFD21532 for ; Thu, 19 Dec 2024 09:46:12 -0500 (EST) Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-71e17de2816so395371a34.0 for ; Thu, 19 Dec 2024 06:46:12 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46: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.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=1734619571; x=1735224371; 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=RH5Bts0bOL/qcyNVD8Jj6Uf2qyEH+GXsI7K71CekL1xzNySS8zJ+ZzZ4hQ946qKSBQ GX+GXzSlshh939umKbsVrsEFBOmXJmZAfLPqA1JGs/6bo061Dshf27IpHIvEXo9yoJ+f +U5a7m/whMTxOnsukpNdbNm7PhuqWTMY6x8kzB+h4pFyw6nDNBCZ6VXMgJA9QC/ovbEk 75IVkiv3OKVP21bPh7YpA9mdJjBGe65zvOO5LC+GSZQ7CgtRtawJPZ1/4Ih6kUgeEoJ/ eKQb4WJk8SRoVjlnNcQzUtFBc0TxDHAUFlqmQpu/YfQdKEdYW32O/htYLiQJcuHzS3Ol TEtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619571; x=1735224371; 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=dZNVZBn5mbD94Htxivj6SCxQ/1W/79u0yi6/thnPIUSH4dhCNt7bwq9LV/LR9JsAbT 8rpfvEhX128ko/69pXLHOyloHWW40VUS5hDpMqpZHo0nSSjtmnj5EjyUQ0+HjQ6JmW1R JM4Igxcqa0P8fLv5GttNERLdguPR0Xx13w4JDLvnmSGTKzMBxkaf2LWAQm4PtlwmxAfC bqS5IJI5XK7QhyGBX4qIQ5FBfqX+AAl2XohW7CM2/O1yW+tyG7lc5+EIf3zy91DBtmMF 7Icx757cjqw36GqxqEXF6xZC+uK94+2V83M2L5zJtXzE2rUru/5q1hQgSNfopCKxP611 gIZg== X-Gm-Message-State: AOJu0YzcPAiqNiEI6P6gm58X4XLQdFv5tSbS8EJvv30p9yBfADWLFkJ4 TkI/7IGiGJdeksOkcMXuT/hnB5AMwuF8JR7nnprNFuLNjVTjWTHNaik4h+IS X-Gm-Gg: ASbGnct/ITrxhfwjGKrRBRkR87sjASZ9nL2pTrdV78Sm/Dy1rlAdjQI0iSBFAGUG1nd X29tL3ymhEVw4q4tcANMPsac4nXlQBBaDKUzPD+PkPaBNZN+/cLu+7a1MBcHqdUKcWWlz1yv8ke bo3vzRPGXB9w9z8PBv5008cIDVAFuzQJFYyLsVUAr/3iSdu/FpDvznxD/63x4P8z7rmh7eL830V g6aFlobdKRUlf61lTheg966Yk2ytN/a6EGZnZsq X-Google-Smtp-Source: AGHT+IFI33j61Wy5rvgX2Vkfc5pWTY9McPqxiuajAj4HesnXbUiqPChvH0M0xpuutuc0fAWsI/KfTA== X-Received: by 2002:a05:6830:90a:b0:71d:e900:2322 with SMTP id 46e09a7af769-71fb757abf7mr3818209a34.8.1734619571326; Thu, 19 Dec 2024 06:46:11 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 08/10] ch: Enable logging for ch domains Date: Thu, 19 Dec 2024 08:45:59 -0600 Message-ID: <20241219144601.16394-9-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GVREOZ6TKTNR7CZFPLF2UJOQIUSLUVXC X-Message-ID-Hash: GVREOZ6TKTNR7CZFPLF2UJOQIUSLUVXC 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: 1734619832642116600 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