From nobody Sun Dec 22 07:27:34 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 --- 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