From nobody Sun Dec 22 01:58:43 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 1734619661428211.6088216951024; Thu, 19 Dec 2024 06:47:41 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 632C21622; Thu, 19 Dec 2024 09:47:40 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 70C2B15AB; Thu, 19 Dec 2024 09:46:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A410414E2; Thu, 19 Dec 2024 09:46:10 -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 0BC8614E2 for ; Thu, 19 Dec 2024 09:46:06 -0500 (EST) Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-71e2bb84fe3so385244a34.1 for ; Thu, 19 Dec 2024 06:46:06 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:03 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-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=1734619565; x=1735224365; 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=AgM+JbywF7ViURbdKXvAAGBRqs+mex84V04UkYlVTT2Y5CaUr0swfVaPQWYM2yPXU5 PVv+eDo3apzhlILm6BGAcyEoHL75ZX73cvIX3sVzrEDnhCdjJKJX/Wsr/JJ25HGNF6Cs 3iWz7RaKprPjTg13pdeu0f4vQ9MV1F2K0i6HgkHVGDpmQ8MvjfWA8ldcxJfAASEJ1scO arODyUQbN/31iLbTLfoXRC8VYudBxyzwsT1+U2cW6Lol/tSNUYuJh4W8EwgSye2mAsW4 PyuyXiESBPMhRoez4kKW64Nk7R2xI0DVpesz8kUpd0Vl7YkXpXVvbHlBHEBdxbC6jV07 OIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619565; x=1735224365; 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=lGiK44NVUxmSly/Sv6Q1Awyi0wn8AxJk98yjHTG83K5i6l3BIPRkao9urP+tybYbVA psKP5fH5ICJJRWlosifLoIZZUxuleQcpQxADsx2FGj69vRNK8r0ie7a+tQACuLzacoI0 Bw89T4AvNoNqx30CW3kiQ5HPFoT9cJL4tcyawlMcpC0SSSRwhFSvfPBR98jH4Zcwk922 0uXRLQ1kYt0dUkkc3KfuH0AA6ZtMAcuxtac65DXMDHsM8J3DDZX58GwerbxJiwtzlvVz PVYTYys0YNPqsL11PAvIYeHsAcytOQlujfp4ld/kExEQWSAzhimxz+TN8DSmvjan3qGI HeOQ== X-Gm-Message-State: AOJu0YxTb72Ip+FcZ/ovZN1NnWYKfkyZrcH7PLitgXbHACEtJSvTSCWx KcCLhP2t9MXjW9fb1thjcYzNIUEvuAGD1YQyDY9IOI1Pu4MdNkm36QH0vijj X-Gm-Gg: ASbGncvPonUb68rmGtPk+n1WHgWtQ6ZujEYc/PuRGE/WX6MuTESePOVyZeZhs6MmQvZ u6mVssEwpk4gZU44/l0H6Z23Pk4QFUTyzBrwa4WkP4ROEG5+tGEf5aqfKQ8Qze9cK31V3hn/8Wq AZDUI7HQd2snTq20wUSuewCvzJGBcjk2P2nh931yGgL1+8vx6pI9ZZ5cducd4c4riy4U4uzJmdU mz0PEeVbQ9hDJow+ztI5GSkOLvRhCpHeBEAPWGO X-Google-Smtp-Source: AGHT+IHkpQdqWBv7RO6QATZEjm+mVo4y8oHsSMX0u5j6tBqmto0IlVtHavwiMw/Rw4Fu3sJ9eK1kdA== X-Received: by 2002:a05:6830:498d:b0:71d:4dac:c79e with SMTP id 46e09a7af769-71fb763913fmr4270938a34.30.1734619564532; Thu, 19 Dec 2024 06:46:04 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 01/10] hypervisor: copy qemu log context mgmt to hypervisor Date: Thu, 19 Dec 2024 08:45:52 -0600 Message-ID: <20241219144601.16394-2-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LY6SEYWGHQJBVHVZP77RNKC47TU4WKPM X-Message-ID-Hash: LY6SEYWGHQJBVHVZP77RNKC47TU4WKPM 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: 1734619662048116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 173461973106685.04054709739773; Thu, 19 Dec 2024 06:48:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0EC65167C; Thu, 19 Dec 2024 09:48:50 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 776911610; Thu, 19 Dec 2024 09:46:22 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A6B221532; Thu, 19 Dec 2024 09:46:10 -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 67A401532 for ; Thu, 19 Dec 2024 09:46:06 -0500 (EST) Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-71e2a32297dso409282a34.0 for ; Thu, 19 Dec 2024 06:46:06 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:04 -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=1734619565; x=1735224365; 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=EL9gHfS/bLTDto6yTp8TadT/JYnqHolBy2B5ofkAmkNqKK2KJ6gmRY7lKElgh2jMaK e0OvTR7+xMwuQdrv4OXd4LuSYSdZgKzPP+4ttfXDppH/qpkghn6Oyb740L53K3+IdUO2 +w6mefOUnaIWDedhSm9XhQX42Y/owAco+/odX/hoB3Uh26Stvr+GJI1hpq24GmRpGwCA H8V4wMjB+jlIW+3mecxy/bF1EzUXE8akmI3QBvlsIAiuHvuTQq6/iyeWyO7FCqKGZByt YaZiCg9g0/qUOTLvC5ndp2+EHVp9wff/ci60GoqEtlU5LR9CZ4WvHQUj7kMUATuRiHPG pRQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619565; x=1735224365; 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=mgZ6OPwPY3EbJcTvOYKFAadpzm03N2qr4bcjAgNvYjb24ldnzMMQgYaAon+AZjGcST Dbm/BPTcyvJ6ThXvqsXxIeovhdSTtSWQIB1BGPcmKW5NsiWjwZVN55R6dl4KbePfMrzN hA76C/nTxkjQkW8kE/bVaaq10Qg4PPs7NOLvICarm0O3x8NCKWO8nVfyM1uH3ycsbCkx P3hHXqKJ8pJMV6oy77fRnXzcBHToI4NgQlLZ9/geiIPLGnxjbsD0LuiK3heK714of3nD v34Pc9Q5bH++mZZDU1aBIf5xjILPvdldY6hCFNHLs5W/KD22OEQUfWqWYwu6S3obr5U8 8nLQ== X-Gm-Message-State: AOJu0YxHRfqTs9iZkZHuHnZnAFjpxmrw+LVGOBtQ1pzR9uIlUGTVkDft AHbthvvsQd9fVZsFjlJ5Fju9qJQj5m7fCXgWqEWVZsewmj60FkLU7/qlxWGp X-Gm-Gg: ASbGncs/sDxfJzJB84XGuTH3Q282E7m2hc0VHn5firxx3ozf86shrvgRNk+j52MZLKi wxrXiv3BoQC6KieXiETXUUazfaLVfVX65pQFlqduWc8//OZHZOWw5SX1TqCt5JASe6VRnRfqi5e hwmCImbCZ8JQJprS1VIksvHk5GdewLSKN3zoGCeMVGwbNsrbCAempmggem1t7otNogo3jG0NZWb jGqWnl84mR+8JnOmAHZZXyV73xkGsw8V2ChMKtl X-Google-Smtp-Source: AGHT+IETnNQltZquHgEJ5rm5mcjzQ13NAGUec7JFL2bz0QyG2PaFyPGeUnzNJCaiKnuM+wQ1Oix/YA== X-Received: by 2002:a05:6830:34a2:b0:71d:f7d8:225 with SMTP id 46e09a7af769-71fc5b79522mr1388536a34.12.1734619565269; Thu, 19 Dec 2024 06:46:05 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 02/10] hypervisor: rename reference to qemu in domain_logcontext Date: Thu, 19 Dec 2024 08:45:53 -0600 Message-ID: <20241219144601.16394-3-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XQMRX5BVBN5U6QY7PUBKOF77K62HFCXQ X-Message-ID-Hash: XQMRX5BVBN5U6QY7PUBKOF77K62HFCXQ 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: 1734619732038116600 Content-Type: text/plain; charset="utf-8" Rename all references to qemu within domain_logcontext files. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 1734619625478415.7857917327955; Thu, 19 Dec 2024 06:47:05 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5ACDB172D; Thu, 19 Dec 2024 09:47:04 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 91A4C15CA; Thu, 19 Dec 2024 09:46:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 960AE1548; Thu, 19 Dec 2024 09:46:10 -0500 (EST) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (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 C27211537 for ; Thu, 19 Dec 2024 09:46:06 -0500 (EST) Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-71e565708beso477110a34.1 for ; Thu, 19 Dec 2024 06:46:06 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46: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=1734619566; x=1735224366; 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=J/srRvoWs69K74KFqctjvc6Y86wYhKPFAPeAdK60qZr3RxOO688yMkz10TBxZnKEvR bmSQxG0KM2/BZEhSaJUzCW/3lKChuswAnxehwP4RKbiFWvu/XCSzFnBxNv2aDZ4pq/dI zlodFnUK5ZeTMRnikHY+91vMzigWPYZ8fTREuWE22p2mu0IPq3Vz1ObKsX5Z9ppu94FI Jh43JsDzAtiU8gOyTSZBAwYgjhcVE7fzQ3nwYtIkAgzeeJfzhqrxFFX9XMOY/9x+oBD9 nD1Qrvc07MiopksBin8dFy9DphSrS+2U7yzAvL2TG1GoKL+OC008yoTi6cSFWocph54O TRpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619566; x=1735224366; 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=UyW/uhbRn9x2OZ4YH4L8sWfvn8X8JEvdJhtBeA6MgfKlQDq+bUoMAnWPI6Wpbp3Bww NYChQdkhB6YYrVwOKIN2fMpj7JsDHBP+31bxhJDvIvTD41vMaQYRlm82UHgyHZ7kzgWy +0yggNFdAFrM4jAveKyCrXMpseMCcnn0/BoBsYyv4uCtDaph4pnXiINYLe6ypHYuAva8 ywte9X8Izi/NhQg9TLXYPJaaEZoJEfARPkugi+QU/cwMHckfuT82L0N7YuAI549QNUEh RXIvcYDb3xQyaEwbsvT+/EcW4JSz3oBG0NeEcQxqRoyipDESFCJjxWpM4wVVAVpr8myl mg2A== X-Gm-Message-State: AOJu0YydlJ/fRMFgI7RHUXpM1OpiNLLKBJ2nvyrff9RwIUAI1zTvpGPQ j8luC0YiResxBysU7I1xAIfdRWdNz9TGCjLAQ1byl+tqAprOex/FDGEaAG+x X-Gm-Gg: ASbGncumwe7Fo5WDpjsHccfB+CkwhkHay3ai2TCubWXqPcUjT3yR3lkMXO3jgSR4xge 7vq7jSqrZnj760g0+4vSKQODwon3vcTzMThojF5cwxFSCSTec+Ncs40KnK51RQbwf7nPxmHIHHy q8pBERplLIrVHANPa6BpxEka8SzXNJSP3KqTBXjUutf6GaF2D6j5ZYqRvyKbZHfzz30lsj1qWWE ZaRUr4uKihVmb8Gyx1nPKgXGs4tha4CpteqHBAE X-Google-Smtp-Source: AGHT+IFPfTSBKUyAtSnTrl3QPaze3/g9ifJzaXABptCvBMT5uzlG86000qDIS9DexTnKp+JupMtNdA== X-Received: by 2002:a05:6830:7109:b0:71e:4fc:6ee1 with SMTP id 46e09a7af769-71fb757ae41mr3768953a34.9.1734619565882; Thu, 19 Dec 2024 06:46:05 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 03/10] hypervisor: drop qemu specific args in domainLogContextNew Date: Thu, 19 Dec 2024 08:45:54 -0600 Message-ID: <20241219144601.16394-4-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3DADNDVSASX2CDYYVHC2ONXIWT3ZN362 X-Message-ID-Hash: 3DADNDVSASX2CDYYVHC2ONXIWT3ZN362 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: 1734619627637116600 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 Reviewed-by: Michal Privoznik --- 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:58:43 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 1734619705643109.62844674339931; Thu, 19 Dec 2024 06:48:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 91AF11540; Thu, 19 Dec 2024 09:48:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B20A41661; Thu, 19 Dec 2024 09:46:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A5D4E152D; Thu, 19 Dec 2024 09:46:10 -0500 (EST) Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 35377153D for ; Thu, 19 Dec 2024 09:46:08 -0500 (EST) Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3eb9ba53f90so216029b6e.1 for ; Thu, 19 Dec 2024 06:46:08 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46: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=-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=1734619567; x=1735224367; 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=XYehPTBg7txsgjIlgy3j83Yr3mt933GPnPtAFOoqqvLnFi6cDNUou5WQiHsJjrald6 dcHPGAhfC7X6sqx376lq40vKMAbzGmLYMUcdQwaacjffmnMtVIRSYyBxZpyCFIUfgjhv TcKskNFmqdMrhMl9A3HebiVeBagByxjqgzwO9w3wXrHDmoSokXO1n+iw5Y6GgIbHK0Ob xq1ssaCAlhlojFcF5EjRnRrLDx1W2VcKKfn7gWXpQN2umMPBFmEYVoRRZSyp0zo3k/Id hiqupalvstPjTtbrv5jds7RMgiGSnXl7q8j5Zlb3rU9A5mcipu/aP5mKWlqslZO/Ly05 xVow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619567; x=1735224367; 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=YTGIk3xUU8HZVbUKkwKczoai6u1E9rKkDcoeo+4ebXo1nuWah5hj0kpqJrcgNpDas5 8DnSLYOHC7M/Xk0tGESYFYSK2qeNZrMkJrqtd3nplKwg8WZBF/zd3XvyhyeD+5ScmCfo xVldzlVQYNpGFb4nyQSo8HjUOvK0u0KgZ2/GkzZNW4Eu2Que3mlHAa5kbQb4MaqRsOuo 7FiTs4N7ZDkIyGdZAs+njmpaoBQSB9e5RGVzaIEspLNiON4M0/2WPu/cqKXrzYozapxA +/auqsZNeDvPZHQD7S2V3rAdBz/Yl8QQOqVJGZQ11j5CAyA7+GMH0S4ORxurXrbyUBp4 RcqQ== X-Gm-Message-State: AOJu0Yy5PeDGwWkKut/DKl14jbgjNj6Mbd8IvzWW7zhtgvTnZMn+6aFZ oUmxCj4lE4i3Ywl0r37torFuDVmhHjzbH96tV13YygfrhXyi14tD80OjGGRb X-Gm-Gg: ASbGncvD9X1HL54Kms8pHAG0YS0lJTdTOrX9ZnYkCPgi2drBAG9wtQ87dNGZsu8mt/T TUhD+ccnzi7ZasuByv14WkYZ0/VJmqjclbBeuAe35UVczaAMkAwtBQtspBL8636HEHpiUPaMCqP 89Fyooo1S/L/NVBvPbDVl+ebfjT/l/cHQS+ypoUYp0u+P39fOqyRLG26lXn05m2Q05FWG7xfBr5 gWhgImMAKslnA4wh8w3m2wQfMRKy8bIYB42SmRE X-Google-Smtp-Source: AGHT+IHD4VDKDKiCCOtsOPJ27i1XhzMnDSXjHbMFf/o9Rwkbc0mEvZWH5E0lD/v2AFHqXwJAt4D2Vw== X-Received: by 2002:a05:6808:1884:b0:3ea:6149:d6fd with SMTP id 5614622812f47-3eccc035179mr3947255b6e.2.1734619567125; Thu, 19 Dec 2024 06:46:07 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 04/10] hypervisor: Build domain_logcontext Date: Thu, 19 Dec 2024 08:45:55 -0600 Message-ID: <20241219144601.16394-5-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 66DP4IQSNTAJLCDHYTR3JSN56WED2OCS X-Message-ID-Hash: 66DP4IQSNTAJLCDHYTR3JSN56WED2OCS 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: 1734619706058116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 1734619679162540.0255560040997; Thu, 19 Dec 2024 06:47:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 321CF1554; Thu, 19 Dec 2024 09:47:58 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ACF6D1566; Thu, 19 Dec 2024 09:46:18 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A50191536; Thu, 19 Dec 2024 09:46:10 -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 4470E1540 for ; Thu, 19 Dec 2024 09:46:09 -0500 (EST) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-71e17de2816so395352a34.0 for ; Thu, 19 Dec 2024 06:46:09 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46: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=1734619568; x=1735224368; 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=jgaYIOxq9Haw3NBLMS+zRdM2yUbcjnEZGOCjDZnLP0zg4dAeDvf6h+rfi4AI/e1RGU ApoAF6OS8tz3tsjbFaki1UYjZO1GxNrulkDuNgLGC66jlStoxOM/PHobyTToiXEB5FLS gjDlCVmxL+1kMK5Ock7SK7Hjjvfq/3HIvwNh5NHi1i8WPadwAofuViRrYJvhIbhz9Ywt 2crusgLv28T9ZHb8AbqBXdIPAqVbSUwTuQMIXQpzkj3QQ2w1+8vMUIaV1zvEseMULeO+ F0tPNrTQargoUHrFU4blyVUoStWb3Oj219VFl/pyKViGgBp7EGJd/UxT77z9ozLX094Z DZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619568; x=1735224368; 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=kMkL+mXrNx/o5M2KRm9bpVAPoc+YZvJP30Ru/trf5ziLjb7nUxbcwVhDFEukvnBEhL QXIbLGsc8GwQza6HJL265FsiXGvsFaG4IEbn2fDXT5Ak64bNVgKd6/qTYgKPPngF0vAZ qojoP0e13+MT7d0z1qN3rxMr7UBCtJ5M6IzYMCZP7agBx+3iz8e6irX2k+yYpqR4YA4N HBD2thvVE/H85rlDH6uMgKoft6dExBOOGqXgIadY0mUZIzhvqRXi3BTkpvr/Gij5l9OD UT02qTl74b/SF+KhnUX1XIBVlFBmPX0Dg2jn/g/qpyxCUZC4FjeTxEk7sJ5g1FNLvNZX P71A== X-Gm-Message-State: AOJu0YzcLwXLU1s5Dz3vMd7DFNRztaHZ1DjksP0lCALP6KQM6Z/hD9k0 xiimsIF0ETZLf9QbM/4C8cDs2hc9w7WT2vmCDd+llMrP285NfENXCffzH05m X-Gm-Gg: ASbGncsl4ulZAi7gftqY35L8IQ11QOEnXoICtcxds3h2I2v7VfIWIwvhCJ7jw7xevWW q95RUszpMlgN7JIKxRK0KbC16Xpy4QL+d6fqK0cv08z1RfLmJnKVFbQLNhRePkYzqtOYwZGD6Oy mpHf67zxBG2k5vJZ3HF5PGSjDgouAuh6dChSbEF93k+BBB1Hr9fy7dsroHcmTVRxjcEKjrnoezx ANPJoyizVlz1dOERFF2DWSWdzzKJM58vWGe2zaF X-Google-Smtp-Source: AGHT+IERTOiIqta0RHxTJc8i6OJLv2/EYX/nGEHSFJLjT53HTixFLdM5C8HmPF9yYJqPzIam3PGsuQ== X-Received: by 2002:a05:6830:6f06:b0:71d:62ad:5262 with SMTP id 46e09a7af769-71fb757ac82mr4382879a34.10.1734619568028; Thu, 19 Dec 2024 06:46:08 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 05/10] libvirt_private: export symbols from domain_logcontext Date: Thu, 19 Dec 2024 08:45:56 -0600 Message-ID: <20241219144601.16394-6-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DIUODSDAXABAYOSYCYA5CXPXL6GRWGBT X-Message-ID-Hash: DIUODSDAXABAYOSYCYA5CXPXL6GRWGBT 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: 1734619679862116600 Content-Type: text/plain; charset="utf-8" Export required symbols from domain_logcontext.c. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 1734619765602350.4404190187612; Thu, 19 Dec 2024 06:49:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 92F589D4; Thu, 19 Dec 2024 09:49:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 528AE16F2; Thu, 19 Dec 2024 09:46:25 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 223B9152D; Thu, 19 Dec 2024 09:46:11 -0500 (EST) Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 24416153F for ; Thu, 19 Dec 2024 09:46:10 -0500 (EST) Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-71e3f291ad6so493098a34.0 for ; Thu, 19 Dec 2024 06:46:10 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46: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=-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=1734619569; x=1735224369; 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=hd8M43j7dF1RTrD987BrnNVH+0PFZme/bitXuyZUGVXFrtslVq+3ThKxNNy6ZtSt9j nRW82fU72qdl+GbORfqt2E4bA36vdnkWjwvNXhRJ7NJx166yX4nKwk7Nb4ctXrczFEgv si9STga7joujCY5A/qkejcS9XQv6cX1kcWZV/EaPwnCEHwDl+u3dE/ADbvdemHp9Js0d 3+UvXoyrmpuKnvGt5W/Tdu3amN9uXd+xyBWTFNBn2IlctTLyEiubk4+z1VYht4BZnwna +GvYNNszNyTjP5RKWeQJKMekkw8DwvNaUxC2H5L+7yJd9vy4kVfIStI+hVgIhlUWabNA 2i5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619569; x=1735224369; 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=WbPePURhLMJaFrLm2TspNEZz6U/kjaAsHnmYO3rJ6wYZxnpRiRB0uQszq7E1eHa8FD GE4ncdn5GAKOeN3358sbHWimsmRViZLfOUcddbx7NjA1mxL9ApSX2I5Qok1BeEioQQNd WBUDYCo+j3a2TWeixQVG9MpzM27Zd/N882do/zn1fsz++dpIB8EL3wnrVfOLbke8Nmmc yiAXhQ5jV/zRI/idRxLH8WMi9iysEgsNVswdulGoRSNIyDLG2x98vXo4Fks5+d2UZU7u 7hdX6/7wODkMf2UOLCg8K+KLcXkHOAK2KyaRLsod+VdablBNLEcw0QAZZeK06QSQ/Qjo PHxQ== X-Gm-Message-State: AOJu0YxnWYaRDYbGj1Fmgb7QQtKEaihkgRJFF3Fz7SDyHOdn/Ftuc8EV io2oHl72YBVEm2XIW4mEAL18ehCLjrgPdD9LtWLvFPe5NWdqprnOY5Ml9TFe X-Gm-Gg: ASbGnctcUaejgObYuekXttX4IZdXRiCbmZMTWENZt01ZXL8Le0rTJlFj1P8w6/7+cOk KJ+1doAreaLppFhpD3ASEavj+JLE86fvYZvye9BAccJ3r56YShUpi5P6rt+3/NNjwagaNHSwvzH dP6oPjyy6kJ8s5qq5iZPSuHHJbHyPRLW3l3hj2Qcb0FjcZTv6YYDFOuSOaKAmGREJqeQvdB5YZM ydRI0a6Le/+Z7IcJ9B8Rn8UsXrNbWeJKq4PsIpl X-Google-Smtp-Source: AGHT+IH95xmcnqfxJw2SipoP7jGoIu8u5LfjF/iOBNtNISuf9Cc+1w49myWupMFcrtbo1UL1rl3QMw== X-Received: by 2002:a05:6830:6dce:b0:71d:f239:c091 with SMTP id 46e09a7af769-71fb75642a9mr4198651a34.6.1734619569110; Thu, 19 Dec 2024 06:46:09 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 06/10] qemu: Modify qemu driver to use domainLogContext Date: Thu, 19 Dec 2024 08:45:57 -0600 Message-ID: <20241219144601.16394-7-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZLENYRHSOGCXLVRIQWBIKB52B4VMXEU7 X-Message-ID-Hash: ZLENYRHSOGCXLVRIQWBIKB52B4VMXEU7 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: 1734619766225116600 Content-Type: text/plain; charset="utf-8" Modify qemu driver to use domainLogcontext instead of qemuLogContext. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 1734619801176666.8313542970283; Thu, 19 Dec 2024 06:50:01 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0F13C16C1; Thu, 19 Dec 2024 09:49:59 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EAF5415EB; Thu, 19 Dec 2024 09:46:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BD8441537; Thu, 19 Dec 2024 09:46:12 -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 8C77914E2 for ; Thu, 19 Dec 2024 09:46:11 -0500 (EST) Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-71e163493efso496893a34.3 for ; Thu, 19 Dec 2024 06:46:11 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:09 -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=1734619570; x=1735224370; 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=UEQWGoPL//IfIHoP553PLvvIK2gxi+JkHGeYCbfCH/6HmAR10hJ5xthtVZj1lI4bzi VOjzOMiTW4Bfeoznc/1OUog2k0Eanmqk/fDc6hev21oNSpdLNsOEqFqGspS9bIMcS0/d HqnTW0mRPjGSR0u4gmQBO/RjKdtju5Mj1hHf+VpMwxu2eZpJ+IyOc2KnwytiANr94jUa DRl9t0NB/LTZzRaQKkbaROzV9/7uy8JuKXdjalsakmxWBlWuubdjkib0187EhF0fc5sQ Q/Z11zhmWby0aIXKTxxpUvQftqPYPOgQkU+C89G+u7WxxiqfxPdGwoRE9JUPYc+jajis fCQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619570; x=1735224370; 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=TdNc4N7LvQ57XGMKbpw9isBJELk99xCbD9RBgD8XQ42WsQM8inaJ0huBM9X68OvWiN xsHhp3t3LgGSrQ5BtgPcmFOXFF4C9vpOAW/dJObtVcLEkL1ltGAwRgsXgU48O9f5hbWG Q+YCbjJGjyzyhQGFqesQQpX8kEjANilu9k8qY+saSEeceZoW7ISUz+ci4YuExQaj8Lvt 24mHEqQjhZaeidC5VdFAE/F4Q65EkqWofilTAIhF2yluThttyqa7Zn8+FTpqRiihsphf NvYGmN+Tcx+M1wCMdCkuPeVFjt0Uq+nQ6r49KlzKeO8Cby6Sfb15ThqWdxT4BTpi17F4 zgMA== X-Gm-Message-State: AOJu0Yz+Y5D53Jciqz5mLOYIv3zx1fYhP9wRsopCECVBvo0SLLIcwie1 8rfrPfkbdZ16i7akAO87zK791OXSHkmeU3bfL2WPCxvh7CaixJdFB2Pdx3BX X-Gm-Gg: ASbGncuSZ0UgyJmq/8xXx04z798BcbXfOrvwQDGwCu+2qcq/+XM0Zi7CXdU7dpTt8K4 FaEMkvt+2pqCYrlRmof34WCXxvlaUPIPyZwxjXiaZQpDtwRFspRA4R5aJH97026CbfjiTSbLKjc 1sP5VDRj0jWECOL8HmCn+OYEhCrN9DttAVlD4EH35zlZK+NHgxwuKgfsQ3CrpodCqp0CbQueK9b lrrcN04k27rGhN8n66/jKrCZgZpK3Z2Z1mUPli2 X-Google-Smtp-Source: AGHT+IEe7mEXbn+p9VGUmp9DVlW2LiwrSDEH8dxjGYmSIRHeXl0A1CCbkeDYcxd6EPpvWBKPuuDNUw== X-Received: by 2002:a05:6830:6dce:b0:71d:f239:c091 with SMTP id 46e09a7af769-71fb75642a9mr4198715a34.6.1734619570330; Thu, 19 Dec 2024 06:46:10 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 07/10] qemu: delete qemu_logcontext files Date: Thu, 19 Dec 2024 08:45:58 -0600 Message-ID: <20241219144601.16394-8-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VNV442QXJJOZT4ORYLLXND6YOIFBB35B X-Message-ID-Hash: VNV442QXJJOZT4ORYLLXND6YOIFBB35B 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: 1734619802570116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734619831464217.98621840793646; Thu, 19 Dec 2024 06:50:31 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 65BDC171E; Thu, 19 Dec 2024 09:50:30 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C889B16FD; Thu, 19 Dec 2024 09:46:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id ED4E11532; Thu, 19 Dec 2024 09:46:12 -0500 (EST) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3BFD21532 for ; Thu, 19 Dec 2024 09:46:12 -0500 (EST) Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-71e17de2816so395371a34.0 for ; Thu, 19 Dec 2024 06:46:12 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:10 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734619571; x=1735224371; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q5fgYIVbZi9WYYQNQ2uIJb3lDEE7CZnZhIdQym+FSuM=; b=RH5Bts0bOL/qcyNVD8Jj6Uf2qyEH+GXsI7K71CekL1xzNySS8zJ+ZzZ4hQ946qKSBQ GX+GXzSlshh939umKbsVrsEFBOmXJmZAfLPqA1JGs/6bo061Dshf27IpHIvEXo9yoJ+f +U5a7m/whMTxOnsukpNdbNm7PhuqWTMY6x8kzB+h4pFyw6nDNBCZ6VXMgJA9QC/ovbEk 75IVkiv3OKVP21bPh7YpA9mdJjBGe65zvOO5LC+GSZQ7CgtRtawJPZ1/4Ih6kUgeEoJ/ eKQb4WJk8SRoVjlnNcQzUtFBc0TxDHAUFlqmQpu/YfQdKEdYW32O/htYLiQJcuHzS3Ol TEtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619571; x=1735224371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q5fgYIVbZi9WYYQNQ2uIJb3lDEE7CZnZhIdQym+FSuM=; b=dZNVZBn5mbD94Htxivj6SCxQ/1W/79u0yi6/thnPIUSH4dhCNt7bwq9LV/LR9JsAbT 8rpfvEhX128ko/69pXLHOyloHWW40VUS5hDpMqpZHo0nSSjtmnj5EjyUQ0+HjQ6JmW1R JM4Igxcqa0P8fLv5GttNERLdguPR0Xx13w4JDLvnmSGTKzMBxkaf2LWAQm4PtlwmxAfC bqS5IJI5XK7QhyGBX4qIQ5FBfqX+AAl2XohW7CM2/O1yW+tyG7lc5+EIf3zy91DBtmMF 7Icx757cjqw36GqxqEXF6xZC+uK94+2V83M2L5zJtXzE2rUru/5q1hQgSNfopCKxP611 gIZg== X-Gm-Message-State: AOJu0YzcPAiqNiEI6P6gm58X4XLQdFv5tSbS8EJvv30p9yBfADWLFkJ4 TkI/7IGiGJdeksOkcMXuT/hnB5AMwuF8JR7nnprNFuLNjVTjWTHNaik4h+IS X-Gm-Gg: ASbGnct/ITrxhfwjGKrRBRkR87sjASZ9nL2pTrdV78Sm/Dy1rlAdjQI0iSBFAGUG1nd X29tL3ymhEVw4q4tcANMPsac4nXlQBBaDKUzPD+PkPaBNZN+/cLu+7a1MBcHqdUKcWWlz1yv8ke bo3vzRPGXB9w9z8PBv5008cIDVAFuzQJFYyLsVUAr/3iSdu/FpDvznxD/63x4P8z7rmh7eL830V g6aFlobdKRUlf61lTheg966Yk2ytN/a6EGZnZsq X-Google-Smtp-Source: AGHT+IFI33j61Wy5rvgX2Vkfc5pWTY9McPqxiuajAj4HesnXbUiqPChvH0M0xpuutuc0fAWsI/KfTA== X-Received: by 2002:a05:6830:90a:b0:71d:e900:2322 with SMTP id 46e09a7af769-71fb757abf7mr3818209a34.8.1734619571326; Thu, 19 Dec 2024 06:46:11 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 08/10] ch: Enable logging for ch domains Date: Thu, 19 Dec 2024 08:45:59 -0600 Message-ID: <20241219144601.16394-9-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GVREOZ6TKTNR7CZFPLF2UJOQIUSLUVXC X-Message-ID-Hash: GVREOZ6TKTNR7CZFPLF2UJOQIUSLUVXC X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1734619832642116600 Content-Type: text/plain; charset="utf-8" Use domainLogContext to enable logging for ch domain process during create and restore steps. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- 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:58:43 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 173461984730513.025049124464545; Thu, 19 Dec 2024 06:50:47 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 51FA81704; Thu, 19 Dec 2024 09:50:46 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 05BE7166C; Thu, 19 Dec 2024 09:46:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 572D7153F; Thu, 19 Dec 2024 09:46:15 -0500 (EST) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 DE2E8153F for ; Thu, 19 Dec 2024 09:46:12 -0500 (EST) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-71e16519031so469296a34.1 for ; Thu, 19 Dec 2024 06:46:12 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:11 -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=1734619572; x=1735224372; 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=QG/Lv4Mf+sE1UBXUO1n9JJjFXMBorsE+M/aFelUSMu9phY40f2kTqWSU0Mw75LymXF MGzE3obmGhpNGOLXEdKFTwWLZVZiySRsKJybrBA2vc6l9FN+y3mM50cyKW0Ak85jagBz qskZXU6BTkCgbB7Iv/uBGiYm/3l+MjQHzgZUgyHtYYEYyNsOLu4sawzstQ+ESWIi4mbl LuW336hrcYP23vgqWZYmwRq9HuSgkTEGja5ww1KJhcmEvT6XYGPS97JIbcs1My4rE+BW 1wpmyFN11gwVmQ/WIvQPIxIapWZQwlfoszk557BNOtQfm1/z3OJtAqb/PKBEo4Packh7 VORQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619572; x=1735224372; 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=v/weX7OV59x3lIzc/uf5lrag8SN8j9MQUAYTIdMs3ulZC3KprI18DyTEEMHza8M4E6 MuAMVWNzcvW0VSVfYA5xHCZmr6A+pBsk66NrSn49jmm7vfRG15Vq+g07eM2DwW5P1sFB fSe8mPV6/W/js03O6KewRtU57ENNVG4BxQ5bcei0Z9BquOPHSKJk6lZVbbffR1gQB69A U0eihhcLIFRyniHCzIsQWbrv5UMXu5FwIGExV4kZu5UJ8+kL7YVZML8I5DxwEzzaD7Q/ G440yvPoZm63V+xXR9WOvnWWMVojXdzTgsi/1k515ko2fQeQVEOhTWSG0xI6SGb1iK45 +4+w== X-Gm-Message-State: AOJu0YyUT/QGLsidDQqTvpd3uAKHlY2RdKwf1YTYVOx/mMkwp28SY5E2 U361OO8Y6dNHPJBITA4vRlaZuV3jB+v89sDjKSYE8MaELE1/kP/qHsmNiGAJ X-Gm-Gg: ASbGncuMqqyfvJnaGDxMT1slINIEMdYJAQZeZznopHWMKt3t7e3Vcj9duXxKlk0PBqH PS9cEvRBgWp74K9h986g+MMwogFTCtOUHK1BwV5chiZrqv8mVMtSW4btCYPbf+fGjLVnypzzcCR MVfE4J3X6KSDFTCE/n/xbxJfnuEByj3TtTlcBDlVGbErh1rBX7AaYROq1udnv/DFXXaxQNotOrs ZZ1XBK4hE5AYqxdrNGd8P1quv5M14E2uyqZwarc X-Google-Smtp-Source: AGHT+IGnJYALt2kP7XhWznPDeuF1CkBSc2fT6NacGkRaGVP5yDE3gkVfxoqcMKz76/8hU1uqVbtTZA== X-Received: by 2002:a9d:6d8e:0:b0:71d:e923:6d2f with SMTP id 46e09a7af769-71fc5b25660mr2298518a34.13.1734619571986; Thu, 19 Dec 2024 06:46:11 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 09/10] ch: move curl_data and curl_callback definitions Date: Thu, 19 Dec 2024 08:46:00 -0600 Message-ID: <20241219144601.16394-10-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RYO2JV4CRVQ2ZNZO465RHPMXN4L6NPLO X-Message-ID-Hash: RYO2JV4CRVQ2ZNZO465RHPMXN4L6NPLO 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: 1734619848492116600 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 Reviewed-by: Michal Privoznik --- 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:58:43 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 173461988592596.1970773069047; Thu, 19 Dec 2024 06:51:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E10DD153F; Thu, 19 Dec 2024 09:51:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8FBB2160C; Thu, 19 Dec 2024 09:46:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 32B81161E; Thu, 19 Dec 2024 09:46:21 -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 50DB2160B for ; Thu, 19 Dec 2024 09:46:14 -0500 (EST) Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-71e2bb84fe3so385287a34.1 for ; Thu, 19 Dec 2024 06:46:14 -0800 (PST) Received: from home.. ([2603:8081:c640:1::1009]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71fc97a40afsm272978a34.25.2024.12.19.06.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 06:46:12 -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=1734619573; x=1735224373; 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=LOXWW2d5cxaE4LDPi81BVC7GjOKt7juicsdeqWcK2c/O6k1tfGhuloNWm0RoOq4GNd 1kQ91xDf7ojTiObVDa4dG5o0e3RS2Teh3HtKITewxM5Wrjg/1rTZmLCH/dx2xmeBKlCl jsM6CoT4pchUei8iofvbzn+cjZgD2oueqoowCVfM9AvyhVYYqAv3LyonEtPxBRapiYJj ElUlHHKnnfrT25zR74QsFBaB6CWewg4Tr1KYcaLWidw9Uy/ukxpV6it5xfduH5rw/KVl FWhRIoOYABO4hDYBlI1/QyX/diPHbjRNqIvbA2o4aIc0J01cjLZwJDXM9vCxXmzXJsn/ 26VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734619573; x=1735224373; 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=ZInhMkCbs+vQ6U3ni0rDUTUcf+lwtfD3Tsp7KviFoUDtXd7qIL6nyR3+n725p008vl 1OlDIcWHdjJaiochKfxgg18OX7F7gV5iB+K05zoMMaScefdGVwngvT48OUtGG265YDFT AjmJJa1+F0pW5Xf5ImmcKFEAhDjjo0O2i2P25Vnoljz+2hsmJYk/JHosK+dnCgFWbVQ1 zVdNPCJKCKs8g7Q1ZQ+YrT7DnUpdYEBf0TNBT3Hzgw6MpbUtQ1Ubj6u46Iq4zw561XXY mYU/KPdBWjwjZxXr+AUZq2JmLekyOj7MIo+xdp9y1Ip5EFRXu3EtAeVdxHmv8vm6FiEB Neug== X-Gm-Message-State: AOJu0YyBhQJK1zIfnbMM08lgXRmqTkLYwcRtazrAwwHFIOgGqr2xYMdP ReS28C2+z9jZ58tMMIQfI4qqu0DL+wE6NciZHpxaHimKdYwACBzSYRciumzy X-Gm-Gg: ASbGncv0gh+HqwNzwwOeBotFxUY8G+/sOEhJs43hl8NpB4VQceySmxFZF2Y0mINOCD7 g5BLWTgv8t6l67bzKIudSq2y4KbxCs7Uqt5h5Fz6PxC/JWXTBlIZXcvR/tdbkKhC+22eRDS45fC 5QHgS+KV0tixKkjBsKlifPhzKxIYWLxdPm8s8ltnO8xBcTac17aR3fpUNvyB+0wT3GKm8bukOnv n1CUVjmL3J6BIr/42pmEOncMHWaDNh60L+/xrEY X-Google-Smtp-Source: AGHT+IEh+b1hhJpJXv+nS5lOCULjtKpJiKx9tUGWLtd6n1J2LzhniB5h9oSNgFRnZLFrxeH9oNoJ5g== X-Received: by 2002:a05:6830:6606:b0:718:17b6:56f5 with SMTP id 46e09a7af769-71fb7639e4fmr4842439a34.29.1734619573199; Thu, 19 Dec 2024 06:46:13 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 10/10] ch: Enable logging curl responses from ch Date: Thu, 19 Dec 2024 08:46:01 -0600 Message-ID: <20241219144601.16394-11-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219144601.16394-1-praveenkpaladugu@gmail.com> References: <20241219144601.16394-1-praveenkpaladugu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HZAS4KM74YG6XAOZKULLWWWGOU3XULXN X-Message-ID-Hash: HZAS4KM74YG6XAOZKULLWWWGOU3XULXN 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: 1734619886712116600 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 Reviewed-by: Michal Privoznik --- 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