From nobody Tue Apr 30 05:13:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592229423; cv=none; d=zohomail.com; s=zohoarc; b=BtDNq3cBY0srZgkIvit07y0YMy8j59DXxjk5fRd8oHnuld2RpnqfH2xv3+POQtt2FZtY8k8bL8z/yVxy0b4I9byKP4YA2b0LufJBsL80SvbBH1HzGMlfYslMUpawbF3FjmlU56Xor1PXxsutmKi7RJbpCw1ZeNfqHlc/uQY7Wn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592229423; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Ts9fhL4lX7nfyjoG89Ap+sy6HsZBPso7hH1rHzsfUJQ=; b=QJhcMFonYaN7hkktGcZlSsjlja6XqHm3xv5A4SjPhhGY0KJEcpRTzq52UZ9R0F2t+KYNFr/kSYFSRZUXfOMMxMoRDRTOYBh1TKwoOotahjfuZcAJMq4SPolv6N+L3kiZVSRiQIXZVx6yxCQl+p0Pu/Cx+x2T+b8BKLL6Qb8h6no= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1592229423103401.5794687723484; Mon, 15 Jun 2020 06:57:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-Mrnt0KASNwabmfua1eiI_Q-1; Mon, 15 Jun 2020 09:56:59 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49DC710AEA15; Mon, 15 Jun 2020 13:56:53 +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 930EB19C66; Mon, 15 Jun 2020 13:56:51 +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 5D7271809547; Mon, 15 Jun 2020 13:56:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05FDuk78013720 for ; Mon, 15 Jun 2020 09:56:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5629E7CAA7; Mon, 15 Jun 2020 13:56:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.110.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272517CAAE; Mon, 15 Jun 2020 13:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592229421; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ts9fhL4lX7nfyjoG89Ap+sy6HsZBPso7hH1rHzsfUJQ=; b=iwZRnVg1VHykxlCS4Q4as5fKMTlc1qD12MA1+5sMPyCo/gg0tYrkquIjKYXQX5dPA7X41D 57V2SevHAHNhXkAD9gYteXGjAypPws/8/ReFPqwScP65BY/dm2b9qxR8py6+se2/Rwt+no ON2eLgMBAbxRyDVAF8n9OoZTQTwXnjU= X-MC-Unique: Mrnt0KASNwabmfua1eiI_Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: fix missing error reports in capabilities probing Date: Mon, 15 Jun 2020 14:56:41 +0100 Message-Id: <20200615135641.540502-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The "virsh domcapabilities --arch ppc64" command will fail with no error message set if qemu-system-ppc64 is not currently installed. This is because virQEMUCapsCacheLookup() does not report any error message if not capabilities can be obtained from the cache. Almost all methods calling this expected an error to be set on failure. Once that's fixed though, we see a further bug which is that virQEMUCapsCacheLookupDefault() is passing a NULL binary path to virQEMUCapsCacheLookup(), so we need to catch that too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 11 +++++++++++ src/qemu/qemu_domain.c | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index aa90eab229..448d6fa175 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5517,6 +5517,11 @@ virQEMUCapsCacheLookup(virFileCachePtr cache, priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); =20 ret =3D virFileCacheLookup(cache, binary); + if (!ret) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no capabilities available for %s"), binary); + return NULL; + } =20 VIR_DEBUG("Returning caps %p for %s", ret, binary); return ret; @@ -5664,6 +5669,12 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, probedbinary =3D virQEMUCapsGetDefaultEmulator(hostarch, arch); binary =3D probedbinary; } + if (!binary) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unable to find any emulator to serve '%s' archit= ecture"), + archStr); + goto cleanup; + } =20 if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2dad823a86..97096073e6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6068,8 +6068,10 @@ qemuDomainPostParseDataAlloc(const virDomainDef *def, virQEMUDriverPtr driver =3D opaque; =20 if (!(*parseOpaque =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator))) + def->emulator))) { + virResetLastError(); return 1; + } =20 return 0; } --=20 2.26.2