From nobody Sun Feb 8 20:00:02 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 1543813886642253.97266761349238; Sun, 2 Dec 2018 21:11:26 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE9513082A2A; Mon, 3 Dec 2018 05:11:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B48619C7C; Mon, 3 Dec 2018 05:11:24 +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 3B157181B9F6; Mon, 3 Dec 2018 05:11: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 wB35BMC3031672 for ; Mon, 3 Dec 2018 00:11:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id C1AFA5C23C; Mon, 3 Dec 2018 05:11:22 +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 4E91B5C232; Mon, 3 Dec 2018 05:11:17 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sun, 2 Dec 2018 23:10:01 -0600 Message-Id: <20181203051030.22126-8-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 07/36] qemu_process: Use qemuProcessQmp struct for a single process 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 03 Dec 2018 05:11:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In new process code, move from model where qemuProcessQmp struct can be used to activate a series of Qemu processes to model where one qemuProcessQmp struct is used for one and only one Qemu process. By allowing only one process activation per qemuProcessQmp struct, the struct can safely store process outputs like status and stderr, without being overwritten, until qemuProcessQmpFree is called. By doing this, process outputs like status and stderr can remain stored in the qemuProcessQmp struct without being overwritten by subsequent process activations. The forceTCG parameter (use / don't use KVM) will be passed when the qemuProcessQmp struct is initialized since the qemuProcessQmp struct won't be reused. Signed-off-by: Chris Venteicher Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 20 ++++++++++++++++---- src/qemu/qemu_process.c | 10 ++++++---- src/qemu/qemu_process.h | 7 ++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a79329a134..bed9ca26a1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4242,14 +4242,15 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, char **qmperr) { qemuProcessQmpPtr proc =3D NULL; + qemuProcessQmpPtr procTCG =3D NULL; int ret =3D -1; int rc; =20 if (!(proc =3D qemuProcessQmpNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr))) + runUid, runGid, qmperr, false))) goto cleanup; =20 - if ((rc =3D qemuProcessQmpRun(proc, false)) !=3D 0) { + if ((rc =3D qemuProcessQmpRun(proc)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; @@ -4259,14 +4260,23 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { + + /* The second QEMU process probes for TCG capabilities + * in case the first process reported KVM as enabled + * (otherwise the first one already reported TCG capabilities). */ + qemuProcessQmpStop(proc); - if ((rc =3D qemuProcessQmpRun(proc, true)) !=3D 0) { + + procTCG =3D qemuProcessQmpNew(qemuCaps->binary, libDir, + runUid, runGid, NULL, true); + + if ((rc =3D qemuProcessQmpRun(procTCG)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0) + if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, procTCG->mon) < 0) goto cleanup; } =20 @@ -4274,7 +4284,9 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, =20 cleanup: qemuProcessQmpStop(proc); + qemuProcessQmpStop(procTCG); qemuProcessQmpFree(proc); + qemuProcessQmpFree(procTCG); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fa050a1a27..324151a7c3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8127,7 +8127,8 @@ qemuProcessQmpNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr) + char **qmperr, + bool forceTCG) { qemuProcessQmpPtr proc =3D NULL; =20 @@ -8137,9 +8138,11 @@ qemuProcessQmpNew(const char *binary, if (VIR_STRDUP(proc->binary, binary) < 0) goto error; =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 * domain called "capabilities" @@ -8178,15 +8181,14 @@ qemuProcessQmpNew(const char *binary, * 1 when probing QEMU failed */ int -qemuProcessQmpRun(qemuProcessQmpPtr proc, - bool forceTCG) +qemuProcessQmpRun(qemuProcessQmpPtr proc) { virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; int status =3D 0; int ret =3D -1; =20 - if (forceTCG) + if (proc->forceTCG) machine =3D "none,accel=3Dtcg"; else machine =3D "none,accel=3Dkvm:tcg"; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 9a72db9a08..51598b402e 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -229,18 +229,19 @@ struct _qemuProcessQmp { virDomainChrSourceDef config; pid_t pid; virDomainObjPtr vm; + bool forceTCG; }; =20 qemuProcessQmpPtr qemuProcessQmpNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr); + char **qmperr, + bool forceTCG); =20 void qemuProcessQmpFree(qemuProcessQmpPtr proc); =20 -int qemuProcessQmpRun(qemuProcessQmpPtr cmd, - bool forceTCG); +int qemuProcessQmpRun(qemuProcessQmpPtr cmd); =20 void qemuProcessQmpStop(qemuProcessQmpPtr proc); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list