From nobody Sun Feb 8 19:40:14 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=1641322505; cv=none; d=zohomail.com; s=zohoarc; b=oDgSpINPqLahSZF6cVnD2dPPIm88xO1QH3kw+JputizPvb4MJPeLwAcRb+9Ip27YKtAprMpMfMHfnabvP0TWrR1P1hOHUkWePbMDZuJbeWhgWVXIk/plNGLzKGOHBINvsviQsDcH9wyqcnSZsH8lLbEsOmKip4UUu85IpSTHm5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641322505; 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=Ak3uh9uAaO7wS9ENfXwycAUALlTfB8wTzTKUviGSK4w=; b=m9w3yzzYkGdhttYTFXRywoJck5oZ/Jf9Famkhepgc7gqzifKwA9qQGjlgfuFRLncRDXIPceuCsIoebN6CX8glPFsk3AcP1mgvQLG+V3rkE51jjgOmtS6K/YE9m9w+CB+uEaDuIjhEUzim9MEEcXlr3xCt2ibfTLlrik91hH/OI0= 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 1641322505546169.00640812589563; Tue, 4 Jan 2022 10:55:05 -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-658-MsvpTxcMPuC7mwY2ybrHNA-1; Tue, 04 Jan 2022 13:53:41 -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 62F2810168DA; Tue, 4 Jan 2022 18:53:33 +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 4395478A33; Tue, 4 Jan 2022 18:53:33 +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 E36791809CBA; Tue, 4 Jan 2022 18:53:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 204IrMwp012626 for ; Tue, 4 Jan 2022 13:53:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id D686938E00; Tue, 4 Jan 2022 18:53:22 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.193.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF83234D4E; Tue, 4 Jan 2022 18:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641322504; 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=Ak3uh9uAaO7wS9ENfXwycAUALlTfB8wTzTKUviGSK4w=; b=ZV+SNs4vmk3UvqcBSITyahvfX3H0Hobt9rKBNd8GQf2X6PcVxNOJsVmrp7r6ktvPb0Pg01 r/sgniSc8xocwV47C5xiR927DJFBsBBRjfpdG0wH5XBzDgNHxynOarPaihBhHP5IpT6oWd Xeq+J7Au9nTrD2nqNeFW8UEMnE2lzV4= X-MC-Unique: MsvpTxcMPuC7mwY2ybrHNA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 03/17] qemu: Query hvf capability on macOS Date: Tue, 4 Jan 2022 19:52:42 +0100 Message-Id: <20220104185256.339072-4-abologna@redhat.com> In-Reply-To: <20220104185256.339072-1-abologna@redhat.com> References: <20220104185256.339072-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641322507718100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7823cb3d48..9b4f695770 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 @@ -3191,6 +3195,32 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, return 0; } =20 +#ifdef __APPLE__ +static int +virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) +{ + int hv_support; + size_t len =3D sizeof(hv_support); + + if (sysctlbyname("kern.hv_support", &hv_support, &len, NULL, 0) < 0) + hv_support =3D 0; + + if (qemuCaps->version >=3D 2012000 && + ARCH_IS_X86(qemuCaps->arch) && + 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; @@ -5335,6 +5365,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.31.1