From nobody Mon Feb 9 03:00:17 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 1550567163769968.6487668697005; Tue, 19 Feb 2019 01:06:03 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6DE08E693; Tue, 19 Feb 2019 09:05:59 +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 5B3F7600C8; Tue, 19 Feb 2019 09:05:59 +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 0F4CB181A266; Tue, 19 Feb 2019 09:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1J95GPm016213 for ; Tue, 19 Feb 2019 04:05:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 982535D6AA; Tue, 19 Feb 2019 09:05:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41E9C5D70E for ; Tue, 19 Feb 2019 09:05:15 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 60E3E10010B; Tue, 19 Feb 2019 10:05:09 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 10:04:52 +0100 Message-Id: <1b8f3f137d3fd88bddd19578c1ae61e4b190d859.1550566126.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/20] qemu_process: Don't ignore errors in virQEMUCapsInit 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 19 Feb 2019 09:06:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" While qemuProcessQMPRun and virQEMUCapsInitQMPMonitor* functions called from virQEMUCapsInit ignore some errors, the caller of virQEMUCapsInit would report an error unless usedQMP is true anyway. And since usedQMP can only be true if the probing code really succeeded (i.e., no errors were ignored), we can just simplify the logic by not ignoring the errors in the first place. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 7: - this is a rewritten version of [PATCH 08/33] qemu_process: All ProcessQMP errors are fatal from version 6 src/qemu/qemu_capabilities.c | 17 +---------------- src/qemu/qemu_process.c | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b695b23fcc..bb1920146e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4152,7 +4152,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, if (qemuMonitorSetCapabilities(mon) < 0) { VIR_DEBUG("Failed to set monitor capabilities %s", virGetLastErrorMessage()); - ret =3D 0; goto cleanup; } =20 @@ -4161,7 +4160,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, &package) < 0) { VIR_DEBUG("Failed to query monitor version %s", virGetLastErrorMessage()); - ret =3D 0; goto cleanup; } =20 @@ -4338,7 +4336,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps = ATTRIBUTE_UNUSED, if (qemuMonitorSetCapabilities(mon) < 0) { VIR_DEBUG("Failed to set monitor capabilities %s", virGetLastErrorMessage()); - ret =3D 0; goto cleanup; } =20 @@ -4364,17 +4361,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps, { qemuProcessQMPPtr proc =3D NULL; int ret =3D -1; - int rc; =20 if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, runUid, runGid, qmperr, onlyTCG))) goto cleanup; =20 - if ((rc =3D qemuProcessQMPRun(proc)) !=3D 0) { - if (rc =3D=3D 1) - ret =3D 0; + if (qemuProcessQMPRun(proc) < 0) goto cleanup; - } =20 if (onlyTCG) ret =3D virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon); @@ -4474,14 +4467,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, goto error; } =20 - if (!qemuCaps->usedQMP) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to probe QEMU binary with QMP: %s"), - qmperr ? qmperr : _("unknown error")); - virQEMUCapsLogProbeFailure(binary); - goto error; - } - qemuCaps->libvirtCtime =3D virGetSelfLastChanged(); qemuCaps->libvirtVersion =3D LIBVIR_VERSION_NUMBER; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6c0f7165c7..728176bbdf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8392,10 +8392,6 @@ qemuProcessQMPNew(const char *binary, } =20 =20 -/* Returns -1 on fatal error, - * 0 on success, - * 1 when probing QEMU failed - */ int qemuProcessQMPRun(qemuProcessQMPPtr proc) { @@ -8403,6 +8399,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) const char *machine; int status =3D 0; int ret =3D -1; + int rc; =20 if (proc->forceTCG) machine =3D "none,accel=3Dtcg"; @@ -8444,19 +8441,21 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) =20 virCommandSetErrorBuffer(proc->cmd, proc->qmperr); =20 - /* Log, but otherwise ignore, non-zero status. */ if (virCommandRun(proc->cmd, &status) < 0) goto cleanup; =20 if (status !=3D 0) { - VIR_DEBUG("QEMU %s exited with status %d: %s", - proc->binary, status, *proc->qmperr); - goto ignore; + VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to start QEMU binary %s for probing: %s"), + proc->binary, + *proc->qmperr ? *proc->qmperr : _("unknown error")); + goto cleanup; } =20 - if (virPidFileReadPath(proc->pidfile, &proc->pid) < 0) { - VIR_DEBUG("Failed to read pidfile %s", proc->pidfile); - goto ignore; + if ((rc =3D virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) { + virReportSystemError(-rc, _("Failed to read pidfile %s"), proc->pi= dfile); + goto cleanup; } =20 if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || @@ -8467,7 +8466,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) =20 if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, 0, &callbacks, NULL))) - goto ignore; + goto cleanup; =20 virObjectLock(proc->mon); =20 @@ -8479,10 +8478,6 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) virObjectUnref(xmlopt); =20 return ret; - - ignore: - ret =3D 1; - goto cleanup; } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list