From nobody Mon Feb 9 13:00:34 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543813898116346.0793780739202; Sun, 2 Dec 2018 21:11:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43B00C0587CE; Mon, 3 Dec 2018 05:11:36 +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 090A560151; Mon, 3 Dec 2018 05:11:36 +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 B7ABE3F604; Mon, 3 Dec 2018 05:11:35 +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 wB35BX0A031740 for ; Mon, 3 Dec 2018 00:11:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 721765C25D; Mon, 3 Dec 2018 05:11:33 +0000 (UTC) Received: from cv1.redhat.com (ovpn-120-56.rdu2.redhat.com [10.10.120.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id D37025C23C; Mon, 3 Dec 2018 05:11:30 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sun, 2 Dec 2018 23:10:03 -0600 Message-Id: <20181203051030.22126-10-cventeic@redhat.com> In-Reply-To: <20181203051030.22126-1-cventeic@redhat.com> References: <20181203051030.22126-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, walling@linux.ibm.com, Chris Venteicher , jdenemar@redhat.com, david@redhat.com Subject: [libvirt] [PATCH v5 09/36] qemu_process: Persist stderr in qemuProcessQmp struct 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 03 Dec 2018 05:11:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A qemuProcessQmp struct tracks the entire lifespan of a single QEMU Process including storing error output when the process terminates or activation fails. Error output remains available until qemuProcessQmpFree is called. The qmperr variable is renamed stderr (captures stderr from process.) The stderr buffer no longer needs to be maintained outside of the qemuProcessQmp structure because the structure is used for a single QEMU process and the structures can be maintained as long as required to retrieve the process error info. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 8 +++----- src/qemu/qemu_process.c | 9 +++------ src/qemu/qemu_process.h | 3 +-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 1efec85b57..997f8c19d5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4259,18 +4259,17 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, { qemuProcessQmpPtr proc =3D NULL; qemuProcessQmpPtr procTCG =3D NULL; - char *qmperr =3D NULL; int ret =3D -1; =20 if (!(proc =3D qemuProcessQmpNew(qemuCaps->binary, libDir, - runUid, runGid, &qmperr, false))) + runUid, runGid, false))) goto cleanup; =20 if (qemuProcessQmpRun(proc) < 0) { if (proc->status !=3D 0) virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to probe QEMU binary with QMP: %s"), - qmperr ? qmperr : _("uknown error")); + proc->stderr ? proc->stderr : _("uknown error")= ); =20 goto cleanup; } @@ -4287,7 +4286,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, qemuProcessQmpStop(proc); =20 procTCG =3D qemuProcessQmpNew(qemuCaps->binary, libDir, - runUid, runGid, NULL, true); + runUid, runGid, true); =20 if (qemuProcessQmpRun(procTCG) < 0) goto cleanup; @@ -4306,7 +4305,6 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, qemuProcessQmpStop(procTCG); qemuProcessQmpFree(proc); qemuProcessQmpFree(procTCG); - VIR_FREE(qmperr); =20 return ret; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2ec0d5340d..8ad685f3ea 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8118,6 +8118,7 @@ qemuProcessQmpFree(qemuProcessQmpPtr proc) VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); VIR_FREE(proc->pidfile); + VIR_FREE(proc->stderr); VIR_FREE(proc); } =20 @@ -8127,7 +8128,6 @@ qemuProcessQmpNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool forceTCG) { qemuProcessQmpPtr proc =3D NULL; @@ -8141,7 +8141,6 @@ qemuProcessQmpNew(const char *binary, =20 proc->runUid =3D runUid; proc->runGid =3D runGid; - proc->qmperr =3D qmperr; proc->forceTCG =3D forceTCG; =20 /* the ".sock" sufix is important to avoid a possible clash with a qemu @@ -8213,7 +8212,7 @@ qemuProcessQmpRun(qemuProcessQmpPtr proc) virCommandSetGID(proc->cmd, proc->runGid); virCommandSetUID(proc->cmd, proc->runUid); =20 - virCommandSetErrorBuffer(proc->cmd, proc->qmperr); + virCommandSetErrorBuffer(proc->cmd, &(proc->stderr)); =20 proc->status =3D 0; =20 @@ -8222,7 +8221,7 @@ qemuProcessQmpRun(qemuProcessQmpPtr proc) =20 if (proc->status !=3D 0) { VIR_DEBUG("QEMU %s exited with status %d: %s", - proc->binary, proc->status, *proc->qmperr); + proc->binary, proc->status, proc->stderr); goto cleanup; } =20 @@ -8283,8 +8282,6 @@ qemuProcessQmpStop(qemuProcessQmpPtr proc) (long long)proc->pid, virStrerror(errno, ebuf, sizeof(ebuf))); =20 - VIR_FREE(*proc->qmperr); - proc->pid =3D 0; } =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index a56e9608cd..3ddfa82918 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -221,7 +221,7 @@ struct _qemuProcessQmp { uid_t runUid; gid_t runGid; int status; - char **qmperr; + char *stderr; char *monarg; char *monpath; char *pidfile; @@ -237,7 +237,6 @@ qemuProcessQmpPtr qemuProcessQmpNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool forceTCG); =20 void qemuProcessQmpFree(qemuProcessQmpPtr proc); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list