From nobody Fri Dec 19 18:46:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1679064771; cv=none; d=zohomail.com; s=zohoarc; b=P7dclCpYAPxrSms4FNPe/xo642cWKfhA+FZ42MjYsnVJIcpxuQL4wDGCZiQJhnzLVBgyizFm3E8uM72jooPaQyLX0ATZhYxD8AvSqVrkE4uz3IYNzK3rllBLm7SceD1PUHDiA+DGkAXM24uQzF8dxX6u4V0V+NUg3nJxqegBBp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679064771; h=Content-Type:Content-Transfer-Encoding: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=0780MY+Y7s7/rvuCTAq4au+J/g9Q0+MWFrIUxrbRsko=; b=ea2KD377+6OokcClQOiIBFZGzbKyJRdPJLm8XCGzCkwVZ6XT8wSCkvEqUg4mi2G/fsoI3caT7XzthzHIjHG6zrcWjQ6kIbnGZLPgtzHX/MoaguEVsbMckb+Oc9Pl7/Xk34XWIT+RxM40KWbWGn7b2t9kw4SVFdGLzmUcCSZ1xJc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1679064771559377.22280053249426; Fri, 17 Mar 2023 07:52:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-533-NcZJL-8FPy2SRSiOyQCnJA-1; Fri, 17 Mar 2023 10:52:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7637E857FB3; Fri, 17 Mar 2023 14:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60A2F2166B2B; Fri, 17 Mar 2023 14:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 380551946A46; Fri, 17 Mar 2023 14:52:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8B8611946587 for ; Thu, 16 Mar 2023 16:12:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7DF212166B29; Thu, 16 Mar 2023 16:12:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3817C2166B26 for ; Thu, 16 Mar 2023 16:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679064770; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0780MY+Y7s7/rvuCTAq4au+J/g9Q0+MWFrIUxrbRsko=; b=TT7gncHlsW2D7r5m2Z27KzA8L6JTA6epyYxsWiiSvQwSKjeyJ5hYQMFTFEf+rarKA9E18v k1Y/HhTo0B1p8xWpo+cNh6zos27yWAvWMRx8wI3wiuS/VDj/sThKTS/tDs5GGgw1JuPnDi ilc+dA6nC1dpX8eJFFX8uNWoHF71w+c= X-MC-Unique: NcZJL-8FPy2SRSiOyQCnJA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/24] virQEMUCapsProbeHVF: Factor out setting of the capability Date: Thu, 16 Mar 2023 17:11:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1679064772852100001 Content-Type: text/plain; charset="utf-8" Separate the architecture specific code to probe the support for HVF from the actual setting of the capability. In upcoming patches 'virQEMUCapsProbeHVF' will be mocked in the testsuite to provide testing for the HVF hypervisor. Signed-off-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 19 ++++++++----------- src/qemu/qemu_capabilities.h | 3 ++- tests/domaincapsmock.c | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9a310a0f2d..f37a81bfe7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3339,7 +3339,7 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, } #ifdef __APPLE__ -int +bool virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) { int hv_support =3D 0; @@ -3349,22 +3349,19 @@ virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) /* Guest and host arch need to match for hardware acceleration * to be usable */ if (qemuCaps->arch !=3D hostArch) - return 0; + return false; /* 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 false; - return 0; + return !!hv_support; } #else -int +bool virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps G_GNUC_UNUSED) { - return 0; + return false; } #endif @@ -5629,8 +5626,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCaps *qemuCaps, if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) return -1; - if (virQEMUCapsProbeHVF(qemuCaps) < 0) - return -1; + if (virQEMUCapsProbeHVF(qemuCaps)) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); type =3D virQEMUCapsGetVirtType(qemuCaps); accel =3D virQEMUCapsGetAccel(qemuCaps, type); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c4f1708639..15f0df5317 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -887,7 +887,8 @@ virQEMUCapsGetSGXCapabilities(virQEMUCaps *qemuCaps); bool virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps) G_NO_INLINE; -int virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) G_NO_INLINE; +bool +virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) G_NO_INLINE; virArch virQEMUCapsArchFromString(const char *arch); const char *virQEMUCapsArchToString(virArch arch); diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index 4d53e48c48..8f27eeb3a1 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -52,10 +52,10 @@ virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuC= aps) return real_virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps); } -int +bool virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps G_GNUC_UNUSED) { - return 0; + return false; } #endif --=20 2.39.2