From nobody Tue Feb 10 05:44:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565276301; cv=none; d=zoho.com; s=zohoarc; b=l6IwJW23BOwhrmT7xTlxIDKnNmDANBosWc8B0WXsDrmBoXQByjd34eR29DEbizhFq348EmY6WQDlb4csxx7rdn/uW8vsMXy9+zVKSnftrU+paGh3kWHAsqrWy4HF9lG1kJ57ygkqGvYmA8IACWL+Z1BoSVRXANDFco95G9DHodQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276301; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vDdoym/0me1ASgMp5qK2Wo2Ckk/DW/j561tlrJTJESY=; b=V1OHDeMc3Q6uQlmdt96vXPWkMWZs84PZ0et+qohbZFAH+mKnyBTmj2BOVmChBc39VCDA+qR4Xt4h2Z1yXIbjUgI9ldRf1Nniqhc3NTVIBc8W3hQHq3c76g2PKybyPYHy19FoeeUBg+G4tggowSHU5eRL9bxl3k/k1dMnEsMmmlk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565276301296813.0506895527802; Thu, 8 Aug 2019 07:58:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AECE30A00DD; Thu, 8 Aug 2019 14:58:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 048F11001B02; Thu, 8 Aug 2019 14:58:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BD58D8354E; Thu, 8 Aug 2019 14:58:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78Eu5G9022869 for ; Thu, 8 Aug 2019 10:56:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 618C25D9CC; Thu, 8 Aug 2019 14:56:05 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27A505DAA0; Thu, 8 Aug 2019 14:55:58 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:55 +0400 Message-Id: <20190808145514.20789-5-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 04/23] qemu: replace logCtxt with qemuDomainLogAppendMessage() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 08 Aug 2019 14:58:20 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Once QEMU is started, the qemuDomainLogContext is owned by it, and can no longer be used from libvirt. Instead, use qemuDomainLogAppendMessage() which will redirect the log. This is not strictly necessary for swtpm, but the following patches are going to reuse qemuExtDeviceLogCommand(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_extdevice.c | 35 ++++++++++------------------------- src/qemu/qemu_extdevice.h | 5 +++-- src/qemu/qemu_tpm.c | 4 ++-- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index af52466421..0aa050cb0a 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -36,39 +36,24 @@ VIR_LOG_INIT("qemu.qemu_extdevice"); =20 int -qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt, +qemuExtDeviceLogCommand(virQEMUDriverPtr driver, + virDomainObjPtr vm, virCommandPtr cmd, const char *info) { - int ret =3D -1; - char *timestamp =3D NULL; - char *logline =3D NULL; - int logFD; + VIR_AUTOFREE(char *) timestamp =3D virTimeStringNow(); + VIR_AUTOFREE(char *) cmds =3D virCommandToString(cmd, false); =20 - logFD =3D qemuDomainLogContextGetWriteFD(logCtxt); - - if ((timestamp =3D virTimeStringNow()) =3D=3D NULL) - goto cleanup; - - if (virAsprintf(&logline, "%s: Starting external device: %s\n", - timestamp, info) < 0) - goto cleanup; - - if (safewrite(logFD, logline, strlen(logline)) < 0) - goto cleanup; - - virCommandWriteArgLog(cmd, logFD); - - ret =3D 0; - - cleanup: - VIR_FREE(timestamp); - VIR_FREE(logline); + if (!timestamp || !cmds) + return -1; =20 - return ret; + return qemuDomainLogAppendMessage(driver, vm, + _("%s: Starting external device: %s\= n%s\n"), + timestamp, info, cmds); } =20 =20 + /* * qemuExtDevicesInitPaths: * diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index 5a53c79f38..cdd20c28ef 100644 --- a/src/qemu/qemu_extdevice.h +++ b/src/qemu/qemu_extdevice.h @@ -23,10 +23,11 @@ #include "qemu_conf.h" #include "qemu_domain.h" =20 -int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt, +int qemuExtDeviceLogCommand(virQEMUDriverPtr driver, + virDomainObjPtr vm, virCommandPtr cmd, const char *info) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBU= TE_NONNULL(4) ATTRIBUTE_RETURN_CHECK; =20 int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 98fe8a38b4..7537091e90 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -834,7 +834,7 @@ qemuExtTPMCleanupHost(virDomainDefPtr def) static int qemuExtTPMStartEmulator(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt, + qemuDomainLogContextPtr logCtxt ATTRIBUTE_UNUSED, bool incomingMigration) { int ret =3D -1; @@ -863,7 +863,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, incomingMigration))) goto cleanup; =20 - if (qemuExtDeviceLogCommand(logCtxt, cmd, "TPM Emulator") < 0) + if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0) goto cleanup; =20 virCommandSetErrorBuffer(cmd, &errbuf); --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list