From nobody Sun Feb 8 09:27:26 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 1550567149677347.82260932857344; Tue, 19 Feb 2019 01:05:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F183181138; Tue, 19 Feb 2019 09:05:46 +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 C299D61B6B; Tue, 19 Feb 2019 09:05:46 +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 7D964181A13B; Tue, 19 Feb 2019 09:05:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1J95FIq016191 for ; Tue, 19 Feb 2019 04:05:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id EA4C0101E5B1; 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 94E3E104811E for ; Tue, 19 Feb 2019 09:05:12 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 5C382100107; Tue, 19 Feb 2019 10:05:09 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 10:04:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/20] 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Feb 2019 09:05:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Chris Venteicher 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 Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 7: - no change src/qemu/qemu_capabilities.c | 19 +++++++++++++++---- src/qemu/qemu_process.c | 9 +++++---- src/qemu/qemu_process.h | 7 ++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f578d4a5ae..6716e62e4a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4362,14 +4362,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; @@ -4379,14 +4380,22 @@ 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 @@ -4394,7 +4403,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 4ae2067782..6c0f7165c7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8344,7 +8344,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 @@ -8357,6 +8358,7 @@ qemuProcessQMPNew(const char *binary, 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" @@ -8395,15 +8397,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 c59379facb..46a0bd2475 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 proc, - bool forceTCG); +int qemuProcessQMPRun(qemuProcessQMPPtr proc); =20 void qemuProcessQMPStop(qemuProcessQMPPtr proc); =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list