From nobody Sat Apr 27 00:39:18 2024 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=1567691307; cv=none; d=zoho.com; s=zohoarc; b=YfLR1uy4N5wmONiJLlk2WdjRt3H6x0ymkkQ+aqfdJi+OewwRB909ZvdQUcHyFXUOlHot+hO68Ocd4MWlbcUm1F8P+zH/rGrk6JVx9KIHkK3gsrpjcFPfYZ+k9bGuyadXIfhnF/zPzizziy/N7b0vrBq/qpRST+8WAaFnf77vfxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567691307; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=8U6HH5iwAPoeeqe1uTV+n2sY7gyuVBKYMkSP9EUrn9k=; b=oIr4AV8uYYJOMC9nsqeRKaVDvPbrQuQqaU20gS8d+GwEcgnbYpk4kXi0WoaPDo8MuLx3Dk2zRiK+emmB2oCs2It0vD4UPztJkMgLigEn4h5Oj3J9D7xithazF+UapxrTIKS1Z4grAT4WcuLHyxF/SxdQcbBbvC3z7yNGZ5fpq4k= 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 1567691307301277.30467994271237; Thu, 5 Sep 2019 06:48:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03D3710576CE; Thu, 5 Sep 2019 13:48:26 +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 AE52D5EE1D; Thu, 5 Sep 2019 13:48:25 +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 5C1E54A486; Thu, 5 Sep 2019 13:48:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x85DmNhn004980 for ; Thu, 5 Sep 2019 09:48:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id E437D5E1B7; Thu, 5 Sep 2019 13:48:23 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B723F5C8BA for ; Thu, 5 Sep 2019 13:48:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id E1DAB100EC8; Thu, 5 Sep 2019 15:48:12 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 5 Sep 2019 15:48:10 +0200 Message-Id: <77147339e1ae801b7e62e8b83d51f13681fa137b.1567691290.git.jdenemar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Fix qemuDomainObjTaint with virtlogd 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Thu, 05 Sep 2019 13:48:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When virtlogd is used to capture QEMU's stdout, qemuDomainObjTaint would always fail to write the message to the log file when QEMU is already running (i.e., outside qemuProcessLaunch). This can happen during device hotplug or by sending a custom QEMU guest agent command: warning : qemuDomainObjTaint:8757 : Domain id=3D9 name=3D'blaf' uuid=3D9cfa4e37-2930-405b-bcb4-faac1829dad8 is tainted: custom-ga-command error : virLogHandlerDomainOpenLogFile:388 : Cannot open log file: '/var/log/libvirt/qemu/blaf.log': Device or resource busy error : virNetClientProgramDispatchError:172 : Cannot open log file: '/var/log/libvirt/qemu/blaf.log': Device or resource busy The fix is easy, we just need to use the right API for appending a message to QEMU log file instead of creating a new log context. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c7eb0b5e9a..709e4e568b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8783,9 +8783,9 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, qemuDomainLogContextPtr logCtxt) { virErrorPtr orig_err =3D NULL; - bool closeLog =3D false; char *timestamp =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; + int rc; =20 if (!virDomainObjTaint(obj, taint)) return; @@ -8806,27 +8806,25 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, if (!(timestamp =3D virTimeStringNow())) goto cleanup; =20 - if (logCtxt =3D=3D NULL) { - logCtxt =3D qemuDomainLogContextNew(driver, obj, - QEMU_DOMAIN_LOG_CONTEXT_MODE_ATT= ACH); - if (!logCtxt) { - VIR_WARN("Unable to open domainlog"); - goto cleanup; - } - closeLog =3D true; + if (logCtxt) { + rc =3D qemuDomainLogContextWrite(logCtxt, + "%s: Domain id=3D%d is tainted: %s\= n", + timestamp, + obj->def->id, + virDomainTaintTypeToString(taint)); + } else { + rc =3D qemuDomainLogAppendMessage(driver, obj, + "%s: Domain id=3D%d is tainted: %s= \n", + timestamp, + obj->def->id, + virDomainTaintTypeToString(taint)); } =20 - if (qemuDomainLogContextWrite(logCtxt, - "%s: Domain id=3D%d is tainted: %s\n", - timestamp, - obj->def->id, - virDomainTaintTypeToString(taint)) < 0) + if (rc < 0) virResetLastError(); =20 cleanup: VIR_FREE(timestamp); - if (closeLog) - virObjectUnref(logCtxt); if (orig_err) { virSetError(orig_err); virFreeError(orig_err); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list