From nobody Tue May 7 22:02:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1579285466; cv=none; d=zohomail.com; s=zohoarc; b=fN3o+r70BftJ5mNVW9JXt9b/Ixl0dLFtudP+nSmmlEsajCZeiOOeiwj5OgKdCoQWArr+foNotA7P1bYLQ1IC6oFtIKt7OWrCkbAqFiOs0x2bcy7UZkgPL9Ricrz75uAoTAjWdnzgTaSzLtYUMi0hzW84GGR+sGnvt5hKPwwyF+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579285466; 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=BXaCCQQ/Oa2giqtfISkVSV29VyFALu7kyvP5oKSUlPw=; b=OQ06BisBaZMrVlj0x71hdK+vvIA7FcZ+dwkJF9RC1ECFihK7drdz5tSdqUWPlEpuqNSPUjUDi7qbQOCvr7Rxj0mxIGoaj1e8eFPnM4VuZ+GyHWOGgxIFZxtw9LCEBLx4On1Vo9yzj9S03emrpia7ucVtcIo5YA81y2rfGjttOzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1579285466759387.677508844066; Fri, 17 Jan 2020 10:24:26 -0800 (PST) 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-371-1aE6y_dCOgq1uqYlYZnTgg-1; Fri, 17 Jan 2020 13:24:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68160800D4E; Fri, 17 Jan 2020 18:24:15 +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 7A24D60BE1; Fri, 17 Jan 2020 18:24:13 +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 43D8D18089CD; Fri, 17 Jan 2020 18:24:11 +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 00HIO9ps026992 for ; Fri, 17 Jan 2020 13:24:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA58784324; Fri, 17 Jan 2020 18:24:09 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA566845AA; Fri, 17 Jan 2020 18:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579285465; 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=BXaCCQQ/Oa2giqtfISkVSV29VyFALu7kyvP5oKSUlPw=; b=axdsEgCzP75neUZt5gS7+sSRB+PhBZ1J1G5Ivt7ZvRrHeD9jUN3bVvdKWt72vm0umG1HWT P5k+BOpFybeAR5ImPC2+0sadvxiAbyvXZ5kwUBsWoa6OFGLzUW+ferXftLiPzz2l20CQ6G ilfqDTHRQcr1i5yvtYZ3Xquoabvkqvk= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2] qemu: fixing auto-detecting binary in domain capabilities Date: Fri, 17 Jan 2020 18:24:01 +0000 Message-Id: <20200117182401.547942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.79 on 10.5.11.12 X-MC-Unique: 1aE6y_dCOgq1uqYlYZnTgg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The virConnectGetDomainCapabilities API accepts either a binary path to the emulator, or desired guest arch. If guest arch is not given, then the host arch is assumed. In the case where the binary is not given, the code tried to find the emulator binary in the existing list of cached emulator capabilities. This is not valid since we switched to lazy population of the cache in: commit 3dd91af01f30c5bda6328454ef49f3afece755d6 Author: Daniel P. Berrang=C3=A9 Date: Mon Dec 2 13:04:26 2019 +0000 qemu: stop creating capabilities at driver startup As a result of this change, if there are no persistent guests defined using the requested guest architecture, virConnectGetDomainCapabilities will fail to find an emulator binary. The solution is to stop relying on the cached capabilities to find the binary and instead use the same logic we use to pick default a binary per arch when populating capabilities. Tested-by: Richard W.M. Jones Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik Tested-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 45 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 498348ad58..14c2aa34d2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5280,10 +5280,13 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, const char **retMachine) { int virttype =3D VIR_DOMAIN_VIRT_NONE; - int arch =3D virArchFromHost(); + virArch hostarch =3D virArchFromHost(); + virArch arch =3D hostarch; virDomainVirtType capsType; virQEMUCapsPtr qemuCaps =3D NULL; virQEMUCapsPtr ret =3D NULL; + virArch arch_from_caps; + g_autofree char *probedbinary =3D NULL; =20 if (virttypeStr && (virttype =3D virDomainVirtTypeFromString(virttypeStr)) < 0) { @@ -5299,31 +5302,27 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, goto cleanup; } =20 - if (binary) { - virArch arch_from_caps; + if (!binary) { + probedbinary =3D virQEMUCapsGetDefaultEmulator(hostarch, arch); + binary =3D probedbinary; + } =20 - if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) - goto cleanup; + if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) + goto cleanup; =20 - arch_from_caps =3D virQEMUCapsGetArch(qemuCaps); + arch_from_caps =3D virQEMUCapsGetArch(qemuCaps); =20 - if (arch_from_caps !=3D arch && - !((ARCH_IS_X86(arch) && ARCH_IS_X86(arch_from_caps)) || - (ARCH_IS_PPC(arch) && ARCH_IS_PPC(arch_from_caps)) || - (ARCH_IS_ARM(arch) && ARCH_IS_ARM(arch_from_caps)) || - (ARCH_IS_S390(arch) && ARCH_IS_S390(arch_from_caps)))) { - virReportError(VIR_ERR_INVALID_ARG, - _("architecture from emulator '%s' doesn't " - "match given architecture '%s'"), - virArchToString(arch_from_caps), - virArchToString(arch)); - goto cleanup; - } - } else { - if (!(qemuCaps =3D virQEMUCapsCacheLookupByArch(cache, arch))) - goto cleanup; - - binary =3D virQEMUCapsGetBinary(qemuCaps); + if (arch_from_caps !=3D arch && + !((ARCH_IS_X86(arch) && ARCH_IS_X86(arch_from_caps)) || + (ARCH_IS_PPC(arch) && ARCH_IS_PPC(arch_from_caps)) || + (ARCH_IS_ARM(arch) && ARCH_IS_ARM(arch_from_caps)) || + (ARCH_IS_S390(arch) && ARCH_IS_S390(arch_from_caps)))) { + virReportError(VIR_ERR_INVALID_ARG, + _("architecture from emulator '%s' doesn't " + "match given architecture '%s'"), + virArchToString(arch_from_caps), + virArchToString(arch)); + goto cleanup; } =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) --=20 2.23.0