From nobody Sun Feb 8 19:54:58 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 1543813882676503.68159432339394; Sun, 2 Dec 2018 21:11:22 -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 931D5307D845; Mon, 3 Dec 2018 05:11:19 +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 602B819C7C; Mon, 3 Dec 2018 05:11:19 +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 190EF181B9E1; Mon, 3 Dec 2018 05:11:19 +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 wB35BHlR031270 for ; Mon, 3 Dec 2018 00:11:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 91FA25C23F; Mon, 3 Dec 2018 05:11:17 +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 41EB05C232; Mon, 3 Dec 2018 05:10:59 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sun, 2 Dec 2018 23:10:00 -0600 Message-Id: <20181203051030.22126-7-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 06/36] qemu_capabilities: Stop QEMU process before freeing 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.48]); Mon, 03 Dec 2018 05:11:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virQEMUCapsInitQMP now stops QEMU process in all execution paths, before freeing the process structure. The qemuProcessQmpStop function can be called multiple times without problems... Won't attempt to stop processes and free resources multiple times. Follow the convention established in qemu_process of 1) alloc process structure 2) start process 3) use process 4) stop process 5) free process data structure The process data structure persists after the process activation fails or the process dies or is killed so stderr strings can be retrieved until the process data structure is freed. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_process.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d903fbddf8..a79329a134 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4273,6 +4273,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, ret =3D 0; =20 cleanup: + qemuProcessQmpStop(proc); qemuProcessQmpFree(proc); return ret; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8465448a49..fa050a1a27 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8263,14 +8263,17 @@ qemuProcessQmpRun(qemuProcessQmpPtr proc, void qemuProcessQmpStop(qemuProcessQmpPtr proc) { - if (proc->mon) + if (proc->mon) { virObjectUnlock(proc->mon); - qemuMonitorClose(proc->mon); - proc->mon =3D NULL; + qemuMonitorClose(proc->mon); + proc->mon =3D NULL; + } =20 - virCommandAbort(proc->cmd); - virCommandFree(proc->cmd); - proc->cmd =3D NULL; + if (proc->cmd) { + virCommandAbort(proc->cmd); + virCommandFree(proc->cmd); + proc->cmd =3D NULL; + } =20 if (proc->monpath) unlink(proc->monpath); @@ -8287,8 +8290,10 @@ qemuProcessQmpStop(qemuProcessQmpPtr proc) virStrerror(errno, ebuf, sizeof(ebuf))); =20 VIR_FREE(*proc->qmperr); + + proc->pid =3D 0; } + if (proc->pidfile) unlink(proc->pidfile); - proc->pid =3D 0; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list