From nobody Tue Feb 10 12:45:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1642416972; cv=none; d=zohomail.com; s=zohoarc; b=dA/21HhEINzkx4Jv1v2SgFsp+K5GEri7eV9BftERyaks5SyJ8BqdTY4rCxCGIgl5A/z5idaeLVXG95bxIJrGheuZd5OWOBELlT9Mp2AxK0wk7Tdhg6FPOsFbFm+2+ch1poUkUWe+0JcJ4BeKvltr7/Je8Nc9b49rsLF2LP0aIpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642416972; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k7Lrgwdqwu0Prk2eJb2C3ZO2iZw/C5/ZB7YZXo8gq0s=; b=MPwAqnSDlchiEGgAP8jszXoMoM3FLD8NVklbgHuUq6PMGKGknI6rKxh0mwqTnwg6+QgNkM9LjTdvnigtAOeSfESZ1XFvqxv6aNyEpsUokZju2XJeht8N0e7+Ft/aG3jS8ym5A97EDryH8/PLYxl3qfFnsOiAdtFGWOnQoV1NAWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1642416972158921.0777392646605; Mon, 17 Jan 2022 02:56:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-lGzEzRxJNHWCw_wvWf92vQ-1; Mon, 17 Jan 2022 05:56:09 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F3D61966320; Mon, 17 Jan 2022 10:56:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F265A70D4C; Mon, 17 Jan 2022 10:56:03 +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 BF51E4A706; Mon, 17 Jan 2022 10:56:03 +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 20HArASN009029 for ; Mon, 17 Jan 2022 05:53:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id DCB431059A79; Mon, 17 Jan 2022 10:53:10 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.194.229]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 19AA21059596; Mon, 17 Jan 2022 10:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642416971; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=k7Lrgwdqwu0Prk2eJb2C3ZO2iZw/C5/ZB7YZXo8gq0s=; b=Ta1VLUjRIYy81GMNT3qesbfBMsFO8hhQbpxk7GR6X2gxjKGph6Tn3KizYduuYudr74D0Yh oqjQp7Mmxru0cK50TtxpqGGeBm+5B9ND6xGWeMKjhhEZKSbvT3yN6kWmHJ2fPfvGAOjduP o0UDogO7E3cbqrEZWBFLV1eNRkDXAK0= X-MC-Unique: lGzEzRxJNHWCw_wvWf92vQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 06/20] fixup! qemu: Fix / improve virQEMUCapsProbeHVF() Date: Mon, 17 Jan 2022 11:52:46 +0100 Message-Id: <20220117105300.15759-7-abologna@redhat.com> In-Reply-To: <20220117105300.15759-1-abologna@redhat.com> References: <20220117105300.15759-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: r.bolshakov@yadro.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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642416973497100003 Content-Type: text/plain; charset="utf-8" Fix the architecture check so that hardware acceleration is only ever advertised when the guest and host architecture match; exit early if possible instead of calling sysctl every single time; add some comments. Signed-off-by: Andrea Bolognani Tested-by: Brad Laue --- src/qemu/qemu_capabilities.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 146bbb97f8..f1f1b37678 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3204,17 +3204,27 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, static int virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) { - int hv_support; + int hv_support =3D 0; size_t len =3D sizeof(hv_support); + virArch hostArch =3D virArchFromHost(); =20 + /* Guest and host arch need to match for hardware acceleration + * to be usable */ + if (qemuCaps->arch !=3D hostArch) + return 0; + + /* We don't have a nice way to probe whether the QEMU binary + * contains HVF support, but we know that versions older than + * QEMU 2.12 didn't have the feature at all */ + if (qemuCaps->version < 2012000) + return 0; + + /* We need the OS to report Hypervisor.framework availability */ if (sysctlbyname("kern.hv_support", &hv_support, &len, NULL, 0) < 0) - hv_support =3D 0; + return 0; =20 - if (qemuCaps->version >=3D 2012000 && - ARCH_IS_X86(qemuCaps->arch) && - hv_support) { + if (hv_support) virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); - } =20 return 0; } --=20 2.34.1