From nobody Sun Feb 8 22:18:39 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 1550567142387190.4966281850792; Tue, 19 Feb 2019 01:05:42 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFA6FAB423; Tue, 19 Feb 2019 09:05:38 +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 6BCE85ED46; Tue, 19 Feb 2019 09:05:38 +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 289C43FB13; Tue, 19 Feb 2019 09:05:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1J95FLZ016176 for ; Tue, 19 Feb 2019 04:05:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id B059C19C5B; Tue, 19 Feb 2019 09:05:15 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CB2719C5A for ; Tue, 19 Feb 2019 09:05:15 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 65D5510010D; Tue, 19 Feb 2019 10:05:09 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 10:04:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/20] qemu_process: Hide qmperr inside qemuProcessQMP 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Feb 2019 09:05:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Keep the pointer to QEMU stderr output in qemuProcessQMP struct instead of requiring the caller to provide it (and free it). Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 7: - this is a combination of the relevant parts of [PATCH 09/33] qemu_process: Expose process exit status code and [PATCH 10/33] qemu_process: Persist stderr in qemuProcessQMP struct adapted to the changes made in the previous patches src/qemu/qemu_capabilities.c | 14 +++++--------- src/qemu/qemu_process.c | 9 +++------ src/qemu/qemu_process.h | 3 +-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 264dcae983..7460b452a0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4376,14 +4376,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool onlyTCG) { qemuProcessQMPPtr proc =3D NULL; int ret =3D -1; =20 if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr, onlyTCG))) + runUid, runGid, onlyTCG))) goto cleanup; =20 if (qemuProcessQMPRun(proc) < 0) @@ -4408,10 +4407,9 @@ static int virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, const char *libDir, uid_t runUid, - gid_t runGid, - char **qmperr) + gid_t runGid) { - if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, qmperr,= false) < 0) + if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, false) = < 0) return -1; =20 /* @@ -4420,7 +4418,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, * off. */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && - virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, NULL, t= rue) < 0) + virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true) <= 0) return -1; =20 return 0; @@ -4438,7 +4436,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, { virQEMUCapsPtr qemuCaps; struct stat sb; - char *qmperr =3D NULL; =20 if (!(qemuCaps =3D virQEMUCapsNew())) goto error; @@ -4465,7 +4462,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, goto error; } =20 - if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr) < 0) + if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid) < 0) goto error; =20 qemuCaps->libvirtCtime =3D virGetSelfLastChanged(); @@ -4484,7 +4481,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, } =20 cleanup: - VIR_FREE(qmperr); return qemuCaps; =20 error: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 728176bbdf..d2859da2ec 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8335,6 +8335,7 @@ qemuProcessQMPFree(qemuProcessQMPPtr proc) VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); VIR_FREE(proc->pidfile); + VIR_FREE(proc->stderr); VIR_FREE(proc); } =20 @@ -8344,7 +8345,6 @@ qemuProcessQMPNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool forceTCG) { qemuProcessQMPPtr proc =3D NULL; @@ -8357,7 +8357,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 @@ -8439,7 +8438,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 if (virCommandRun(proc->cmd, &status) < 0) goto cleanup; @@ -8449,7 +8448,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to start QEMU binary %s for probing: %s"), proc->binary, - *proc->qmperr ? *proc->qmperr : _("unknown error")); + proc->stderr ? proc->stderr : _("unknown error")); goto cleanup; } =20 @@ -8513,8 +8512,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 46a0bd2475..e7d4ca0c92 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -220,7 +220,7 @@ struct _qemuProcessQMP { char *binary; uid_t runUid; gid_t runGid; - char **qmperr; + char *stderr; char *monarg; char *monpath; char *pidfile; @@ -236,7 +236,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.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list