From nobody Mon Feb 9 00:01:09 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 1543813919538442.76495230979367; Sun, 2 Dec 2018 21:11:59 -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 CDBC0C0495B5; Mon, 3 Dec 2018 05:11:57 +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 94DF36B640; Mon, 3 Dec 2018 05:11:57 +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 51B8D181B9E4; Mon, 3 Dec 2018 05:11:57 +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 wB35BtbV031953 for ; Mon, 3 Dec 2018 00:11:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id EB9D3171B0; Mon, 3 Dec 2018 05:11:55 +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 F2D8B6149F; Mon, 3 Dec 2018 05:11:52 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sun, 2 Dec 2018 23:10:09 -0600 Message-Id: <20181203051030.22126-16-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 15/36] qemu_process: Don't open monitor if process failed 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 03 Dec 2018 05:11:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Gracefully handle case when proc activation failed prior to calling. Consistent with the existing code for qemuConnectMonitor (for domains) in qemu_process.c... - Handle qemMonitorOpen failure with INFO message and NULL ptr - Identify parameters passed to qemuMonitorOpen Monitor callbacks will be removed in future patch so we prep for passing NULL for the callback pointer. Set proc->mon to NULL then use VIR_STEAL_PTR if successful to be consistent with other functions. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8906a22e3c..31d41688fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8262,25 +8262,50 @@ static int qemuProcessQmpConnectMonitor(qemuProcessQmpPtr proc) { int ret =3D -1; + qemuMonitorPtr mon =3D NULL; + unsigned long long timeout =3D 0; + bool retry =3D true; + bool enableJson =3D true; + virQEMUDriverPtr driver =3D NULL; + qemuMonitorCallbacksPtr monCallbacks =3D &callbacks; virDomainXMLOptionPtr xmlopt =3D NULL; virDomainChrSourceDef monConfig; =20 VIR_DEBUG("proc=3D%p, emulator=3D%s, proc->pid=3D%lld", proc, NULLSTR(proc->binary), (long long)proc->pid); =20 + if (!proc || !proc->pid) { + ret =3D 0; + goto cleanup; + } + + proc->mon =3D NULL; + monConfig.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; monConfig.data.nix.path =3D proc->monpath; monConfig.data.nix.listen =3D false; =20 + /* Create a NULL Domain object for qemuMonitor */ if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || !(proc->vm =3D virDomainObjNew(xmlopt))) goto cleanup; =20 proc->vm->pid =3D proc->pid; =20 - if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &monConfig, true, true, - 0, &callbacks, NULL))) + mon =3D qemuMonitorOpen(proc->vm, + &monConfig, + enableJson, + retry, + timeout, + monCallbacks, + driver); + + if (!mon) { + VIR_INFO("Failed to connect monitor to emulator %s", proc->binary); goto cleanup; + } + + VIR_STEAL_PTR(proc->mon, mon); =20 virObjectLock(proc->mon); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list