From nobody Mon May 6 17:42:20 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=1579267837; cv=none; d=zohomail.com; s=zohoarc; b=lZxt4SqXskvuLoOmTs+iTpFEv0y+nAO3HPayizA0AWQpd+Yp4feLI8evRWLISYtqFXWUdwIuyByu4JdzrnGa9vV/lyDCjpeWRb+zqmAVvqI6BBVmTaBtxixd2NGKo2bQGWY2bm5Y2Obdjr7hfDamCHwwtZXKjXLDdWw5Y3kztts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579267837; 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=kA82VYCcm0g4H9pI9GBDKiCRw3b9/XYYXVJENrZegiU=; b=ZFBAwn0KtAtJpFDR+5kQ2GkxRJP1RJXIQGZH1Xs87HE4nBxaiScYIb8O5liHSTKAI5iFNflrQll5qYgPOZR9Jxn4stA6MZzJSD/r3xcSSfNzW0CqrqG9W5szMLNvkkaWuQhRgdCZi/DO5ugcV3X+5svGAZKU8hCT6QFBhm/dPow= 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 1579267837652865.0678274995507; Fri, 17 Jan 2020 05:30:37 -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-382-Lo1dUwmgPaOmNp6-GDLPuw-1; Fri, 17 Jan 2020 08:30:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EBAA184C732; Fri, 17 Jan 2020 13:30:28 +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 1C7015D9CD; Fri, 17 Jan 2020 13:30:27 +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 1B80E1802027; Fri, 17 Jan 2020 13:30:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00HDTjQW008988 for ; Fri, 17 Jan 2020 08:29:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1B59810016EB; Fri, 17 Jan 2020 13:29:45 +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 E27C61001902; Fri, 17 Jan 2020 13:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579267836; 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=kA82VYCcm0g4H9pI9GBDKiCRw3b9/XYYXVJENrZegiU=; b=IOh/afhh+CKK8LjqPTFdj1oILdykuMYlNt7giUKIR+c7lXWdY+Lnqd2oDnS+rOsl8VUiYJ 6Jzr5jDhsXKilAdGx76P0ggl6iJFVLhkWJN9ziJEaO3uBjDYog2sBiWCTX0oOTSQW8hL8t ZokcNU5UGfWxuaEt5tAdCnKuuzqe6vI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: fixing auto-detecting binary in domain capabilities Date: Fri, 17 Jan 2020 13:29:36 +0000 Message-Id: <20200117132936.425483-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.14 X-MC-Unique: Lo1dUwmgPaOmNp6-GDLPuw-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. Signed-off-by: Daniel P. Berrang=C3=A9 Tested-by: Richard W.M. Jones --- src/qemu/qemu_capabilities.c | 42 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 498348ad58..9017e8d920 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5280,10 +5280,12 @@ 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; =20 if (virttypeStr && (virttype =3D virDomainVirtTypeFromString(virttypeStr)) < 0) { @@ -5299,31 +5301,25 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, goto cleanup; } =20 - if (binary) { - virArch arch_from_caps; + if (!binary) + binary =3D virQEMUCapsGetDefaultEmulator(hostarch, arch); =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