From nobody Sun Dec 22 01:57:13 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 1734628149266595.5149768989447; Thu, 19 Dec 2024 09:09:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 32AAE17CD; Thu, 19 Dec 2024 12:09:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 52C68178D; Thu, 19 Dec 2024 12:08:06 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 19A8E167B; Thu, 19 Dec 2024 12:08:01 -0500 (EST) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 1B7A81786 for ; Thu, 19 Dec 2024 12:08:00 -0500 (EST) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3eb98b3b63dso236972b6e.1 for ; Thu, 19 Dec 2024 09:08:00 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc9807c0fsm325938a34.41.2024.12.19.09.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:07:58 -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.7 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_H2,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=1734628079; x=1735232879; 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=vLoipIr19aqgOYUoX04EOX9OlfX16/Rd2xB6gmj+nmI=; b=IQTP96wx+npAGGrOAJ9aL516YaHlqfWm+pl4Vs1CuQSqAh7zBomQRzkPV2pCLl/mlf VA5vsPjOApYIOj1JmNNwMOB1Vh49zo+kwbDDIUioVcNG0nuj02TgDHQXzo069RQDK4Es 1d2OSMVGN4hjNG9JQ+lfW/ZTCzI33q9ZQI31e51zaaxcNH1H+gmsTJDqNh9ALyGiknPt Ra8I4qe5I5/QcXcBX0uU+tZ8k4jYFeMlnq1ISEmw3DJ+MfigZHqyXp+Oe6sPMSRmZyjw 70+Uq12xU+ziC6RIOfsqpZr3HYqmHuTOq/iO+cu8Ng1zrDGJJn/yDyefdhwVrBk5oWyM Pdkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628079; x=1735232879; 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=vLoipIr19aqgOYUoX04EOX9OlfX16/Rd2xB6gmj+nmI=; b=Q9DIT+aMaXrlmn5zsK+ndxp2JdV3ZsgvtToTLq/VN/FPDoWFbJ1/NK1zq6G6QYK26V jdIKoAaas6h6dv5CZUBXDxGpVSk0RAy5BTxCymNMsOYpuVuCD6FmDd9fcR/du89BurVe eg8K33arSG/eJJaBWeMfRCJFKN2/YgXL3jmf4PnoLtMC/p3pGZVgkLecjBj+I4hBSf9v glXxdvVIcfNOxQZS/3ZL1MB7cEV74nf71jfowcWvKMnxvugM+D3VKzXWeYApdfhoukdc 1VRkJwsyQ0F5fthWP3r9RI9EeVL/KhGyoS/t1/naADzP5FRWGSlsQ4rV1RgrFy7VCV17 CapA== X-Gm-Message-State: AOJu0Ywi0at8u4sjTezEGDDS3gI4yOCaGn2Ulej9FTLsmSzCQtqO9DBa /+F4XciXsGtDLNZUKkUvkTUS2fh4UgFOQJy/DtRE6Y7BbAyVKx9ZPfpzLtg/ X-Gm-Gg: ASbGncumbBRNjzjKx/9I9b0obQO70ftXvSE6OCw4eZu7GCZHKVi03cbDE5yDmwO2jHE mkQ6lsTf0xcQm+qRkwYpdJuDePgaLYA+81ju1VDkiKoMfYuAfFFID2R5S9J1KyguuVLLuog+DUR aDolhA2PnQ+T+WmmXsRrc/fo24NC2KWJ7gCyUhxjhZCK5gPZXUbQQXKIpNOdlhW0qAqX6hSugrT e3wHllULmKUJ4QRqA/4AdNWMTz0Hp2eClk8z1vi X-Google-Smtp-Source: AGHT+IEeuE8AAp+rjL10P1HNwR/M9kEWZiOk1ECJ6M90j5JcvGbkC7v7WpGObzX8xze19FacBVXw8g== X-Received: by 2002:a05:6808:e88:b0:3eb:5d13:f688 with SMTP id 5614622812f47-3ecdcd55d14mr2851900b6e.26.1734628078811; Thu, 19 Dec 2024 09:07:58 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 01/11] hypervisor: copy qemu log context mgmt to hypervisor Date: Thu, 19 Dec 2024 11:07:46 -0600 Message-ID: <20241219170756.30810-2-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: DM2Z3ZSPDLMSQGU6B3WZOTY2FZUYERH3 X-Message-ID-Hash: DM2Z3ZSPDLMSQGU6B3WZOTY2FZUYERH3 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: 1734628151146116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu --- po/POTFILES | 1 + src/hypervisor/domain_logcontext.c | 329 +++++++++++++++++++++++++++++ src/hypervisor/domain_logcontext.h | 41 ++++ 3 files changed, 371 insertions(+) create mode 100644 src/hypervisor/domain_logcontext.c create mode 100644 src/hypervisor/domain_logcontext.h diff --git a/po/POTFILES b/po/POTFILES index 3514aa3dca..1d3c3c0a81 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -94,6 +94,7 @@ src/hyperv/hyperv_util.c src/hyperv/hyperv_wmi.c src/hypervisor/domain_cgroup.c src/hypervisor/domain_driver.c +src/hypervisor/domain_logcontext.c src/hypervisor/domain_interface.c src/hypervisor/virhostdev.c src/interface/interface_backend_netcf.c diff --git a/src/hypervisor/domain_logcontext.c b/src/hypervisor/domain_log= context.c new file mode 100644 index 0000000000..7932cf7712 --- /dev/null +++ b/src/hypervisor/domain_logcontext.c @@ -0,0 +1,329 @@ +/* + * domain_logcontext.c: QEMU log context + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "qemu_logcontext.h" +#include "viralloc.h" +#include "virlog.h" +#include "virstring.h" +#include "virutil.h" + +#include + +#define VIR_FROM_THIS VIR_FROM_QEMU + +VIR_LOG_INIT("qemu.qemu_logcontext"); + + +struct _qemuLogContext { + GObject parent; + + int writefd; + int readfd; /* Only used if manager =3D=3D NULL */ + off_t pos; + ino_t inode; /* Only used if manager !=3D NULL */ + char *path; + virLogManager *manager; +}; + +G_DEFINE_TYPE(qemuLogContext, qemu_log_context, G_TYPE_OBJECT); + +static void +qemuLogContextFinalize(GObject *obj); + + +static void +qemu_log_context_init(qemuLogContext *logctxt G_GNUC_UNUSED) +{ +} + + +static void +qemu_log_context_class_init(qemuLogContextClass *klass) +{ + GObjectClass *obj =3D G_OBJECT_CLASS(klass); + + obj->finalize =3D qemuLogContextFinalize; +} + + +static void +qemuLogContextFinalize(GObject *object) +{ + qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(object); + VIR_DEBUG("ctxt=3D%p", ctxt); + + virLogManagerFree(ctxt->manager); + VIR_FREE(ctxt->path); + VIR_FORCE_CLOSE(ctxt->writefd); + VIR_FORCE_CLOSE(ctxt->readfd); + G_OBJECT_CLASS(qemu_log_context_parent_class)->finalize(object); +} + + +qemuLogContext * +qemuLogContextNew(virQEMUDriver *driver, + virDomainObj *vm, + const char *basename) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(g_object_new(QEMU_TYPE_LOG_C= ONTEXT, NULL)); + + VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, cfg->stdioLogD); + ctxt->writefd =3D -1; + ctxt->readfd =3D -1; + + ctxt->path =3D g_strdup_printf("%s/%s.log", cfg->logDir, basename); + + if (cfg->stdioLogD) { + ctxt->manager =3D virLogManagerNew(driver->privileged); + if (!ctxt->manager) + goto error; + + ctxt->writefd =3D virLogManagerDomainOpenLogFile(ctxt->manager, + "qemu", + vm->def->uuid, + vm->def->name, + ctxt->path, + 0, + &ctxt->inode, + &ctxt->pos); + if (ctxt->writefd < 0) + goto error; + } else { + if ((ctxt->writefd =3D open(ctxt->path, O_WRONLY | O_CREAT | O_APP= END, S_IRUSR | S_IWUSR)) < 0) { + virReportSystemError(errno, _("failed to create logfile %1$s"), + ctxt->path); + goto error; + } + if (virSetCloseExec(ctxt->writefd) < 0) { + virReportSystemError(errno, _("failed to set close-on-exec fla= g on %1$s"), + ctxt->path); + goto error; + } + + /* For unprivileged startup we must truncate the file since + * we can't rely on logrotate. We don't use O_TRUNC since + * it is better for SELinux policy if we truncate afterwards */ + if (!driver->privileged && + ftruncate(ctxt->writefd, 0) < 0) { + virReportSystemError(errno, _("failed to truncate %1$s"), + ctxt->path); + goto error; + } + + if ((ctxt->readfd =3D open(ctxt->path, O_RDONLY)) < 0) { + virReportSystemError(errno, _("failed to open logfile %1$s"), + ctxt->path); + goto error; + } + if (virSetCloseExec(ctxt->readfd) < 0) { + virReportSystemError(errno, _("failed to set close-on-exec fla= g on %1$s"), + ctxt->path); + goto error; + } + + if ((ctxt->pos =3D lseek(ctxt->writefd, 0, SEEK_END)) < 0) { + virReportSystemError(errno, _("failed to seek in log file %1$s= "), + ctxt->path); + goto error; + } + } + + return ctxt; + + error: + g_clear_object(&ctxt); + return NULL; +} + + +int +qemuLogContextWrite(qemuLogContext *ctxt, + const char *fmt, ...) +{ + va_list argptr; + g_autofree char *message =3D NULL; + int ret =3D -1; + + va_start(argptr, fmt); + + message =3D g_strdup_vprintf(fmt, argptr); + if (!ctxt->manager && + lseek(ctxt->writefd, 0, SEEK_END) < 0) { + virReportSystemError(errno, "%s", + _("Unable to seek to end of domain logfile")); + goto cleanup; + } + if (safewrite(ctxt->writefd, message, strlen(message)) < 0) { + virReportSystemError(errno, "%s", + _("Unable to write to domain logfile")); + goto cleanup; + } + + ret =3D 0; + + cleanup: + va_end(argptr); + return ret; +} + + +ssize_t +qemuLogContextRead(qemuLogContext *ctxt, + char **msg) +{ + char *buf; + size_t buflen; + + VIR_DEBUG("Context read %p manager=3D%p inode=3D%llu pos=3D%llu", + ctxt, ctxt->manager, + (unsigned long long)ctxt->inode, + (unsigned long long)ctxt->pos); + + if (ctxt->manager) { + buf =3D virLogManagerDomainReadLogFile(ctxt->manager, + ctxt->path, + ctxt->inode, + ctxt->pos, + 1024 * 128, + 0); + if (!buf) + return -1; + buflen =3D strlen(buf); + } else { + ssize_t got; + + buflen =3D 1024 * 128; + + /* Best effort jump to start of messages */ + ignore_value(lseek(ctxt->readfd, ctxt->pos, SEEK_SET)); + + buf =3D g_new0(char, buflen); + + got =3D saferead(ctxt->readfd, buf, buflen - 1); + if (got < 0) { + VIR_FREE(buf); + virReportSystemError(errno, "%s", + _("Unable to read from log file")); + return -1; + } + + buf[got] =3D '\0'; + + buf =3D g_renew(char, buf, got + 1); + buflen =3D got; + } + + *msg =3D buf; + + return buflen; +} + + +/** + * qemuLogContextFilter: Read and filter log for relevant messages + * @ctxt: the domain log context + * @msg: pointer to buffer to store the read messages in + * @max: maximum length of the message returned in @msg after filtering + * + * Reads log output from @ctxt and filters it. Skips messages not produced= by + * the target executable or irrelevant messages. If @max is not zero, @buf= will + * contain at most @max characters from the end of the log and @buf will s= tart + * after a new line if possible. + */ +int +qemuLogContextReadFiltered(qemuLogContext *ctxt, + char **msg, + size_t max) +{ + char *buf; + char *eol; + char *filter_next; + size_t skip; + ssize_t got; + + if ((got =3D qemuLogContextRead(ctxt, &buf)) < 0) + return -1; + + /* Filter out debug messages from intermediate libvirt process */ + filter_next =3D buf; + while ((eol =3D strchr(filter_next, '\n'))) { + *eol =3D '\0'; + if (virLogProbablyLogMessage(filter_next) || + strstr(filter_next, "char device redirected to")) { + skip =3D (eol + 1) - filter_next; + memmove(filter_next, eol + 1, buf + got - eol); + got -=3D skip; + } else { + filter_next =3D eol + 1; + *eol =3D '\n'; + } + } + + if (got > 0 && + buf[got - 1] =3D=3D '\n') { + buf[got - 1] =3D '\0'; + got--; + } + + if (max > 0 && got > max) { + skip =3D got - max; + + if (buf[skip - 1] !=3D '\n' && + (eol =3D strchr(buf + skip, '\n')) && + !virStringIsEmpty(eol + 1)) + skip =3D eol + 1 - buf; + + memmove(buf, buf + skip, got - skip + 1); + got -=3D skip; + } + + buf =3D g_renew(char, buf, got + 1); + *msg =3D buf; + return 0; +} + + +int +qemuLogContextGetWriteFD(qemuLogContext *ctxt) +{ + return ctxt->writefd; +} + + +void +qemuLogContextMarkPosition(qemuLogContext *ctxt) +{ + if (ctxt->manager) + virLogManagerDomainGetLogFilePosition(ctxt->manager, + ctxt->path, + 0, + &ctxt->inode, + &ctxt->pos); + else + ctxt->pos =3D lseek(ctxt->writefd, 0, SEEK_END); +} + + +virLogManager * +qemuLogContextGetManager(qemuLogContext *ctxt) +{ + return ctxt->manager; +} diff --git a/src/hypervisor/domain_logcontext.h b/src/hypervisor/domain_log= context.h new file mode 100644 index 0000000000..572ac1026e --- /dev/null +++ b/src/hypervisor/domain_logcontext.h @@ -0,0 +1,41 @@ +/* + * domain_logcontext.h: QEMU log context + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include +#include "qemu_conf.h" +#include "logging/log_manager.h" + +#define QEMU_TYPE_LOG_CONTEXT qemu_log_context_get_type() +G_DECLARE_FINAL_TYPE(qemuLogContext, qemu_log_context, QEMU, LOG_CONTEXT, = GObject); + +qemuLogContext *qemuLogContextNew(virQEMUDriver *driver, + virDomainObj *vm, + const char *basename); +int qemuLogContextWrite(qemuLogContext *ctxt, + const char *fmt, ...) G_GNUC_PRINTF(2, 3); +ssize_t qemuLogContextRead(qemuLogContext *ctxt, + char **msg); +int qemuLogContextReadFiltered(qemuLogContext *ctxt, + char **msg, + size_t max); +int qemuLogContextGetWriteFD(qemuLogContext *ctxt); +void qemuLogContextMarkPosition(qemuLogContext *ctxt); + +virLogManager *qemuLogContextGetManager(qemuLogContext *ctxt); --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628179884371.69591322929796; Thu, 19 Dec 2024 09:09:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D864A1800; Thu, 19 Dec 2024 12:09:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E0F3217BE; Thu, 19 Dec 2024 12:08:07 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0F9A6167B; Thu, 19 Dec 2024 12:08:02 -0500 (EST) Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 497DE1786 for ; Thu, 19 Dec 2024 12:08:01 -0500 (EST) Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5f2dee7d218so402833eaf.2 for ; Thu, 19 Dec 2024 09:08:01 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc9807c0fsm325938a34.41.2024.12.19.09.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:07:59 -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=1734628080; x=1735232880; 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=/L3YHHfaSKNZsuWctr7Gl7+vimfIIkvrjqfcqA8pbnU=; b=KqPHmGnKUcFbWPPHeXDbOI9g1BV6JeUB6HgrKj3XWdcNI2Gtbz7pfD0KtFu3IerV9l wWguxhFvKEeZLCc9qKyc9DXzbhOqIkWnWwipntYk41llGR2eP9RWRM2xR+D30jG7lud6 eDgvz9iBDlSQ7hoJT4MeYTI1fXDaaS5LkBgsgB3fdyti9Mk2Tdl46PuMNWd6pCyWqu3E foUe56v6esXTYk3FH1GnFw53nJ9p5lvWjmH9VpSomCqKVsedwz1JWJOnwxmWi9SqBPyT PE/rwbzJBF8PrlC61r8kNMLK1Dh+cGZIec35bcfCSreZ6kPluofvPBnH85dX4Hnu1nNe A73g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628080; x=1735232880; 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=/L3YHHfaSKNZsuWctr7Gl7+vimfIIkvrjqfcqA8pbnU=; b=JwN4DKtxEBWgfdJJlVV1ceTX729b17OXEkhkJ5PJYz+qI3zBhvVYMzY0egHphTACFc j2EvEBxDSpXUXX9jI+FCld8C4RWpel4Zmg8y2wRFvYcFNpv9eP/G46Isn8XStMLHmCgl 4XIz6Zt88mix+o2nUr5f5OLVeVdxONxK2VvZc1zEaRFWXXVUSjTYVlSjbTtb2kIOdaEt GrD/m89tXmUbTTKppUcF2xQQPyYBpaK9JDJfdzSP2pEvs/CImpDS+SL1VISbb6xk5+TN vBi+N+kmZIPswD6880inDuaPNrvY4v5D14+HIPOW6NMQl4DsZjfwp3GX7+XPN0ntyIBx OXig== X-Gm-Message-State: AOJu0YzAc9uMRayCv4q2fkUmJRBIl1yyuB+gsNH2rzUs9kc1NgtXpc0T cRGy9wfb4m/QjOVP/u7h19ISHDXrJ3Nsa5A2QRegjrHju3o6hTRC048EzV7R X-Gm-Gg: ASbGncsnLCFqYC+Eife0d8stvE15tWJQssvbFPOStTdJRxJD8558e8RiUvdE92ehr8o NWSVAhGnhXT58xYQGXkmAcZ8RZYlqDOe6mkmmM9Y8p78rqVeiD4OFhICd/o90H8bXPiJrDU8iCy ZoFT0UnecyZ2oA2DknzJBQZimQ5wURU6aVOfj3NXFM7791qdKGgAONeJEkyy0UG4gZIwjSo4cur YSsFWCefaBcdkj6bU67il55qmg1CDRbaZ1bFv2Y X-Google-Smtp-Source: AGHT+IE26GGnQzWVkphoW8EOy7B4PrNHt9oyvXTwB+/xuwjoQFxiT+bpmenatSe7aUNpMQrrZLc94w== X-Received: by 2002:a05:6820:189a:b0:5f2:df4c:d4a6 with SMTP id 006d021491bc7-5f4c9ba26aamr4002798eaf.8.1734628080030; Thu, 19 Dec 2024 09:08:00 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 02/11] hypervisor: rename reference to qemu in domain_logcontext Date: Thu, 19 Dec 2024 11:07:47 -0600 Message-ID: <20241219170756.30810-3-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: 2TFZHF4MBBAT2WQPUY5J7ZHEHEFRMXKB X-Message-ID-Hash: 2TFZHF4MBBAT2WQPUY5J7ZHEHEFRMXKB 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: 1734628181210116600 Content-Type: text/plain; charset="utf-8" Rename all references to qemu within domain_logcontext files. Signed-off-by: Praveen K Paladugu --- src/hypervisor/domain_logcontext.c | 60 +++++++++++++++--------------- src/hypervisor/domain_logcontext.h | 32 ++++++++-------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/hypervisor/domain_logcontext.c b/src/hypervisor/domain_log= context.c index 7932cf7712..3776d68ab9 100644 --- a/src/hypervisor/domain_logcontext.c +++ b/src/hypervisor/domain_logcontext.c @@ -1,5 +1,5 @@ /* - * domain_logcontext.c: QEMU log context + * domain_logcontext.c: Domain log context * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,7 @@ =20 #include =20 -#include "qemu_logcontext.h" +#include "domain_logcontext.h" #include "viralloc.h" #include "virlog.h" #include "virstring.h" @@ -26,12 +26,12 @@ =20 #include =20 -#define VIR_FROM_THIS VIR_FROM_QEMU +#define VIR_FROM_THIS VIR_FROM_DOMAIN =20 -VIR_LOG_INIT("qemu.qemu_logcontext"); +VIR_LOG_INIT("domain.domain_logcontext"); =20 =20 -struct _qemuLogContext { +struct _domainLogContext { GObject parent; =20 int writefd; @@ -42,48 +42,48 @@ struct _qemuLogContext { virLogManager *manager; }; =20 -G_DEFINE_TYPE(qemuLogContext, qemu_log_context, G_TYPE_OBJECT); +G_DEFINE_TYPE(domainLogContext, domain_log_context, G_TYPE_OBJECT); =20 static void -qemuLogContextFinalize(GObject *obj); +domainLogContextFinalize(GObject *obj); =20 =20 static void -qemu_log_context_init(qemuLogContext *logctxt G_GNUC_UNUSED) +domain_log_context_init(domainLogContext *logctxt G_GNUC_UNUSED) { } =20 =20 static void -qemu_log_context_class_init(qemuLogContextClass *klass) +domain_log_context_class_init(domainLogContextClass *klass) { GObjectClass *obj =3D G_OBJECT_CLASS(klass); =20 - obj->finalize =3D qemuLogContextFinalize; + obj->finalize =3D domainLogContextFinalize; } =20 =20 static void -qemuLogContextFinalize(GObject *object) +domainLogContextFinalize(GObject *object) { - qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(object); + domainLogContext *ctxt =3D DOMAIN_LOG_CONTEXT(object); VIR_DEBUG("ctxt=3D%p", ctxt); =20 virLogManagerFree(ctxt->manager); VIR_FREE(ctxt->path); VIR_FORCE_CLOSE(ctxt->writefd); VIR_FORCE_CLOSE(ctxt->readfd); - G_OBJECT_CLASS(qemu_log_context_parent_class)->finalize(object); + G_OBJECT_CLASS(domain_log_context_parent_class)->finalize(object); } =20 =20 -qemuLogContext * -qemuLogContextNew(virQEMUDriver *driver, - virDomainObj *vm, - const char *basename) +domainLogContext * +domainLogContextNew(virQEMUDriver *driver, + virDomainObj *vm, + const char *basename) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(g_object_new(QEMU_TYPE_LOG_C= ONTEXT, NULL)); + domainLogContext *ctxt =3D DOMAIN_LOG_CONTEXT(g_object_new(DOMAIN_TYPE= _LOG_CONTEXT, NULL)); =20 VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, cfg->stdioLogD); ctxt->writefd =3D -1; @@ -155,8 +155,8 @@ qemuLogContextNew(virQEMUDriver *driver, =20 =20 int -qemuLogContextWrite(qemuLogContext *ctxt, - const char *fmt, ...) +domainLogContextWrite(domainLogContext *ctxt, + const char *fmt, ...) { va_list argptr; g_autofree char *message =3D NULL; @@ -186,8 +186,8 @@ qemuLogContextWrite(qemuLogContext *ctxt, =20 =20 ssize_t -qemuLogContextRead(qemuLogContext *ctxt, - char **msg) +domainLogContextRead(domainLogContext *ctxt, + char **msg) { char *buf; size_t buflen; @@ -238,7 +238,7 @@ qemuLogContextRead(qemuLogContext *ctxt, =20 =20 /** - * qemuLogContextFilter: Read and filter log for relevant messages + * domainLogContextFilter: Read and filter log for relevant messages * @ctxt: the domain log context * @msg: pointer to buffer to store the read messages in * @max: maximum length of the message returned in @msg after filtering @@ -249,9 +249,9 @@ qemuLogContextRead(qemuLogContext *ctxt, * after a new line if possible. */ int -qemuLogContextReadFiltered(qemuLogContext *ctxt, - char **msg, - size_t max) +domainLogContextReadFiltered(domainLogContext *ctxt, + char **msg, + size_t max) { char *buf; char *eol; @@ -259,7 +259,7 @@ qemuLogContextReadFiltered(qemuLogContext *ctxt, size_t skip; ssize_t got; =20 - if ((got =3D qemuLogContextRead(ctxt, &buf)) < 0) + if ((got =3D domainLogContextRead(ctxt, &buf)) < 0) return -1; =20 /* Filter out debug messages from intermediate libvirt process */ @@ -302,14 +302,14 @@ qemuLogContextReadFiltered(qemuLogContext *ctxt, =20 =20 int -qemuLogContextGetWriteFD(qemuLogContext *ctxt) +domainLogContextGetWriteFD(domainLogContext *ctxt) { return ctxt->writefd; } =20 =20 void -qemuLogContextMarkPosition(qemuLogContext *ctxt) +domainLogContextMarkPosition(domainLogContext *ctxt) { if (ctxt->manager) virLogManagerDomainGetLogFilePosition(ctxt->manager, @@ -323,7 +323,7 @@ qemuLogContextMarkPosition(qemuLogContext *ctxt) =20 =20 virLogManager * -qemuLogContextGetManager(qemuLogContext *ctxt) +domainLogContextGetManager(domainLogContext *ctxt) { return ctxt->manager; } diff --git a/src/hypervisor/domain_logcontext.h b/src/hypervisor/domain_log= context.h index 572ac1026e..8bb7c3d217 100644 --- a/src/hypervisor/domain_logcontext.h +++ b/src/hypervisor/domain_logcontext.h @@ -1,5 +1,5 @@ /* - * domain_logcontext.h: QEMU log context + * domain_logcontext.h: Domain log context * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,20 +22,20 @@ #include "qemu_conf.h" #include "logging/log_manager.h" =20 -#define QEMU_TYPE_LOG_CONTEXT qemu_log_context_get_type() -G_DECLARE_FINAL_TYPE(qemuLogContext, qemu_log_context, QEMU, LOG_CONTEXT, = GObject); +#define DOMAIN_TYPE_LOG_CONTEXT domain_log_context_get_type() +G_DECLARE_FINAL_TYPE(domainLogContext, domain_log_context, DOMAIN, LOG_CON= TEXT, GObject); =20 -qemuLogContext *qemuLogContextNew(virQEMUDriver *driver, - virDomainObj *vm, - const char *basename); -int qemuLogContextWrite(qemuLogContext *ctxt, - const char *fmt, ...) G_GNUC_PRINTF(2, 3); -ssize_t qemuLogContextRead(qemuLogContext *ctxt, - char **msg); -int qemuLogContextReadFiltered(qemuLogContext *ctxt, - char **msg, - size_t max); -int qemuLogContextGetWriteFD(qemuLogContext *ctxt); -void qemuLogContextMarkPosition(qemuLogContext *ctxt); +domainLogContext *domainLogContextNew(virQEMUDriver *driver, + virDomainObj *vm, + const char *basename); +int domainLogContextWrite(domainLogContext *ctxt, + const char *fmt, ...) G_GNUC_PRINTF(2, 3); +ssize_t domainLogContextRead(domainLogContext *ctxt, + char **msg); +int domainLogContextReadFiltered(domainLogContext *ctxt, + char **msg, + size_t max); +int domainLogContextGetWriteFD(domainLogContext *ctxt); +void domainLogContextMarkPosition(domainLogContext *ctxt); =20 -virLogManager *qemuLogContextGetManager(qemuLogContext *ctxt); +virLogManager *domainLogContextGetManager(domainLogContext *ctxt); --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628209979565.3791478760794; Thu, 19 Dec 2024 09:10:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id F3477180A; Thu, 19 Dec 2024 12:10:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 09AF017DF; Thu, 19 Dec 2024 12:08:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E567C1786; Thu, 19 Dec 2024 12:08:02 -0500 (EST) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 1FA2B167B for ; Thu, 19 Dec 2024 12:08:02 -0500 (EST) Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-71e15717a2dso502567a34.3 for ; Thu, 19 Dec 2024 09:08:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:00 -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=1734628081; x=1735232881; 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=RMwdLvBqzR51bCQ8OnjTHZWcXmN8hdkyA5thOHZ7LlY=; b=XdSr7IPIAnB01vH/bnePSHErfuvhI6FnKeru7XpHz9k5UsAE5864eEqyq+hlfriRrF BEb6n0+xjvvWTulSNO8Bzx7KQweqy/Yu7eBqoNeaS/KgTQO57x5N5S53QMfPE95ydXGe S4IezxHB64FsqJmoeKrg1M0Lho11wMUH8x5IPPl5bF3x68mt0zIBHaeDh07pcNMsWVbd QHn6yxP5i6lyiq/cExcb45EEFUYYm2g301PHKID/gUUkwb9gD6+PFtLVk7QyL5oZJjAq /xfk5y++wc9ps+Fju4NNbUnT5ctT2x8iR9SoQfySCL6RbKhZuIG7ADdGMv7qnLEf7NME 2R7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628081; x=1735232881; 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=RMwdLvBqzR51bCQ8OnjTHZWcXmN8hdkyA5thOHZ7LlY=; b=bAqa387aXoFjx3tzs2EI97HgTy2spcC5n40oIzaLtsKbI3J9qlwuUiHF+aQt6I4GBl 12hOTFr9dMfKgFPJqrsVIZ3KVYnjweo38KhemXOCL25kCP+6r9nJ4nSaehq48D7COJpR 8IZRNj8wnZQXmjQq0NN3QJbt75jkW926wt68s7zpsN2D4fxmRhapNtxgcT4ZemO4OxyN a7eSt2v25OXipxZp1CVrgZBux7lmk+202E9PNE3ltjBz2BYO8D9KQn40qqU9s4ErLe/J E0rzzI3u6xWjfhesLo4Nr16RbPH6bPbfQz4vLJXeSMjkdUJ+OT/isymLwKwfZZCoV05q LnmA== X-Gm-Message-State: AOJu0Yw38D+VRpIHBwsuKpSsZXXM4E1LrZwPRDZDBIip3pg6U/PlrFQa GAYtew3huE3UAQL7YEBIiWHbnML7Yx/HF1k49L4srEanFAHmbLbtSYUZ3DtK X-Gm-Gg: ASbGncuTlTI2mn5WcCW7ZaA53M0rvfmvI2As51bHH3BBiMnUrX//UmrGbPnamYPBSwj q+FIcZe6F64pZiNlzhpbuWV094f8aKtHfsXqHQrW+L6lh3/Azztv/wgF6SZXK86wiw27hnytY3d 7M4WIOKmR8W4PD3NhdQHWeE4KUGfxJkmq29siihnxPEdodyEdqs1BH8AeUiROr7481Wc326S4Uh h2nlHt3I9aNZB5xYCP8nRdEDq9ut2jDU2KZhqK0 X-Google-Smtp-Source: AGHT+IERn6uDWq1VNGBJTVqTcduwjM1iiy8jM55e+0Z7OkLf/YFXC+ID5u7SkT7DkNVifHTTvXd5RQ== X-Received: by 2002:a05:6830:370d:b0:71e:ae7:3530 with SMTP id 46e09a7af769-720fe6a5387mr86681a34.17.1734628081197; Thu, 19 Dec 2024 09:08:01 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 03/11] hypervisor: drop qemu specific args in domainLogContextNew Date: Thu, 19 Dec 2024 11:07:48 -0600 Message-ID: <20241219170756.30810-4-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: LIHFDQVIFM6LT4FMM7UG6J3UJ2ZDZANF X-Message-ID-Hash: LIHFDQVIFM6LT4FMM7UG6J3UJ2ZDZANF 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: 1734628211415116600 Content-Type: text/plain; charset="utf-8" Drop Qemu specific arguments from domainLogContextNew and replace them with hypervisor agnostic ones. Signed-off-by: Praveen K Paladugu --- src/hypervisor/domain_logcontext.c | 20 ++++++++++++-------- src/hypervisor/domain_logcontext.h | 8 ++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/hypervisor/domain_logcontext.c b/src/hypervisor/domain_log= context.c index 3776d68ab9..41d1bbdf64 100644 --- a/src/hypervisor/domain_logcontext.c +++ b/src/hypervisor/domain_logcontext.c @@ -23,6 +23,8 @@ #include "virlog.h" #include "virstring.h" #include "virutil.h" +#include "virfile.h" +#include "virerror.h" =20 #include =20 @@ -78,26 +80,28 @@ domainLogContextFinalize(GObject *object) =20 =20 domainLogContext * -domainLogContextNew(virQEMUDriver *driver, +domainLogContextNew(bool stdioLogD, + char *logDir, + const char *driver_name, virDomainObj *vm, + bool privileged, const char *basename) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); domainLogContext *ctxt =3D DOMAIN_LOG_CONTEXT(g_object_new(DOMAIN_TYPE= _LOG_CONTEXT, NULL)); =20 - VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, cfg->stdioLogD); + VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, stdioLogD); ctxt->writefd =3D -1; ctxt->readfd =3D -1; =20 - ctxt->path =3D g_strdup_printf("%s/%s.log", cfg->logDir, basename); + ctxt->path =3D g_strdup_printf("%s/%s.log", logDir, basename); =20 - if (cfg->stdioLogD) { - ctxt->manager =3D virLogManagerNew(driver->privileged); + if (stdioLogD) { + ctxt->manager =3D virLogManagerNew(privileged); if (!ctxt->manager) goto error; =20 ctxt->writefd =3D virLogManagerDomainOpenLogFile(ctxt->manager, - "qemu", + driver_name, vm->def->uuid, vm->def->name, ctxt->path, @@ -121,7 +125,7 @@ domainLogContextNew(virQEMUDriver *driver, /* For unprivileged startup we must truncate the file since * we can't rely on logrotate. We don't use O_TRUNC since * it is better for SELinux policy if we truncate afterwards */ - if (!driver->privileged && + if (!privileged && ftruncate(ctxt->writefd, 0) < 0) { virReportSystemError(errno, _("failed to truncate %1$s"), ctxt->path); diff --git a/src/hypervisor/domain_logcontext.h b/src/hypervisor/domain_log= context.h index 8bb7c3d217..07c93fcf65 100644 --- a/src/hypervisor/domain_logcontext.h +++ b/src/hypervisor/domain_logcontext.h @@ -19,14 +19,18 @@ #pragma once =20 #include -#include "qemu_conf.h" #include "logging/log_manager.h" +#include "virconftypes.h" +#include "domain_conf.h" =20 #define DOMAIN_TYPE_LOG_CONTEXT domain_log_context_get_type() G_DECLARE_FINAL_TYPE(domainLogContext, domain_log_context, DOMAIN, LOG_CON= TEXT, GObject); =20 -domainLogContext *domainLogContextNew(virQEMUDriver *driver, +domainLogContext *domainLogContextNew(bool stdioLogD, + char *logDir, + const char *driver_name, virDomainObj *vm, + bool privileged, const char *basename); int domainLogContextWrite(domainLogContext *ctxt, const char *fmt, ...) G_GNUC_PRINTF(2, 3); --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628227318848.7298872650638; Thu, 19 Dec 2024 09:10:27 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4A02A1714; Thu, 19 Dec 2024 12:10:26 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B674E17A1; Thu, 19 Dec 2024 12:08:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CC5CE186E; Thu, 19 Dec 2024 12:08:09 -0500 (EST) Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 61F3117C3 for ; Thu, 19 Dec 2024 12:08:03 -0500 (EST) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5f33ad7d6faso699823eaf.0 for ; Thu, 19 Dec 2024 09:08:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:01 -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=1734628082; x=1735232882; 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=/9U+3CiYaVVqFwBaYglANLVUqc5YjjV8Ti3KJ8vMzk4=; b=I+2STUr5mLXGcOuMz4mQf6qN6SWr7Y25+hqFaEWccnPPjHv6Z4CtCX34wLbv0mB8VK PkLhqwWOLPKeIl5cRF5+Ljv1+jYDagaXBfwnBNHDfRD48sq3UXPw+wjLAV1diLsngioy /9TNx6OT5FGsBh6ch9KwBTM0T87ur0HQdAUjKoEpr8W2S9OqyFqu0J6EdLEhz1AWTbxn SfNLWJaVNW2sIK0sIGCUzxzRgCSLQDgb+65AmFW1KKpCrE0kgxGL6q1rqktjEO2fIM9Y HnTqNG95aP7QVTtAUFdf/vXA+z8hnFSzRY0EeZdvJ/j/J0OwMdlwVquy1IDClW218Cw1 PWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628082; x=1735232882; 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=/9U+3CiYaVVqFwBaYglANLVUqc5YjjV8Ti3KJ8vMzk4=; b=fUWuslDWJOxLVaS5aVvfJbZBeyStRHyT1yK5zqvHZNINXZEI8V8KANwEuwhRhG9OKJ v+oXnNe+ihwkhQpRFCKX9lc4WjFMvPM68EtUjwcep/muCjyttigjdLdof2NWd6OWnRr2 vUwMnnsRxllq/BZNfBtHc7oStw9vJapJegKLovxJ4vKnqVgWwDgiUOeN2tyo/nzmIMmj j1MPfYQPf5/ECswELigz6A7EhECkxfVqLkKg6DFnIto4TVM9RAhyL2/anlH2Yf30TB6Q LqWXkeaK+wQH10dDPgBMMcIafXTcH1uH83nl0vG9LOJBFGg85tor3ZnQsWV6+Z0vTz+2 jdjQ== X-Gm-Message-State: AOJu0YyBqa+MOnU0v1qP/eX4J1rm37EE6rm+QX6ZmXvKYxqVrPRn0xeY M7AUXbjEv6wTSRqe2lDNFHTCnmmVjCtgaPTjOpJ9IGicIGi7hCEjP3YCUfE5 X-Gm-Gg: ASbGncsCEXHbSpIXRQ/qHD9ZaG0D+f+F6kcTznrTmlcj9sC2o13+dnu5DvyEnYnizog 1VLYOauD7jP6eaYcvwP80jtDYQr5CqjUg7qT/9MhhaoppQJlaids65VyKh+jf7VEMBkb+4RSfS+ Km/7+0i0BDNuUQW4vZYtWBS/lEsYfSES68xAuzPHeXvOR2gz6z0/096UzouhamYInWgOkZMsc05 OFP4C+S5eLSIgum8jSFUTOUGUDCmdPE1NVtL1Vt X-Google-Smtp-Source: AGHT+IHFJfk4CJdfyWEJfiGIv4n82RonjUpLMS6Y1cz68pqvUlqUfEvgENkXkibeS9jzvnK/l/s0Mw== X-Received: by 2002:a05:6820:1792:b0:5f4:cd65:7619 with SMTP id 006d021491bc7-5f62d0693a6mr211084eaf.1.1734628082484; Thu, 19 Dec 2024 09:08:02 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 04/11] hypervisor: Build domain_logcontext Date: Thu, 19 Dec 2024 11:07:49 -0600 Message-ID: <20241219170756.30810-5-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: 3UUOMTXCND7W22ZCUHCLVH5GKIY4CBHU X-Message-ID-Hash: 3UUOMTXCND7W22ZCUHCLVH5GKIY4CBHU 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: 1734628229440116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu --- src/hypervisor/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hypervisor/meson.build b/src/hypervisor/meson.build index 819a9a82a2..c32703af88 100644 --- a/src/hypervisor/meson.build +++ b/src/hypervisor/meson.build @@ -2,6 +2,7 @@ hypervisor_sources =3D [ 'domain_cgroup.c', 'domain_driver.c', 'domain_interface.c', + 'domain_logcontext.c', 'virclosecallbacks.c', 'virhostdev.c', ] --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628244555183.9652830098023; Thu, 19 Dec 2024 09:10:44 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 76B4817C5; Thu, 19 Dec 2024 12:10:43 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BFCE217D0; Thu, 19 Dec 2024 12:08:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 175F91802; Thu, 19 Dec 2024 12:08:13 -0500 (EST) Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 A455517F9 for ; Thu, 19 Dec 2024 12:08:04 -0500 (EST) Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-71e2a32297dso485018a34.0 for ; Thu, 19 Dec 2024 09:08:04 -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.02 (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=1734628083; x=1735232883; 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=w/ZoeTFey56o0ufXSYqcRaX9nN+tn9dtl9Mcq2zq9XY=; b=MALU4o5/zsOrKjZ7ADRgdQv1G4hAgoXrugYAWxUhqsTmWmqZdOfWPgZOw3h1CpS2PR 1b36t2tlI1j16WsVebFoYaon9hVOlaRFABwDQGvbT5dj4tEkrZ8Q8keTym3rK+Q9jX1k lk4vRDQIsa1vgoRDubBtYiEMzGxrC5fmDlAJ4tQZUDE2dKtrs//XLCn3iq3vSSFeC6pa A/TBOiODhr4xjdV0m3muxqbDLnJf3XucDADxKPpJlFtFwHxjWn6ogwx2yOu36YAzqWIk 9kv0qH2oFeoclBcaHfD3WxdXbeiNi0XG1+KuDun8wX6K78f5YvHqMtCfVbPtiNkJeGZV NMqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628083; x=1735232883; 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=w/ZoeTFey56o0ufXSYqcRaX9nN+tn9dtl9Mcq2zq9XY=; b=oQyAyKPXouEgZkQjTp/229gdyGEeZ2MdOhL/618k6QbHQUhRS3NhhoOzVahG5CNa5v HVG7SKN7QPaKvgne4CBdkDpfDsGG7lAs58YH/2VCaAtVGS6ZIXSkkvdf7vFkssmNQCf3 a4XHzTJO2dryjNELmLDHGM7TcZ+J388j/zps7aEJMoGtyPxOZY13jqhInQAM4BhpnHcj RgYdPXIhrj6q7QxMKRICTvidRtfXGHFEPc6iWd6sc+b1g59s6oSb4Sd5MfCLlWWSJvPx INMelTX/wwvqauvdJfLx2VpPFlojkYUe3e67DqlLpyZsp8pRJfJIWHEIy3+nZ27IWBJh 5QOw== X-Gm-Message-State: AOJu0YwTzTrqviWsrtWdeOEzIT04iB9CjDQ+FD/zraZtqi8ntmT0889M XWYdBnCoIOviKPo3iBE4lOd1iqR6GSF88QFsk1UGGvNN25EXePo7Pw2J+IPM X-Gm-Gg: ASbGncsa2Kn/UpuduZxTSlbZa6DNnlwT9W9CnynfrTK4Fnx9u6lf3DoFePaIfFTjgBN /1t25WR/F5IEU/p9ufAaaP/eBByoOYFYDhabP0zeYxapIqC1evGE8RUUfgb0PCnxaRh33xlQk6t Sbn8/J5mXYT7iKJgj0TXJdOxYLyX0hEasqC8r5j3K5z0ki6UJlAEm6Tv2VNOMrDkkBRDMz7+7Ou KFlXcA7+BgRtZnkC6aBEGIfsfzNa2oDUs75GKO/ X-Google-Smtp-Source: AGHT+IHmbd5no0GnUqthforD9iZXIXhGm8gl8IfxVw/Q5qo3rMxiFar0//KoHmg7nrhi11RbwqNMBw== X-Received: by 2002:a05:6830:1511:b0:71d:e666:14e with SMTP id 46e09a7af769-71fc59b065dmr2111550a34.6.1734628083537; Thu, 19 Dec 2024 09:08:03 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 05/11] libvirt_private: export symbols from domain_logcontext Date: Thu, 19 Dec 2024 11:07:50 -0600 Message-ID: <20241219170756.30810-6-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: MAN7OMTH7K5KLOEMZ7CLDYLB7DRMQT5R X-Message-ID-Hash: MAN7OMTH7K5KLOEMZ7CLDYLB7DRMQT5R 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: 1734628245505116600 Content-Type: text/plain; charset="utf-8" Export required symbols from domain_logcontext.c. Signed-off-by: Praveen K Paladugu --- src/libvirt_private.syms | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c931003fad..ad90f46c18 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1665,6 +1665,12 @@ virDomainInterfaceStopDevice; virDomainInterfaceStopDevices; virDomainInterfaceVportRemove; =20 +# hypervisor/domain_logcontext.h +domainLogContextGetWriteFD; +domainLogContextMarkPosition; +domainLogContextNew; +domainLogContextReadFiltered; +domainLogContextWrite; =20 # hypervisor/virclosecallbacks.h virCloseCallbacksDomainAdd; --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 From nobody Sun Dec 22 01:57:13 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 1734628326773640.9471818807813; Thu, 19 Dec 2024 09:12:06 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 29FFD18C6; Thu, 19 Dec 2024 12:12:04 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0A0F8186E; Thu, 19 Dec 2024 12:08:28 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BFE3C17EE; Thu, 19 Dec 2024 12:08:22 -0500 (EST) Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 2480C17AE for ; Thu, 19 Dec 2024 12:08:07 -0500 (EST) Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-71deb3745easo227735a34.3 for ; Thu, 19 Dec 2024 09:08:07 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:05 -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=1734628086; x=1735232886; 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=YsTjRFLYYKLK6zPxLwt+uvXBBaibofbEWDTaNrlIgHw=; b=GLnUrXnUXeunzJv/UpC+zWdZlF+QST9sfBVlqFr8nsdBCHOisCXPKCdQewVKVZPPiQ kftqItHYR0ZlaUisUOemGftYhM3lCY8kq0myOQnuPJtHPdtWW4m8NrERXNXx0SfIKmKM tcWb8Rtl/JX2sgirqSZt4r2JMLtkDeKU6DsDgui0SVyrMB0CTnFwvBHMFkpGKaOBZlvX O8wrtZzN6vvqG7ZXmeDUCLfQYz6ZC8990EED15qdTMuiiA7+HjxjuVfG0yTRap66bDa4 M/JbzHyl+hRqjVo4xjlEXvRiQEs46ynD1uFzO3jfnoJd+tEAKCvbpyQjDpMkl78aSZIC vyXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628086; x=1735232886; 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=YsTjRFLYYKLK6zPxLwt+uvXBBaibofbEWDTaNrlIgHw=; b=aY5+XIhEpZHaSADzDhAwdA3x9ZRvhaMATWeYSDMt8v9H3RVUM4nctTsacMoZIG6TT4 9GG9Mpsx3xKHAuYrCdh76lCAICY7p3bpWD0yM0RJsv95P6VRaCdJevmZO/LGFElbasIf ksl1kR6kJ0uxXEnXZJW4MmVOw19q6KflVMJ/gXPDR8Am0mz9nZGZnWVA1Pzf9WhbBOZl ZWE/JMiYXmzmEo4qT1fToE2UTcu16eeArPRP5x5tddaYmaJj8HPj+NZ4Z091a8AAIyPU 4H7EF+EGgNjiSVbEM1n8zk/N6dpsOuBzQtqGfSUN4ZSR/Qrzfq3MQ3+IymtVioz3AID1 gjAQ== X-Gm-Message-State: AOJu0YwZYteZ1M1OQT1oJf+zTXAJw5eWTkeFxAlyo4yE9zRuDnfaLufN mUo+lSK7fs6D5ErohYlH5TxdfRW7C+icz4SEss8FBLtrLLI2agph7QlDo4t8 X-Gm-Gg: ASbGnctZoC78dqOiUmQ6W1RGbrTL8f36HJwKt0kt1fISQGN1y26upXSPWI9XPCbl41+ GvQd58EmfN3T9U1nQsVeIXZhTP0pUNAOHIvsZo/aTmzxbXSFOcqpVfjfeOqr5g9OrTcRZbEUKeB ArYoakurYUdcH0+h867Xej7qOhG2SzSYMLp1pDpEXOPVShENatlA5EawOsCUPGxxARkCCfpvt+A 3SYvI7TvunS6IO3y9PX31+6cNxF+U8tGElckXio X-Google-Smtp-Source: AGHT+IHHZi/vdjUbwQapFKM9aqaiX1yBTNlM3DnhyoVqkpoG2n3TmCZ7i7bOueKy0HbOzkgQ3HCc1g== X-Received: by 2002:a05:6830:3c8c:b0:717:f701:4842 with SMTP id 46e09a7af769-71fb76390camr4737509a34.28.1734628085802; Thu, 19 Dec 2024 09:08:05 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 07/11] qemu: delete qemu_logcontext files Date: Thu, 19 Dec 2024 11:07:52 -0600 Message-ID: <20241219170756.30810-8-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: HTGXOYM6VWJWAIUYVWZENTOE25W7KZFS X-Message-ID-Hash: HTGXOYM6VWJWAIUYVWZENTOE25W7KZFS 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: 1734628327469116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu --- po/POTFILES | 1 - src/qemu/meson.build | 1 - src/qemu/qemu_logcontext.c | 329 ------------------------------------- src/qemu/qemu_logcontext.h | 41 ----- 4 files changed, 372 deletions(-) delete mode 100644 src/qemu/qemu_logcontext.c delete mode 100644 src/qemu/qemu_logcontext.h diff --git a/po/POTFILES b/po/POTFILES index 1d3c3c0a81..43b4d005e3 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -181,7 +181,6 @@ src/qemu/qemu_hostdev.c src/qemu/qemu_hotplug.c src/qemu/qemu_interface.c src/qemu/qemu_interop_config.c -src/qemu/qemu_logcontext.c src/qemu/qemu_migration.c src/qemu/qemu_migration_cookie.c src/qemu/qemu_migration_params.c diff --git a/src/qemu/meson.build b/src/qemu/meson.build index 2a85e2e604..43a8ad7c3b 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -22,7 +22,6 @@ qemu_driver_sources =3D [ 'qemu_hotplug.c', 'qemu_interface.c', 'qemu_interop_config.c', - 'qemu_logcontext.c', 'qemu_migration.c', 'qemu_migration_cookie.c', 'qemu_migration_params.c', diff --git a/src/qemu/qemu_logcontext.c b/src/qemu/qemu_logcontext.c deleted file mode 100644 index 6e20f58bfa..0000000000 --- a/src/qemu/qemu_logcontext.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * qemu_logcontext.c: QEMU log context - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#include - -#include "qemu_logcontext.h" -#include "viralloc.h" -#include "virlog.h" -#include "virstring.h" -#include "virutil.h" - -#include - -#define VIR_FROM_THIS VIR_FROM_QEMU - -VIR_LOG_INIT("qemu.qemu_logcontext"); - - -struct _qemuLogContext { - GObject parent; - - int writefd; - int readfd; /* Only used if manager =3D=3D NULL */ - off_t pos; - ino_t inode; /* Only used if manager !=3D NULL */ - char *path; - virLogManager *manager; -}; - -G_DEFINE_TYPE(qemuLogContext, qemu_log_context, G_TYPE_OBJECT); - -static void -qemuLogContextFinalize(GObject *obj); - - -static void -qemu_log_context_init(qemuLogContext *logctxt G_GNUC_UNUSED) -{ -} - - -static void -qemu_log_context_class_init(qemuLogContextClass *klass) -{ - GObjectClass *obj =3D G_OBJECT_CLASS(klass); - - obj->finalize =3D qemuLogContextFinalize; -} - - -static void -qemuLogContextFinalize(GObject *object) -{ - qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(object); - VIR_DEBUG("ctxt=3D%p", ctxt); - - virLogManagerFree(ctxt->manager); - VIR_FREE(ctxt->path); - VIR_FORCE_CLOSE(ctxt->writefd); - VIR_FORCE_CLOSE(ctxt->readfd); - G_OBJECT_CLASS(qemu_log_context_parent_class)->finalize(object); -} - - -qemuLogContext * -qemuLogContextNew(virQEMUDriver *driver, - virDomainObj *vm, - const char *basename) -{ - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - qemuLogContext *ctxt =3D QEMU_LOG_CONTEXT(g_object_new(QEMU_TYPE_LOG_C= ONTEXT, NULL)); - - VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, cfg->stdioLogD); - ctxt->writefd =3D -1; - ctxt->readfd =3D -1; - - ctxt->path =3D g_strdup_printf("%s/%s.log", cfg->logDir, basename); - - if (cfg->stdioLogD) { - ctxt->manager =3D virLogManagerNew(driver->privileged); - if (!ctxt->manager) - goto error; - - ctxt->writefd =3D virLogManagerDomainOpenLogFile(ctxt->manager, - "qemu", - vm->def->uuid, - vm->def->name, - ctxt->path, - 0, - &ctxt->inode, - &ctxt->pos); - if (ctxt->writefd < 0) - goto error; - } else { - if ((ctxt->writefd =3D open(ctxt->path, O_WRONLY | O_CREAT | O_APP= END, S_IRUSR | S_IWUSR)) < 0) { - virReportSystemError(errno, _("failed to create logfile %1$s"), - ctxt->path); - goto error; - } - if (virSetCloseExec(ctxt->writefd) < 0) { - virReportSystemError(errno, _("failed to set close-on-exec fla= g on %1$s"), - ctxt->path); - goto error; - } - - /* For unprivileged startup we must truncate the file since - * we can't rely on logrotate. We don't use O_TRUNC since - * it is better for SELinux policy if we truncate afterwards */ - if (!driver->privileged && - ftruncate(ctxt->writefd, 0) < 0) { - virReportSystemError(errno, _("failed to truncate %1$s"), - ctxt->path); - goto error; - } - - if ((ctxt->readfd =3D open(ctxt->path, O_RDONLY)) < 0) { - virReportSystemError(errno, _("failed to open logfile %1$s"), - ctxt->path); - goto error; - } - if (virSetCloseExec(ctxt->readfd) < 0) { - virReportSystemError(errno, _("failed to set close-on-exec fla= g on %1$s"), - ctxt->path); - goto error; - } - - if ((ctxt->pos =3D lseek(ctxt->writefd, 0, SEEK_END)) < 0) { - virReportSystemError(errno, _("failed to seek in log file %1$s= "), - ctxt->path); - goto error; - } - } - - return ctxt; - - error: - g_clear_object(&ctxt); - return NULL; -} - - -int -qemuLogContextWrite(qemuLogContext *ctxt, - const char *fmt, ...) -{ - va_list argptr; - g_autofree char *message =3D NULL; - int ret =3D -1; - - va_start(argptr, fmt); - - message =3D g_strdup_vprintf(fmt, argptr); - if (!ctxt->manager && - lseek(ctxt->writefd, 0, SEEK_END) < 0) { - virReportSystemError(errno, "%s", - _("Unable to seek to end of domain logfile")); - goto cleanup; - } - if (safewrite(ctxt->writefd, message, strlen(message)) < 0) { - virReportSystemError(errno, "%s", - _("Unable to write to domain logfile")); - goto cleanup; - } - - ret =3D 0; - - cleanup: - va_end(argptr); - return ret; -} - - -ssize_t -qemuLogContextRead(qemuLogContext *ctxt, - char **msg) -{ - char *buf; - size_t buflen; - - VIR_DEBUG("Context read %p manager=3D%p inode=3D%llu pos=3D%llu", - ctxt, ctxt->manager, - (unsigned long long)ctxt->inode, - (unsigned long long)ctxt->pos); - - if (ctxt->manager) { - buf =3D virLogManagerDomainReadLogFile(ctxt->manager, - ctxt->path, - ctxt->inode, - ctxt->pos, - 1024 * 128, - 0); - if (!buf) - return -1; - buflen =3D strlen(buf); - } else { - ssize_t got; - - buflen =3D 1024 * 128; - - /* Best effort jump to start of messages */ - ignore_value(lseek(ctxt->readfd, ctxt->pos, SEEK_SET)); - - buf =3D g_new0(char, buflen); - - got =3D saferead(ctxt->readfd, buf, buflen - 1); - if (got < 0) { - VIR_FREE(buf); - virReportSystemError(errno, "%s", - _("Unable to read from log file")); - return -1; - } - - buf[got] =3D '\0'; - - buf =3D g_renew(char, buf, got + 1); - buflen =3D got; - } - - *msg =3D buf; - - return buflen; -} - - -/** - * qemuLogContextFilter: Read and filter log for relevant messages - * @ctxt: the domain log context - * @msg: pointer to buffer to store the read messages in - * @max: maximum length of the message returned in @msg after filtering - * - * Reads log output from @ctxt and filters it. Skips messages not produced= by - * the target executable or irrelevant messages. If @max is not zero, @buf= will - * contain at most @max characters from the end of the log and @buf will s= tart - * after a new line if possible. - */ -int -qemuLogContextReadFiltered(qemuLogContext *ctxt, - char **msg, - size_t max) -{ - char *buf; - char *eol; - char *filter_next; - size_t skip; - ssize_t got; - - if ((got =3D qemuLogContextRead(ctxt, &buf)) < 0) - return -1; - - /* Filter out debug messages from intermediate libvirt process */ - filter_next =3D buf; - while ((eol =3D strchr(filter_next, '\n'))) { - *eol =3D '\0'; - if (virLogProbablyLogMessage(filter_next) || - strstr(filter_next, "char device redirected to")) { - skip =3D (eol + 1) - filter_next; - memmove(filter_next, eol + 1, buf + got - eol); - got -=3D skip; - } else { - filter_next =3D eol + 1; - *eol =3D '\n'; - } - } - - if (got > 0 && - buf[got - 1] =3D=3D '\n') { - buf[got - 1] =3D '\0'; - got--; - } - - if (max > 0 && got > max) { - skip =3D got - max; - - if (buf[skip - 1] !=3D '\n' && - (eol =3D strchr(buf + skip, '\n')) && - !virStringIsEmpty(eol + 1)) - skip =3D eol + 1 - buf; - - memmove(buf, buf + skip, got - skip + 1); - got -=3D skip; - } - - buf =3D g_renew(char, buf, got + 1); - *msg =3D buf; - return 0; -} - - -int -qemuLogContextGetWriteFD(qemuLogContext *ctxt) -{ - return ctxt->writefd; -} - - -void -qemuLogContextMarkPosition(qemuLogContext *ctxt) -{ - if (ctxt->manager) - virLogManagerDomainGetLogFilePosition(ctxt->manager, - ctxt->path, - 0, - &ctxt->inode, - &ctxt->pos); - else - ctxt->pos =3D lseek(ctxt->writefd, 0, SEEK_END); -} - - -virLogManager * -qemuLogContextGetManager(qemuLogContext *ctxt) -{ - return ctxt->manager; -} diff --git a/src/qemu/qemu_logcontext.h b/src/qemu/qemu_logcontext.h deleted file mode 100644 index 738e908bc3..0000000000 --- a/src/qemu/qemu_logcontext.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * qemu_logcontext.h: QEMU log context - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#pragma once - -#include -#include "qemu_conf.h" -#include "logging/log_manager.h" - -#define QEMU_TYPE_LOG_CONTEXT qemu_log_context_get_type() -G_DECLARE_FINAL_TYPE(qemuLogContext, qemu_log_context, QEMU, LOG_CONTEXT, = GObject); - -qemuLogContext *qemuLogContextNew(virQEMUDriver *driver, - virDomainObj *vm, - const char *basename); -int qemuLogContextWrite(qemuLogContext *ctxt, - const char *fmt, ...) G_GNUC_PRINTF(2, 3); -ssize_t qemuLogContextRead(qemuLogContext *ctxt, - char **msg); -int qemuLogContextReadFiltered(qemuLogContext *ctxt, - char **msg, - size_t max); -int qemuLogContextGetWriteFD(qemuLogContext *ctxt); -void qemuLogContextMarkPosition(qemuLogContext *ctxt); - -virLogManager *qemuLogContextGetManager(qemuLogContext *ctxt); --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 From nobody Sun Dec 22 01:57:13 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 1734628375065753.9052756184717; Thu, 19 Dec 2024 09:12:55 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1A6E31827; Thu, 19 Dec 2024 12:12:54 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2A7B518A6; Thu, 19 Dec 2024 12:08:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 722BA167B; Thu, 19 Dec 2024 12:08:24 -0500 (EST) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 A26AC186D for ; Thu, 19 Dec 2024 12:08:09 -0500 (EST) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-71e2a32297dso485075a34.0 for ; Thu, 19 Dec 2024 09:08:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:07 -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=1734628088; x=1735232888; 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=aAagNEhhoP8t9C8eJwwXRIAQDU4uwU5avOfsrGTUoVw=; b=mQQAauYpa6OWMeMPGzJ04XLElfObd5XXoF/Y9rPlzsGKEHP7Jn24/bKaRsa2C1PWnN SLqfJ44GtpEuMLn3C3DavMzrTEdaIGj1W+V6dsOxdSs/FXgdX/ouNHnq0IWDkrR6S9ZH Qc82IF5w1pohfYSlIFV4p38PSsEftPBdDk2C8Bku9EJ1gBmHABaa6aaDVPhvD6QOgUZc U+DR25KFb1W9T4Pl6EoHJZTrH0ZM9VpqAqSJUmjNeSIKoN82V5S+tVyXAw94Z4i68Odu H8d/oqkJvbnrTkNv+h6vf6JKXiawbVxsPkfTP+TIhKTWD584U/+tRiJUqrnsJWDhajpN jQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628088; x=1735232888; 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=aAagNEhhoP8t9C8eJwwXRIAQDU4uwU5avOfsrGTUoVw=; b=Hgq7WDXP9g+dUpSr1ExpJzNcb6KuKHjAqa78/QCm4xs9H/zzai8SRBwPPY7xdZaSLt FDNngpTIy/3uAvrJz4iQ/U4Pv8EsnPUjC1NezKfrstMGpOW62pHZVOOa5msI0qaQwxwe Ah1Wh6q44YxjBHx8y+dLqlzcJO3/HPLQfVZxsXm6SlRIisLuX0iFpTyyUSpmps/vhY4O orD7avaL2/yxyG2PRrNPIXCXIcsGcOA6gIDLAs8Yy3Ylukmpwzlv++1dKAlnrAC1xxgi o3m8WbXTkTfCNVLmdwbM+F7mGDqSJNWJhvQ1Vrhm86wtCBNm9tpcj0QQrIv8v3Uc6JVZ IX5g== X-Gm-Message-State: AOJu0YyWDET8VNRfHpZgk7yjI9dzN9s7FlrWQiJLvZifBX7buXCNvffX TnDnoz8hLjcG7XIVgb1XiQqUhoDCuFts2U6/vyRcIBjEAnPVpg08UpeK5EnZ X-Gm-Gg: ASbGncsTwLAzJgGkEgDJlgzsm0TkuyKemyL3BzVgA91GUepxt6QsfBryPzrrd2/vkYM Qc3erPlPeOFqD2sExOF6r+V0eQFM6AruT9Rter1xtPOidM/YGeGdwyidqo7jcMA9y12d4zZBVEk 5/GZ8ut8M3FulYMKmn1STbJfJZlKIBKAC3Bo2MeEBRiCyy9fXxOIMtdRRGwUtO//RNPcryBWvbK E75JnK5YlFwDTyX5i4IIIDCQZUC66IgUDqyL+Cl X-Google-Smtp-Source: AGHT+IGtYUplhVUck7IeeUlM/Vp1QRTpaZq6tmmesICTVTcBWCp0aVBhNPEV6ITNNdNiySlXl5yFBg== X-Received: by 2002:a9d:4b08:0:b0:71d:4dbb:7232 with SMTP id 46e09a7af769-71fc5938e40mr2010938a34.3.1734628088470; Thu, 19 Dec 2024 09:08:08 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 09/11] ch: move curl_data and curl_callback definitions Date: Thu, 19 Dec 2024 11:07:54 -0600 Message-ID: <20241219170756.30810-10-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: HEDIIALCWLIOA57FZU6ADWEQ7TAX73V6 X-Message-ID-Hash: HEDIIALCWLIOA57FZU6ADWEQ7TAX73V6 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: 1734628375393116600 Content-Type: text/plain; charset="utf-8" Move the definitions of curl_data and curl_callback to be used within virCHMonitorPutNoContent. Signed-off-by: Praveen K Paladugu --- src/ch/ch_monitor.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index c9b08b0f75..88df9d4a03 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -671,6 +671,28 @@ virCHMonitorCurlPerform(CURL *handle) return responseCode; } =20 +struct curl_data { + char *content; + size_t size; +}; + +static size_t +curl_callback(void *contents, size_t size, size_t nmemb, void *userp) +{ + size_t content_size =3D size * nmemb; + struct curl_data *data =3D userp; + + if (content_size =3D=3D 0) + return content_size; + + data->content =3D g_realloc(data->content, data->size + content_size); + + memcpy(&(data->content[data->size]), contents, content_size); + data->size +=3D content_size; + + return content_size; +} + int virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint) { @@ -698,28 +720,6 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char= *endpoint) return ret; } =20 -struct curl_data { - char *content; - size_t size; -}; - -static size_t -curl_callback(void *contents, size_t size, size_t nmemb, void *userp) -{ - size_t content_size =3D size * nmemb; - struct curl_data *data =3D userp; - - if (content_size =3D=3D 0) - return content_size; - - data->content =3D g_realloc(data->content, data->size + content_size); - - memcpy(&(data->content[data->size]), contents, content_size); - data->size +=3D content_size; - - return content_size; -} - static int virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **re= sponse) { --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628396887197.99502231341023; Thu, 19 Dec 2024 09:13:16 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D6DEC17DF; Thu, 19 Dec 2024 12:13:15 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0A3A71899; Thu, 19 Dec 2024 12:08:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 686C917FE; Thu, 19 Dec 2024 12:08:25 -0500 (EST) Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 AC7E017E6 for ; Thu, 19 Dec 2024 12:08:10 -0500 (EST) Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3ebbe804913so274366b6e.0 for ; Thu, 19 Dec 2024 09:08:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08:08 -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.7 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_H2,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=1734628090; x=1735232890; 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=0GJOq4kM4UcnXAhLXl68hU71Afy29qcZO5F/JWYQvYw=; b=W6dbxC4M2C4NT25SUAxhvdOylMwiHheaIFcHp4s9d9SS/U9nQIqH7tHFTNo4IIXI1D 5n+jqLjxfNIlTCJ+vr8meqQl2Slz5zjsZ1/46nsfDm3wndoXpgaonvWUhG9TySVXnT4+ 1zD6T0LHZC93ZmtfYd2pOGvfsT0IHk/7AUdsvhUPw/yFpFsX3RsMDWoMxRUQ+DF3tIaF cHCTLMgnDfu2kYt2SKvpW4cqgK6ahjaPB2F4jn8mc2LDIyMJ4BBjnnGxO1YSNhT89zHz zwmogIwR8ZUKNtgiamqoOVp7GOvGs/zK0QJi4pTCq1SV387nGuRejcytfyE1EhbCRAyu EYsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628090; x=1735232890; 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=0GJOq4kM4UcnXAhLXl68hU71Afy29qcZO5F/JWYQvYw=; b=PBtUkuQXvU0Rgm3O9uZREFlHaKOzacOVH7X9FQpJC6UGPATLeJwao2rV/5tvpesd1z uWcUfIZHieK/ePMRxnvB71IY+qn+XxYBsZeT8X5C9ZvyCehnicmEAj2SHi2JssL8Ejb5 HjD+NwoMCczcwxlJoieMRPHhv/Xpwb90sSCuvviM5ZUyXkMMTJa6ij+PriRVSBYL7nBf XykH8ZJ3aRQ1OHhjwuPk5agJL/OI8qHUWDdXkWfAklBe8dUbsu2jbmvI7E20YnhCovdR rE3JTpv3fjbdeuN2Yv65ARIM5qtPWxl5VTFKMiJ20n2yqcWUHPy14LGshgcr3c4NXzWs o9rQ== X-Gm-Message-State: AOJu0YysYwnQ7gljl39QEcO/qcCEv1tyo/vpD/qT6x9Ju/UYZgJdRDBh 4ozZUMtZTFE9iLjfMYDa0hZoBCGnVGxUCtRGH62IvHiErgs0RCrsHAXUBbxX X-Gm-Gg: ASbGncsB+1koL99DoDBd/zh0bWgryufeoeyFcVvCXZmHlFK+ABPGdVYZlE0aKkNdi6w 1THpt6qKMulYSJdCghYktNfC/K5dBmN4VfqZdQt26McVsSElU7mvVtWgj+u2l3XrbTj5vicitP7 TzEPA7vqB4i7wOjytR7dnBOScUDPIn6Zm2std0hjqMtmSxyos0i3E4GSbcoG2MyXUQlbYLxv3g7 VpImpdU4qbaSizfY2/KeBu/Ekq2EuM9Q28ZyD2D X-Google-Smtp-Source: AGHT+IHmczG7MjoE7V3GGJlcOjXqpisB6L+nDHEF5+xc/VM4xsOzmUVx/kdaa+Zr9Nut2D6J0CmLSQ== X-Received: by 2002:a05:6808:2187:b0:3e6:147:6c5 with SMTP id 5614622812f47-3ecdcbe0218mr2581504b6e.10.1734628089703; Thu, 19 Dec 2024 09:08:09 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 10/11] ch: Enable logging curl responses from ch Date: Thu, 19 Dec 2024 11:07:55 -0600 Message-ID: <20241219170756.30810-11-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: 7YWPCSKMN5B2YEGYSGSOR5NNV6NTMDW3 X-Message-ID-Hash: 7YWPCSKMN5B2YEGYSGSOR5NNV6NTMDW3 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: 1734628397423116600 Content-Type: text/plain; charset="utf-8" Log curl responses from cloud-hypervisor process during Boot request, using domain's logContext. Signed-off-by: Praveen K Paladugu --- src/ch/ch_monitor.c | 35 ++++++++++++++++++++++++++--------- src/ch/ch_monitor.h | 3 ++- src/ch/ch_process.c | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 88df9d4a03..d3f969e01a 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -56,7 +56,8 @@ static int virCHMonitorOnceInit(void) VIR_ONCE_GLOBAL_INIT(virCHMonitor); =20 int virCHMonitorShutdownVMM(virCHMonitor *mon); -int virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint); +int virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint, + domainLogContext *logCtxt); =20 static int virCHMonitorBuildCPUJson(virJSONValue *content, virDomainDef *vmdef) @@ -694,12 +695,15 @@ curl_callback(void *contents, size_t size, size_t nme= mb, void *userp) } =20 int -virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint) +virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint, + domainLogContext *logCtxt) { VIR_LOCK_GUARD lock =3D virObjectLockGuard(mon); g_autofree char *url =3D NULL; int responseCode =3D 0; int ret =3D -1; + struct curl_data data =3D {0}; + struct curl_slist *headers =3D NULL; =20 url =3D g_strdup_printf("%s/%s", URL_ROOT, endpoint); =20 @@ -712,8 +716,21 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char= *endpoint) curl_easy_setopt(mon->handle, CURLOPT_HTTPHEADER, NULL); curl_easy_setopt(mon->handle, CURLOPT_INFILESIZE, 0L); =20 + headers =3D curl_slist_append(headers, "Accept: application/json"); + curl_easy_setopt(mon->handle, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(mon->handle, CURLOPT_WRITEFUNCTION, curl_callback); + curl_easy_setopt(mon->handle, CURLOPT_WRITEDATA, (void *)&data); + responseCode =3D virCHMonitorCurlPerform(mon->handle); =20 + if (logCtxt && data.size) { + /* Do this to append a NULL char at the end of data */ + data.content =3D g_realloc(data.content, data.size + 1); + data.content[data.size] =3D 0; + domainLogContextWrite(logCtxt, "HTTP response code from CH: %d\n",= responseCode); + domainLogContextWrite(logCtxt, "Response =3D %s\n", data.content); + } + if (responseCode =3D=3D 200 || responseCode =3D=3D 204) ret =3D 0; =20 @@ -863,7 +880,7 @@ virCHMonitorGetThreadInfo(virCHMonitor *mon, int virCHMonitorShutdownVMM(virCHMonitor *mon) { - return virCHMonitorPutNoContent(mon, URL_VMM_SHUTDOWN); + return virCHMonitorPutNoContent(mon, URL_VMM_SHUTDOWN, NULL); } =20 int @@ -903,33 +920,33 @@ virCHMonitorCreateVM(virCHDriver *driver, virCHMonito= r *mon) } =20 int -virCHMonitorBootVM(virCHMonitor *mon) +virCHMonitorBootVM(virCHMonitor *mon, domainLogContext *logCtxt) { - return virCHMonitorPutNoContent(mon, URL_VM_BOOT); + return virCHMonitorPutNoContent(mon, URL_VM_BOOT, logCtxt); } =20 int virCHMonitorShutdownVM(virCHMonitor *mon) { - return virCHMonitorPutNoContent(mon, URL_VM_SHUTDOWN); + return virCHMonitorPutNoContent(mon, URL_VM_SHUTDOWN, NULL); } =20 int virCHMonitorRebootVM(virCHMonitor *mon) { - return virCHMonitorPutNoContent(mon, URL_VM_REBOOT); + return virCHMonitorPutNoContent(mon, URL_VM_REBOOT, NULL); } =20 int virCHMonitorSuspendVM(virCHMonitor *mon) { - return virCHMonitorPutNoContent(mon, URL_VM_Suspend); + return virCHMonitorPutNoContent(mon, URL_VM_Suspend, NULL); } =20 int virCHMonitorResumeVM(virCHMonitor *mon) { - return virCHMonitorPutNoContent(mon, URL_VM_RESUME); + return virCHMonitorPutNoContent(mon, URL_VM_RESUME, NULL); } =20 int diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index 5c02447116..ca23301723 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -25,6 +25,7 @@ #include "virobject.h" #include "virjson.h" #include "domain_conf.h" +#include "domain_logcontext.h" #include "ch_conf.h" =20 #define URL_ROOT "http://localhost/api/v1" @@ -110,7 +111,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHMonitor, virCHMonito= rClose); =20 =20 int virCHMonitorCreateVM(virCHDriver *driver, virCHMonitor *mon); -int virCHMonitorBootVM(virCHMonitor *mon); +int virCHMonitorBootVM(virCHMonitor *mon, domainLogContext *logCtxt); int virCHMonitorShutdownVM(virCHMonitor *mon); int virCHMonitorRebootVM(virCHMonitor *mon); int virCHMonitorSuspendVM(virCHMonitor *mon); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index af44aa81a2..9a85f7869e 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -964,7 +964,7 @@ virCHProcessStart(virCHDriver *driver, if (virDomainInterfaceStartDevices(vm->def) < 0) return -1; =20 - if (virCHMonitorBootVM(priv->monitor) < 0) { + if (virCHMonitorBootVM(priv->monitor, logCtxt) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to boot guest VM")); goto cleanup; --=20 2.47.0 From nobody Sun Dec 22 01:57:13 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 1734628412751501.0214306094142; Thu, 19 Dec 2024 09:13:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BDC901826; Thu, 19 Dec 2024 12:13:31 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7C07F18B5; Thu, 19 Dec 2024 12:08:37 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A03751790; Thu, 19 Dec 2024 12:08:25 -0500 (EST) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 CDEF81790 for ; Thu, 19 Dec 2024 12:08:11 -0500 (EST) Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-71e1158fe3eso595020a34.1 for ; Thu, 19 Dec 2024 09:08:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 09:08: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=1734628091; x=1735232891; 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=8Em+oJkXu/h57ymGDJbkwlWwzIyyTSIYu5Eoft9tYfU=; b=cNz+RfJ0i0G/BYony/w4wBjz1zpnF1HrC+Zv6AVmBxYKZjQcMh+fPzJNWViTtPiXic KRkjvsz+J5KuNVOYzJKjinrQbeMdgbPh86wDezTSkq3MXepPbc/GB60u15oLs42j71/f nPM9qV0Q/vaeTXQmt670bg8xRFhnwNVJDXL0+3LvKXuuTuvIk9K0EHs2Bo6M8NAeyez/ EVYwGhCxi8mQ7OZY9LTb75PY/i9TPDhpjMQEmhWgNzNB/P0GlXLiieqJVmse2QE3qxpN G/ML8HzOulCiwHkYO3wR8H6CgnMSCfY7lM8NHZ1jEnxjrrzlXUx9CYWD28u+lvwN3jZB WpPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734628091; x=1735232891; 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=8Em+oJkXu/h57ymGDJbkwlWwzIyyTSIYu5Eoft9tYfU=; b=kSeCvepA6bW4xjA56+YlZVAJlSJOpv3CA/SbsmFTLw5gYt3Nkyqa97rCtDcX9Mvzfv 3JfSwWeP7Gicu+cD4Fu8OGAytjCSXSQQi6WgTX7ahIzFGj/I8tpgN+0/7LFFwVV1ZjaB nvR7r4o09sIDYNhMhEXnSYG63ftfzIw+zAKegzWy1atauTBK5/Mol/Utmqy2Q4QogjNX CcQoPwxy7HUPZQnqWMK0GQ3dnwYL3aryQpBnDERLrBWK495gRKHgcj34ozB5F6hdoav0 gvk/wyDkjXWzqiN6GFg3TMUOjZEwajNKuVWqgks19HxUPtoSchWOgFBt21LZVucK4PZG ELUg== X-Gm-Message-State: AOJu0YyHwQ4J8eXtFMuoXGm6LGwh8Vh1lt4e6at1iUoxw+Yhdaabh119 PQnSqbGafFTKwy7fCmrpBxANlGCMWpEOzcrS+6t6bX/8vLi6n+SEMpjFEnCH X-Gm-Gg: ASbGncul5f/4nleWj8qm5PI2LubGdoziorLHuz1DruIU8MbPE9V2LmMHwa7G558zOGl 2fp9lUUl0/oQLbg//DD7M0NWJHutmx1TNplwRlGZQW+PaAfCBRYqU2bIlrPAR6nfShzdoAjzviR BGTL+umHfTI3oj8bFUQoBvoGg+uz5A+WbOuP5tmQiR0hkDhUorJjIr3jtjRhIaKckQ1ljmH2z6+ 9Zb7rOB1t9ZuLKUD1QHNsjHukeQRxRQm6gyv75n X-Google-Smtp-Source: AGHT+IGi9poR9dnjKt/k4ZI2I8XbAXghZcLY55M5MymR+4dNMDFf01kLgUX4Pm3BllO247nwsQ+WZQ== X-Received: by 2002:a05:6830:4120:b0:71d:5b70:41bd with SMTP id 46e09a7af769-720fe657115mr93130a34.12.1734628090912; Thu, 19 Dec 2024 09:08:10 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2 11/11] ch: configure ch driver to use virlogd Date: Thu, 19 Dec 2024 11:07:56 -0600 Message-ID: <20241219170756.30810-12-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: SOQMJO5UN5I7QTNVKTJXMKKMYJF4WCVI X-Message-ID-Hash: SOQMJO5UN5I7QTNVKTJXMKKMYJF4WCVI 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: 1734628413527116600 Content-Type: text/plain; charset="utf-8" Ch driver will use virtlogd to consolidate logs from hypervisor and its domains. Signed-off-by: Praveen K Paladugu --- src/ch/ch_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index cab97639c4..6161ce4987 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -165,6 +165,7 @@ virCHDriverConfigNew(bool privileged) configbasedir =3D virGetUserConfigDirectory(); cfg->saveDir =3D g_strdup_printf("%s/ch/save", configbasedir); } + cfg->stdioLogD =3D true; =20 return cfg; } --=20 2.47.0