From nobody Sun Dec 22 07:12:31 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 1734628306801579.3891320186738; Thu, 19 Dec 2024 09:11:46 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5741F1893; Thu, 19 Dec 2024 12:11:25 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BC129188F; Thu, 19 Dec 2024 12:08:21 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5E1E9181A; Thu, 19 Dec 2024 12:08:17 -0500 (EST) Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 BEBF11799 for ; Thu, 19 Dec 2024 12:08:05 -0500 (EST) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5f2b21a0784so213013eaf.1 for ; Thu, 19 Dec 2024 09:08:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08: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=-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=1734628084; x=1735232884; 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=IKm9XzlgxuSzN3Y1AVkhCqeCv/sYl2/8Rcp2mxnmRF4=; b=WHjuWXy13+WcMPnoy92XwfO1LtB423pw/ci1nm1TubsphgqaoC2yV5DE643J+106EW gqvtiH8WkgVn2hAIT5GrJP5sEHeJ34LgWB8FR0+asQTWbs2+V/8q8tbKwshCOBPgP8Wz NPyC5TfM50V/xRZLocArhMoCjJPxWJtDJBJ8I5fyLc2jhsCVY8RNVl/LE1U+KIYhlHmL L7cSp8jlhxRieeMgZh45KLQyoZc9qiW/V/xTred+tt5phA+hONjzzyxzwfZGxNLyCTKy jbKQWnEoD8RHRlJNz3r1rDJDH8+2v+josbe2fy65l6oV8Jh567G80wD0HiktDj+q9oVG PoFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628084; x=1735232884; 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=IKm9XzlgxuSzN3Y1AVkhCqeCv/sYl2/8Rcp2mxnmRF4=; b=Vt/J/87rahEJpV/TTvQZQEdGmO1Y+HgOvwPkmBfoW6CZUaB+BsQT6QCfZS005nR4+O yhPWBTI1TcCMlTagtgAy+pMzPB9SXx1DvE8r1TOYzEX6Ieqxp7bAx38GSD6DYoIS4EEh RB71Oc5lzn+4I7lhgrXQtc43N/wO+KvmnVH4YG+eO4AYWGlNfei4BXt2KLVWuNb+KkB6 RM9Gs3sGO55JeE3RlWaTY8R6wHMjb+98wBKo3ISTmuiPk2Zw+X11eaV7fdWlFmr31tp6 nT9ylObyyrD3bgC6KYLDjdGCx98LmSSWTy4i7ZoGzN08d8lTFMU/FHZ1Nv/8PXuUF9iv kovg== X-Gm-Message-State: AOJu0YzjRZ9qzBVB+5JkeOTE9tLjlTggl4X+8B/Jk2RvWj+G9uab1z7r 2yf5dezdDcjFo6BMTuoIvGDLT39WB0Z0axGxUga2F9Cbnzc0/17QwWxFVAKL X-Gm-Gg: ASbGncvZgoUw1wRsyVG68+1ra2/kBIcO6HMXuZCM6YmS4kCnNGA7looz9IB+zAQ7q6E OWknnSQfzXRxmNBrJZa+QJrx2nNdTrLrOH2JThLpROS2qDONsCq//kPH9UI+GTPS5Edc0dEavQ3 hZa+/FejgNy8DauXd5Dwk2mkrl4/DK60Q7U9fSlAvShdGiVeFRdj5nwdcEoDoQtNHkC7bm923A1 derb1t7OCy83ZExCT9tX3N7DzmCBLgZ2STWj6bI X-Google-Smtp-Source: AGHT+IEOyhxZqkcRjEkK7NDYsyEwC1JA/OOMH89oyeTSZ0N0UUQHvMkI5jbmj7/IMTVTCJuch8cbrQ== X-Received: by 2002:a05:6870:ed86:b0:29e:80d8:31a9 with SMTP id 586e51a60fabf-2a7b2ff12f7mr4434730fac.2.1734628084513; Thu, 19 Dec 2024 09:08:04 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 06/11] qemu: Modify qemu driver to use domainLogContext Date: Thu, 19 Dec 2024 11:07:51 -0600 Message-ID: <20241219170756.30810-7-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: XMACFZADEBRBLGT24INWFYRV7LVVPKNZ X-Message-ID-Hash: XMACFZADEBRBLGT24INWFYRV7LVVPKNZ 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: 1734628309115116600 Content-Type: text/plain; charset="utf-8" Modify qemu driver to use domainLogcontext instead of qemuLogContext. Signed-off-by: Praveen K Paladugu --- src/qemu/qemu_domain.c | 28 ++++++++++++------------- src/qemu/qemu_domain.h | 12 +++++------ src/qemu/qemu_nbdkit.c | 12 +++++++---- src/qemu/qemu_process.c | 45 ++++++++++++++++++++++------------------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f15ba58179..c7d7ac26ce 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5399,7 +5399,7 @@ static void G_GNUC_PRINTF(5, 6) qemuDomainObjTaintMsg(virQEMUDriver *driver, virDomainObj *obj, virDomainTaintFlags taint, - qemuLogContext *logCtxt, + domainLogContext *logCtxt, const char *fmt, ...) { virErrorPtr orig_err =3D NULL; @@ -5452,12 +5452,12 @@ qemuDomainObjTaintMsg(virQEMUDriver *driver, goto cleanup; =20 if (logCtxt) { - rc =3D qemuLogContextWrite(logCtxt, - "%s: Domain id=3D%d is tainted: %s%s%s%s\= n", - timestamp, - obj->def->id, - virDomainTaintTypeToString(taint), - extraprefix, extramsg, extrasuffix); + rc =3D domainLogContextWrite(logCtxt, + "%s: Domain id=3D%d is tainted: %s%s%s%= s\n", + timestamp, + obj->def->id, + virDomainTaintTypeToString(taint), + extraprefix, extramsg, extrasuffix); } else { rc =3D qemuDomainLogAppendMessage(driver, obj, "%s: Domain id=3D%d is tainted: %s= %s%s%s\n", @@ -5478,7 +5478,7 @@ qemuDomainObjTaintMsg(virQEMUDriver *driver, void qemuDomainObjTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainTaintFlags taint, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { qemuDomainObjTaintMsg(driver, obj, taint, logCtxt, NULL); qemuDomainSaveStatus(obj); @@ -5487,7 +5487,7 @@ void qemuDomainObjTaint(virQEMUDriver *driver, static void qemuDomainObjCheckMachineTaint(virQEMUDriver *driver, virDomainObj *obj, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { qemuDomainObjPrivate *priv =3D obj->privateData; virQEMUCaps *qemuCaps =3D priv->qemuCaps; @@ -5505,7 +5505,7 @@ qemuDomainObjCheckMachineTaint(virQEMUDriver *driver, static void qemuDomainObjCheckCPUTaint(virQEMUDriver *driver, virDomainObj *obj, - qemuLogContext *logCtxt, + domainLogContext *logCtxt, bool incomingMigration) { qemuDomainObjPrivate *priv =3D obj->privateData; @@ -5537,7 +5537,7 @@ qemuDomainObjCheckCPUTaint(virQEMUDriver *driver, =20 void qemuDomainObjCheckTaint(virQEMUDriver *driver, virDomainObj *obj, - qemuLogContext *logCtxt, + domainLogContext *logCtxt, bool incomingMigration) { size_t i; @@ -5593,7 +5593,7 @@ void qemuDomainObjCheckTaint(virQEMUDriver *driver, void qemuDomainObjCheckDiskTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainDiskDef *disk, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { if (disk->rawio =3D=3D VIR_TRISTATE_BOOL_YES) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, @@ -5610,7 +5610,7 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriver *drive= r, void qemuDomainObjCheckHostdevTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainHostdevDef *hostdev, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { if (!virHostdevIsSCSIDevice(hostdev)) return; @@ -5623,7 +5623,7 @@ void qemuDomainObjCheckHostdevTaint(virQEMUDriver *dr= iver, void qemuDomainObjCheckNetTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainNetDef *net, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { /* script is only useful for NET_TYPE_ETHERNET (qemu) and * NET_TYPE_BRIDGE (xen), but could be (incorrectly) specified for diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 86e24ad54b..04577f1297 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -26,13 +26,13 @@ #include "virperf.h" #include "domain_addr.h" #include "domain_conf.h" +#include "domain_logcontext.h" #include "qemu_monitor.h" #include "qemu_agent.h" #include "qemu_blockjob.h" #include "qemu_domainjob.h" #include "qemu_conf.h" #include "qemu_capabilities.h" -#include "qemu_logcontext.h" #include "qemu_migration_params.h" #include "qemu_nbdkit.h" #include "qemu_slirp.h" @@ -641,24 +641,24 @@ char *qemuDomainDefFormatLive(virQEMUDriver *driver, void qemuDomainObjTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainTaintFlags taint, - qemuLogContext *logCtxt); + domainLogContext *logCtxt); =20 void qemuDomainObjCheckTaint(virQEMUDriver *driver, virDomainObj *obj, - qemuLogContext *logCtxt, + domainLogContext *logCtxt, bool incomingMigration); void qemuDomainObjCheckDiskTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainDiskDef *disk, - qemuLogContext *logCtxt); + domainLogContext *logCtxt); void qemuDomainObjCheckHostdevTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainHostdevDef *disk, - qemuLogContext *logCtxt); + domainLogContext *logCtxt); void qemuDomainObjCheckNetTaint(virQEMUDriver *driver, virDomainObj *obj, virDomainNetDef *net, - qemuLogContext *logCtxt); + domainLogContext *logCtxt); =20 int qemuDomainLogAppendMessage(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c index f099f35e1e..65c98de017 100644 --- a/src/qemu/qemu_nbdkit.c +++ b/src/qemu/qemu_nbdkit.c @@ -1177,6 +1177,7 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc, virQEMUDriver *driver) { g_autoptr(virCommand) cmd =3D NULL; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); int rc; int exitstatus =3D 0; g_autofree char *errbuf =3D NULL; @@ -1185,7 +1186,7 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc, g_autofree char *uristring =3D NULL; g_autofree char *basename =3D g_strdup_printf("%s-nbdkit-%i", vm->def-= >name, proc->source->id); int logfd =3D -1; - g_autoptr(qemuLogContext) logContext =3D NULL; + g_autoptr(domainLogContext) logContext =3D NULL; #if WITH_NBDKIT struct nbd_handle *nbd =3D NULL; #endif @@ -1200,12 +1201,15 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc, if (!(cmd =3D qemuNbdkitProcessBuildCommand(proc))) return -1; =20 - if (!(logContext =3D qemuLogContextNew(driver, vm, basename))) { + if (!(logContext =3D domainLogContextNew(cfg->stdioLogD, cfg->logDir, + QEMU_DRIVER_NAME, + vm, driver->privileged, + basename))) { virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); return -1; } =20 - logfd =3D qemuLogContextGetWriteFD(logContext); + logfd =3D domainLogContextGetWriteFD(logContext); =20 VIR_DEBUG("starting nbdkit process for %s", qemuBlockStorageSourceGetS= torageNodename(proc->source)); virCommandSetErrorFD(cmd, &logfd); @@ -1283,7 +1287,7 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc, if ((uri =3D qemuBlockStorageSourceGetURI(proc->source))) uristring =3D virURIFormat(uri); =20 - if (qemuLogContextReadFiltered(logContext, &errbuf, 1024) < 0) + if (domainLogContextReadFiltered(logContext, &errbuf, 1024) < 0) VIR_WARN("Unable to read from nbdkit log"); =20 virReportError(VIR_ERR_OPERATION_FAILED, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5f2e278156..c7240f3ae4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1840,7 +1840,7 @@ qemuProcessMonitorReportLogError(qemuMonitor *mon, static void qemuProcessMonitorLogFree(void *opaque) { - qemuLogContext *logCtxt =3D opaque; + domainLogContext *logCtxt =3D opaque; g_clear_object(&logCtxt); } =20 @@ -1866,7 +1866,7 @@ static int qemuConnectMonitor(virQEMUDriver *driver, virDomainObj *vm, int asyncJob, - qemuLogContext *logCtxt, + domainLogContext *logCtxt, bool reconnect) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -1918,13 +1918,13 @@ qemuConnectMonitor(virQEMUDriver *driver, =20 =20 static int -qemuProcessReportLogError(qemuLogContext *logCtxt, +qemuProcessReportLogError(domainLogContext *logCtxt, const char *msgprefix) { g_autofree char *logmsg =3D NULL; =20 /* assume that 1024 chars of qemu log is the right balance */ - if (qemuLogContextReadFiltered(logCtxt, &logmsg, 1024) < 0) + if (domainLogContextReadFiltered(logCtxt, &logmsg, 1024) < 0) return -1; =20 virResetLastError(); @@ -1943,7 +1943,7 @@ qemuProcessMonitorReportLogError(qemuMonitor *mon G_G= NUC_UNUSED, const char *msg, void *opaque) { - qemuLogContext *logCtxt =3D opaque; + domainLogContext *logCtxt =3D opaque; qemuProcessReportLogError(logCtxt, msg); } =20 @@ -2244,7 +2244,7 @@ static int qemuProcessWaitForMonitor(virQEMUDriver *driver, virDomainObj *vm, int asyncJob, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { int ret =3D -1; g_autoptr(GHashTable) info =3D NULL; @@ -4740,7 +4740,7 @@ static void qemuLogOperation(virDomainObj *vm, const char *msg, virCommand *cmd, - qemuLogContext *logCtxt) + domainLogContext *logCtxt) { g_autofree char *timestamp =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; @@ -4754,20 +4754,20 @@ qemuLogOperation(virDomainObj *vm, if ((timestamp =3D virTimeStringNow()) =3D=3D NULL) return; =20 - if (qemuLogContextWrite(logCtxt, - "%s: %s %s, qemu version: %d.%d.%d%s, kernel: = %s, hostname: %s\n", - timestamp, msg, VIR_LOG_VERSION_STRING, - (qemuVersion / 1000000) % 1000, - (qemuVersion / 1000) % 1000, - qemuVersion % 1000, - NULLSTR_EMPTY(package), - uts.release, - NULLSTR_EMPTY(hostname)) < 0) + if (domainLogContextWrite(logCtxt, + "%s: %s %s, qemu version: %d.%d.%d%s, kernel= : %s, hostname: %s\n", + timestamp, msg, VIR_LOG_VERSION_STRING, + (qemuVersion / 1000000) % 1000, + (qemuVersion / 1000) % 1000, + qemuVersion % 1000, + NULLSTR_EMPTY(package), + uts.release, + NULLSTR_EMPTY(hostname)) < 0) return; =20 if (cmd) { g_autofree char *args =3D virCommandToString(cmd, true); - qemuLogContextWrite(logCtxt, "%s\n", args); + domainLogContextWrite(logCtxt, "%s\n", args); } } =20 @@ -7776,7 +7776,7 @@ qemuProcessLaunch(virConnectPtr conn, int ret =3D -1; int rv; int logfile =3D -1; - g_autoptr(qemuLogContext) logCtxt =3D NULL; + g_autoptr(domainLogContext) logCtxt =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCommand) cmd =3D NULL; struct qemuProcessHookData hookData; @@ -7826,11 +7826,14 @@ qemuProcessLaunch(virConnectPtr conn, hookData.cfg =3D cfg; =20 VIR_DEBUG("Creating domain log file"); - if (!(logCtxt =3D qemuLogContextNew(driver, vm, vm->def->name))) { + if (!(logCtxt =3D domainLogContextNew(cfg->stdioLogD, cfg->logDir, + QEMU_DRIVER_NAME, + vm, driver->privileged, + vm->def->name))) { virLastErrorPrefixMessage("%s", _("can't connect to virtlogd")); goto cleanup; } - logfile =3D qemuLogContextGetWriteFD(logCtxt); + logfile =3D domainLogContextGetWriteFD(logCtxt); =20 if (qemuProcessGenID(vm, flags) < 0) goto cleanup; @@ -7866,7 +7869,7 @@ qemuProcessLaunch(virConnectPtr conn, =20 qemuDomainObjCheckTaint(driver, vm, logCtxt, incoming !=3D NULL); =20 - qemuLogContextMarkPosition(logCtxt); + domainLogContextMarkPosition(logCtxt); =20 if (qemuProcessEnableDomainNamespaces(driver, vm) < 0) goto cleanup; --=20 2.47.0