From nobody Mon Feb 9 01:21:01 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=1642787798; cv=none; d=zohomail.com; s=zohoarc; b=SjWc3/w8e/Vtlb522FmusboElXzUb8C8g0tswT7SHiYE00uIBfeegGv2rYOzmiFFZX2wvJNJ5I/46wfexHi2YQyCotlY7EMO3VnIm21u0UJOg4KmEa4rWU//Atm/K5Upy/QzDyzpcCzaUXE9wj96fdD5djxAqcKSiyexz/lha90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642787798; 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=n5Pzdyu4ozj5DlrxkhV3/LrQE1zN+IlWdFuaeSxBL8Q=; b=fjdAR7rGgag076qIPXyqop0GGzQ1mrzEugxM6L1Ml9DgknIpFCb0RXMYl0sKPTHT0pXQ9et8C0DGG2qXJEvLdYVUfJB7o9PAYSQaw08sYDWW/HuI2cse0uTpymmumm/eSmdE79RWB5euHnr+OjdiaZi6xK3scGgCxU1JCkA6f5Y= 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 1642787798957740.413016527225; Fri, 21 Jan 2022 09:56:38 -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-283-a3-38VkmPaOEwc3HarZJQg-1; Fri, 21 Jan 2022 12:56:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CF918144E6; Fri, 21 Jan 2022 17:56: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 1CD2177C96; Fri, 21 Jan 2022 17:56:28 +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 E22A71806D2F; Fri, 21 Jan 2022 17:56:27 +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 20LHtIoc005584 for ; Fri, 21 Jan 2022 12:55:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2271384D25; Fri, 21 Jan 2022 17:55:18 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51E1984D19; Fri, 21 Jan 2022 17:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642787798; 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=n5Pzdyu4ozj5DlrxkhV3/LrQE1zN+IlWdFuaeSxBL8Q=; b=bMrBsax4aCUu8Tr4+NX28FQPzKbtMyBO2SQ+Frs71eROL9Wwq/0Wr2TjtylbDi8jk46+pA xK+IB/qbftmwy4nvLJ0k1rwaw+t5ZGSzxA7CapsRGnl1etlXST6ebh+ScwhFFyH/DXi/Pq gKWD+ruIk88ejwvJ6vGD+Og51GrL93M= X-MC-Unique: a3-38VkmPaOEwc3HarZJQg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v7 05/18] qemu: Query hvf capability on macOS Date: Fri, 21 Jan 2022 18:54:45 +0100 Message-Id: <20220121175458.162675-6-abologna@redhat.com> In-Reply-To: <20220121175458.162675-1-abologna@redhat.com> References: <20220121175458.162675-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642787799941100001 From: Roman Bolshakov There's no QMP command for querying if hvf is supported, therefore we use sysctl interface that tells if Hypervisor.framework works/available on the host. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Tested-by: Brad Laue Tested-by: Christophe Fergeau Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 994dc3dad2..d01be3e892 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -56,6 +56,10 @@ #include #include #include +#ifdef __APPLE__ +# include +# include +#endif =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 @@ -3192,6 +3196,42 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, return 0; } =20 +#ifdef __APPLE__ +static int +virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) +{ + int hv_support =3D 0; + size_t len =3D sizeof(hv_support); + virArch hostArch =3D virArchFromHost(); + + /* 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) + return 0; + + if (hv_support) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); + + return 0; +} +#else +static int +virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps G_GNUC_UNUSED) +{ + return 0; +} +#endif + struct virQEMUCapsCommandLineProps { const char *option; const char *param; @@ -5333,6 +5373,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCaps *qemuCaps, if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) return -1; =20 + if (virQEMUCapsProbeHVF(qemuCaps) < 0) + return -1; + type =3D virQEMUCapsGetVirtType(qemuCaps); accel =3D virQEMUCapsGetAccel(qemuCaps, type); =20 --=20 2.34.1