From nobody Fri Mar 29 12:09:46 2024 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=1641548900; cv=none; d=zohomail.com; s=zohoarc; b=iyoY1FYedIIGMHWagHG3JMjf8FFTD1pay1d5dqWhhy2B8rcjnG3WhqBs9dK6wU+T7XxJlD4jVRwc3Xl8Z5V/Tm1KGWcPLSkKIxzsGD/gs0UauqF/BCzhU7CWJxJVWU+LDZrFNX8gH5d+n+0JWsPba6VeIajU//R4qMtFXElNEcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548900; 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=5r10XZ5XlK5gDku9ZzB7fwso+xqMV/nCtrmpJ+i+DTo=; b=Bc5sj/KJV//H6KhfJhWcwmqWMNufayr9erRpsru2odSYR/YhK8HsX6VVUGZtPON5r0zFEhSo5GLoIwG30rmhtocvVZGRsHOLuDDi+qx0GFl0hGfPEAGz/XNHFrkKMQKGklue8E6qPlYP8UwhgtmMGOHo78NWduzaBfVCvWkTBt4= 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 1641548900189871.1883612069622; Fri, 7 Jan 2022 01:48:20 -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-577-G1XG6kvwNfejmpgH5DyvxA-1; Fri, 07 Jan 2022 04:48:15 -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 18AA31926DA0; Fri, 7 Jan 2022 09:48:10 +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 EDA544EC9D; Fri, 7 Jan 2022 09:48:09 +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 B8A0F1806D2B; Fri, 7 Jan 2022 09:48:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079lu8c009460 for ; Fri, 7 Jan 2022 04:47:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 48E4F60C33; Fri, 7 Jan 2022 09:47:56 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 238FC60C50; Fri, 7 Jan 2022 09:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548899; 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=5r10XZ5XlK5gDku9ZzB7fwso+xqMV/nCtrmpJ+i+DTo=; b=SZh0PjtBJ6QasPcaknijF7bj8YkQZ5uKFtAxWStfzUKyzDW44z3tJ++nf0jwkQJrw11FV5 UO9tk4H9dHDww4N+e0E15ENKbYSKWq1m3pWDy8weTboFpspERAruL/tWvC+y2Sf+9bZ5wE 5ILVGggSkyIklH4OjHEnHVs2hd42fbg= X-MC-Unique: G1XG6kvwNfejmpgH5DyvxA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 01/19] qemu: Only probe KVM on Linux Date: Fri, 7 Jan 2022 10:47:28 +0100 Message-Id: <20220107094746.1042621-2-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1641548901816100001 We already know it's not going to be available on other platforms. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5c9ca0fe4f..c2c10d282a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -9269,6 +9269,12 @@ qemuProcessQMPInit(qemuProcessQMP *proc) } =20 =20 +#if defined(__linux__) +# define hwaccel "kvm:tcg" +#else +# define hwaccel "tcg" +#endif + static int qemuProcessQMPLaunch(qemuProcessQMP *proc) { @@ -9279,7 +9285,7 @@ qemuProcessQMPLaunch(qemuProcessQMP *proc) if (proc->forceTCG) machine =3D "none,accel=3Dtcg"; else - machine =3D "none,accel=3Dkvm:tcg"; + machine =3D "none,accel=3D" hwaccel; =20 VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s", proc->binary, machine); --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641548902; cv=none; d=zohomail.com; s=zohoarc; b=TduhVQ/iFEPdCbXB/RoyO+k1CVmQ3odDY16Cf+MFUOP2B8tSeAPlwmJmdSWDK60tai4Zvg3+Xa9+vX3aJaVEdlKHJxRr3x8w0HMxbNJCu5W9KNq36y0/J7x6m143vWo/6RmeRSNz40SpTOrWHVm+7LWg0cIZdwJfZf5+m1+PyjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548902; 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=xNPxG1PIdgyHxyDKc3BQKaBoC2pRhrPxmT7Hym1uqCs=; b=CM8NfMHedwiXc92hO51N5WJ+DmATujfsv3im9m9pH4WfSy5OmZrTcUSFz86cIJ2zrjPt0h5h/Zpue57c/4FuvL3bjfMwzQXK298mtn8DmUiI7o7dm2eeVlEiqmlqAm34t0TahVqQqvVYsNzLP1oyfCGgRDc0BORWIjC2R7mKiJo= 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 164154890286582.94782446981708; Fri, 7 Jan 2022 01:48:22 -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-651-xA20sUPYPeGbwTfJRswzMQ-1; Fri, 07 Jan 2022 04:48:18 -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 DAE6B2F4B; Fri, 7 Jan 2022 09:48:12 +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 BCDB460C47; Fri, 7 Jan 2022 09:48:12 +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 8DD261806D2D; Fri, 7 Jan 2022 09:48:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079lv1t009468 for ; Fri, 7 Jan 2022 04:47:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CD3460C4B; Fri, 7 Jan 2022 09:47:57 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABEB060C33; Fri, 7 Jan 2022 09:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548901; 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=xNPxG1PIdgyHxyDKc3BQKaBoC2pRhrPxmT7Hym1uqCs=; b=JIfF6YzV6Qe/kYwyzM5WPKpB7S4sJhORnC+Fh5SxnrxoLlPfN/JusSntDW7lu2hh7sFzrz SuxmP1jsVV6w2AFl2m91e5tuuw88Vf0vsq0zoZcSaMoUS4Y5FKetA2TfA8ps9tnKtuwiap oGYmGmslvbUmymt81ufn5pzIT2knxaQ= X-MC-Unique: xA20sUPYPeGbwTfJRswzMQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 02/19] qemu: Add KVM CPUs into cache only if KVM is present Date: Fri, 7 Jan 2022 10:47:29 +0100 Message-Id: <20220107094746.1042621-3-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1641548903791100003 Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov virQEMUCapsFormatCache/virQEMUCapsLoadCache adds/reads KVM CPUs to/from capabilities cache regardless of QEMU_CAPS_KVM. That can cause undesired side-effects when KVM CPUs are present in the cache on a platform that doesn't support it, e.g. macOS or Linux without KVM support. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2d72132410..fd001100a1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4420,8 +4420,11 @@ virQEMUCapsLoadCache(virArch hostArch, return -1; } =20 - if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 || - virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && + virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0) { + return -1; + } + if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) return -1; =20 if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0) @@ -4430,7 +4433,8 @@ virQEMUCapsLoadCache(virArch hostArch, if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0) return -1; =20 - virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0) @@ -4663,7 +4667,8 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) virBufferAsprintf(&buf, "%s\n", virArchToString(qemuCaps->arch)); =20 - virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM); virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU); =20 for (i =3D 0; i < qemuCaps->ngicCapabilities; i++) { @@ -5517,7 +5522,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, qemuCaps->libvirtCtime =3D virGetSelfLastChanged(); qemuCaps->libvirtVersion =3D LIBVIR_VERSION_NUMBER; =20 - virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641548895; cv=none; d=zohomail.com; s=zohoarc; b=hj1gWXQvAN75nX1yqngYMc0Xqk9TkY9mJ059vOtFpUmI6FuYKECsEKOa0+cThDXAjSZzssvYmJ7uMKc0YK1mb+HxC3KIfgYx1UT2jDgugFKvLcDOoZS8IxLo7/ZIxNx8/r+dEVP/dqczoFgqMREn/O72lo0yaW17wPCBJUNuPLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548895; 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=JiUZ86jCzzDdnW3hp+RnpLuVR9yZclJjeKqAlaqr8lo=; b=f0tgsSmLKPgnqiyiuChu+MxtYxWeN50TydM/JtpZorZA74IdDGRdBuI+zdAgl73pHhZUEM92AXGWDZEGkEdb9TpR/LUGAgAmR7ifFqTt5dfIVo0cXlsB0vC/6Plf5PCg99Lgs5mXL071FBoIyLc93NcwBvp4TzjZLWk/fu7I0Kg= 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 1641548895975712.7127901251655; Fri, 7 Jan 2022 01:48:15 -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-549-QnZW6-ALN7OrnLEHxV4jLQ-1; Fri, 07 Jan 2022 04:48:11 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E0AF2F27; Fri, 7 Jan 2022 09:48:06 +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 CBE247AB66; Fri, 7 Jan 2022 09:48:05 +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 991BA4BB7C; Fri, 7 Jan 2022 09:48:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079m4d0009483 for ; Fri, 7 Jan 2022 04:48:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2DD656128B; Fri, 7 Jan 2022 09:48:04 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FADC60C4B; Fri, 7 Jan 2022 09:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548895; 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=JiUZ86jCzzDdnW3hp+RnpLuVR9yZclJjeKqAlaqr8lo=; b=UR6O4IA71lIggDZf5h8Bca4VbD8uK+jlXYY12gXBUNzYN5dYVyt/S2C9eSo2mEaG3a5R4W klqbBRSUhWjlHJEpZfFCsKuyDGJvBduGXw+6+p4KK/pnSFEJo6XMcMckmFIP+nmtR3pjb7 C78Rw+TWYm3bWhqUH26Z7dq4xZjU3Ic= X-MC-Unique: QnZW6-ALN7OrnLEHxV4jLQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 03/19] conf: Add hvf domain type Date: Fri, 7 Jan 2022 10:47:30 +0100 Message-Id: <20220107094746.1042621-4-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.16 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: 1641548897810100001 From: Roman Bolshakov QEMU supports Hypervisor.framework since 2.12 as hvf accel. Hypervisor.framework provides a lightweight interface to run a virtual cpu on macOS without the need to install third-party kernel extensions (KEXTs). It's supported since macOS 10.10 on machines with Intel VT-x feature set that includes Extended Page Tables (EPT) and Unrestricted Mode. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.rst | 3 ++- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 4 ++++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d4f30bb8af..3e9de05249 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -20,7 +20,8 @@ Element and attribute overview =20 The root element required for all virtual machines is named ``domain``. It= has two attributes, the ``type`` specifies the hypervisor used for running the -domain. The allowed values are driver specific, but include "xen", "kvm", = "qemu" +domain. The allowed values are driver specific, but include "xen", "kvm", +"hvf" (:since:`since 8.0.0 and QEMU 2.12`), "qemu" and "lxc". The second attribute is ``id`` which is a unique integer identi= fier for the running guest machine. Inactive machines have no id value. =20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 7fa5c2b8b5..bf9c12397f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -230,6 +230,7 @@ phyp vz bhyve + hvf diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5691b8d2d5..0faecf2bb4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -125,6 +125,7 @@ VIR_ENUM_IMPL(virDomainVirt, "parallels", "bhyve", "vz", + "hvf", ); =20 VIR_ENUM_IMPL(virDomainOS, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 144ba4dd12..d4d8aa7e23 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -139,6 +139,7 @@ typedef enum { VIR_DOMAIN_VIRT_PARALLELS, VIR_DOMAIN_VIRT_BHYVE, VIR_DOMAIN_VIRT_VZ, + VIR_DOMAIN_VIRT_HVF, =20 VIR_DOMAIN_VIRT_LAST } virDomainVirtType; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d822533ccb..3bacf3edf2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7229,6 +7229,10 @@ qemuBuildAccelCommandLine(virCommand *cmd, } break; =20 + case VIR_DOMAIN_VIRT_HVF: + virBufferAddLit(&buf, "hvf"); + break; + case VIR_DOMAIN_VIRT_KQEMU: case VIR_DOMAIN_VIRT_XEN: case VIR_DOMAIN_VIRT_LXC: --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641548918; cv=none; d=zohomail.com; s=zohoarc; b=ciubjWfjWQHX+D4P3loNy/WdmMymEO1cq+zd86NO2CbxhFpcNfvQDKcDOJ50EViXx+Yv+u2rLLGlCn+wsp6B694FbFL/3cmFWiNPGyc96KZNStys4/gbt063HZWosoHyWqukKXpbois066Z1JY55exKWVjZ3eNgUmf4EwpyedW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548918; 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=251c1R37nSlxpfkQtCeBJ16PcI6wHeYv8Mp/AW7sf94=; b=bUWuh4Ctrc06Fyo60aSBF6VwA3+j/PrH4MwW4g8S4vfLAE91DQwV1OLu4ydl2py26UlNXYx7ukIoyuxs/f7mpmzksHN3mQnG4weWGa8MNFoYvy/Sh7/IiDzKRJhs2eqHmJ0Ko0mzaC0H7sMMnxmfEksThxbAT/MlVXXwKaSuEuo= 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 1641548918503372.3964208370178; Fri, 7 Jan 2022 01:48: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-450-Hl_AK4nkO-qmoMbaukrzqQ-1; Fri, 07 Jan 2022 04:48:36 -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 D20542F4A; Fri, 7 Jan 2022 09:48:31 +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 B618A67C99; Fri, 7 Jan 2022 09:48:31 +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 865374A7C9; Fri, 7 Jan 2022 09:48:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079mVgm009584 for ; Fri, 7 Jan 2022 04:48:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1B8F76128B; Fri, 7 Jan 2022 09:48:31 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24BFD60C4B; Fri, 7 Jan 2022 09:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548917; 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=251c1R37nSlxpfkQtCeBJ16PcI6wHeYv8Mp/AW7sf94=; b=DVcOOU50aJj3YMO097snaB9ZTV4E6OhIG6tS/WoA8+TZN6MD0GlBpHzUA/2WIXOUdxtQSZ 7vP8Lw0T2ssvecitgiCqQMlF9VgEdKdzBq5KgpESeneHfT3N1Xq8oSJjHZVLhDLAw0Y89e uUgE2fg2wUZcXaygQGzISWB+ExVuIFA= X-MC-Unique: Hl_AK4nkO-qmoMbaukrzqQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 04/19] qemu: Define hvf capability Date: Fri, 7 Jan 2022 10:47:31 +0100 Message-Id: <20220107094746.1042621-5-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1641548919914100001 From: Roman Bolshakov Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index fd001100a1..6b7e295f68 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -654,6 +654,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "rbd-encryption", /* QEMU_CAPS_RBD_ENCRYPTION */ "sev-guest-kernel-hashes", /* QEMU_CAPS_SEV_GUEST_KERNEL_HAS= HES */ "sev-inject-launch-secret", /* QEMU_CAPS_SEV_INJECT_LAUNCH_S= ECRET */ + + /* 420 */ + "hvf", /* QEMU_CAPS_HVF */ ); =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 63ac24314f..4a9a40a8b9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -634,6 +634,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_SEV_GUEST_KERNEL_HASHES, /* sev-guest.kernel-hashes=3D */ QEMU_CAPS_SEV_INJECT_LAUNCH_SECRET, /* 'sev-inject-launch-secret' qmp = command present */ =20 + /* 420 */ + QEMU_CAPS_HVF, /* Whether Hypervisor.framework is available */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641548936; cv=none; d=zohomail.com; s=zohoarc; b=F8ucNzjxedXJcu3mxFfT2Zz+N88w9TYGMsxgNHIte4NzUM29DIvFho79Fu9JG3TnjT0uXh1h4RxNBkRK2TEsFilHRUptmm5Ufhw0cN/7/jPXaeJCKoqOH8CY0vhYT8vRWFkJQ4X0nCtRhiTV5E0xRMZmKjiYBcGo74vfpGVdRVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548936; 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=ZhrbN1+QQTOUUYqb7mZf/yKwvPoftb71kWilxjE/SM8=; b=gRMdAjhwwOH/F8jTw+qeh4pfa6uMPvSGp4r8ufvUpPQTtloD7iWrumKvFDMZoNQF7XQVocVoqQnWxbVmE3n9HMqjp5Jv6E4p8SCWKj29ffbCqA16T7TpJyuGse/0eM+p1WXmt91CW/RF0j5P6kvZTDRawJV0qyEzd9aqH+iJZDs= 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 1641548936696529.0662142012364; Fri, 7 Jan 2022 01:48:56 -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-62-EKkONtxXPquB60yxfe926w-1; Fri, 07 Jan 2022 04:48:52 -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 0E97D802C92; Fri, 7 Jan 2022 09:48:48 +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 DF7BF72FA2; Fri, 7 Jan 2022 09:48:47 +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 B14304A7CB; Fri, 7 Jan 2022 09:48:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079mkih009617 for ; Fri, 7 Jan 2022 04:48:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E6CA752AD; Fri, 7 Jan 2022 09:48:46 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CF1A752A8; Fri, 7 Jan 2022 09:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548935; 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=ZhrbN1+QQTOUUYqb7mZf/yKwvPoftb71kWilxjE/SM8=; b=aSNGQVPbiTodZF69idO3IxV0XDjiV4S7MfVi4W8BVsAdBbBUZvgLhnyG6t2MJXFxq7U5u3 6xItYkazraoeaAuajGQwt8XgiVoVKy6Emr62nlR4/vbesm0wHh7jGfSFZKV6IknYeTvX5b LdcA/SEtHsvAu3icO2xx4tidAiRZJTc= X-MC-Unique: EKkONtxXPquB60yxfe926w-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 05/19] qemu: Query hvf capability on macOS Date: Fri, 7 Jan 2022 10:47:32 +0100 Message-Id: <20220107094746.1042621-6-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641548938058100001 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6b7e295f68..56325d1762 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 @@ -3195,6 +3199,33 @@ 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 && + (qemuCaps->arch =3D=3D VIR_ARCH_X86_64 || + qemuCaps->arch =3D=3D VIR_ARCH_AARCH64) && + 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; @@ -5344,6 +5375,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 From nobody Fri Mar 29 12:09:46 2024 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=1641549005; cv=none; d=zohomail.com; s=zohoarc; b=laPWUzWP9B3JFWOhbVMTn314iH/gQEFyVewuvAjYSZLxmaojS31sws7uCj7XIP1gbe9869aM/rjmuN1KA+SHKUzBEqKIuYaMDF3Sym9UvqhsBMHT5YexJvj/8DXlREo0k04R/ydUEJfxWelWdFtTVd/ymGTtG0IENQO04AkqGgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549005; 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=z8ZxAHT8iVfSANmvl0stFgJmFWDr8MP+mruAnCp77YQ=; b=lA94nLIYzr1bp6qPa+UBT8DwJM+xizMD/EbeXJSR/tTfbbZW2He5Yw/HxtruBGATI4bMdGAKe3DK4d660npJEEHPrhqINQ7i18iQtA++zMYZJtPam1E+YNoSP0L+RdpSCQVfrCd1rcaCGvVDidUlhG6/cGe7BAEw/cp6i05bcmk= 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 1641549005292924.1836702359046; Fri, 7 Jan 2022 01:50: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-375-Uc5Bfra4MViKAvKlgnoSQg-1; Fri, 07 Jan 2022 04:49:15 -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 7AE4B100C660; Fri, 7 Jan 2022 09:49:10 +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 5E6696F11C; Fri, 7 Jan 2022 09:49:10 +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 2985E1806D2C; Fri, 7 Jan 2022 09:49:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079n9mK009823 for ; Fri, 7 Jan 2022 04:49:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0278967C99; Fri, 7 Jan 2022 09:49:09 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C532660C53; Fri, 7 Jan 2022 09:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549004; 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=z8ZxAHT8iVfSANmvl0stFgJmFWDr8MP+mruAnCp77YQ=; b=eEVCRnlwjeWT6T9yeVx+0up4FtzeAeE0nkJYnn00eeMQUJ49AoZI7BPEKqu5u/K+GWmvBX E4MHM22rDlKNIeBGc0pe0Eo/HHlMB6bdMff9uQ1KGBMpfQ2uNQ2hdea18ZIt6udRNMLc1g KgfExFthkuzh8AvuEInn2cAcU3eqQvU= X-MC-Unique: Uc5Bfra4MViKAvKlgnoSQg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 06/19] qemu: Expose hvf domain type if hvf is supported Date: Fri, 7 Jan 2022 10:47:33 +0100 Message-Id: <20220107094746.1042621-7-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1641549006595100001 From: Roman Bolshakov Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 56325d1762..081c43e728 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1084,6 +1084,10 @@ virQEMUCapsInitGuestFromBinary(virCaps *caps, virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL); } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) { + virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HVF, + NULL, NULL, 0, NULL); + } =20 if ((ARCH_IS_X86(guestarch) || guestarch =3D=3D VIR_ARCH_AARCH64)) virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEA= TURE_TYPE_ACPI, --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641548991; cv=none; d=zohomail.com; s=zohoarc; b=W7Csv4qaFKefmk5UoLzU89d23Jw1CkR92fPw9sw4LsWrR6UD7fmgj1MTBqblK7Npv8d4OKFSvE3CJckQ/NwQAJvU8zhT+EYOzI+6KC33g5UKGfPOfHYa/Friw7HQCpJ4EbqwmRD3neWksbDd6o9DiQIoO8Uj7NBfzrL3W8qAPDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641548991; 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=PZ1BTCT9qSGtk8a/l2ksx/cQ6q2dcyzwaCQFHF+ZasM=; b=gpp1nA8UZ0ZYMOquWMjU0vS1TGHna1/HaUPhZtXxsRXON1QAgDV5b5kB/eIoNjNY9sD4LXYaKg0bkmuq1Cw+iRWckQOqOQdf3yhik0Jj3OhXIKyKeW19gT4yaJS1R6XzAKrSkM1nM2rz7nfAVOX6tWxCOWFs3anm5uXLL4lVZO4= 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 1641548991745414.2648817779823; Fri, 7 Jan 2022 01:49:51 -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-588--GSF-AxhPA-82KvDI9D4xw-1; Fri, 07 Jan 2022 04:49:43 -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 1958E345C1; Fri, 7 Jan 2022 09:49:39 +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 F038770D53; Fri, 7 Jan 2022 09:49:38 +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 C30C84A700; Fri, 7 Jan 2022 09:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079nb9e009950 for ; Fri, 7 Jan 2022 04:49:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6CBDF60C47; Fri, 7 Jan 2022 09:49:37 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 841D567C99; Fri, 7 Jan 2022 09:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641548986; 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=PZ1BTCT9qSGtk8a/l2ksx/cQ6q2dcyzwaCQFHF+ZasM=; b=iG77WNJh4UVOSdqhdv+DVlGNirJW9sPcWq2OMIhhvnvhqy+pQr6xJKqNr1pNh8MjzcRkA9 rFnQrdWPWIR1nzHeBmMUUcxcBggOVK07LfR4kBKFznjvmQhVUaLji3GJBxUcZ8DnUTSQ+E I+HYoRBBL69I2s/pwbFYs36Ra0OxfbE= X-MC-Unique: -GSF-AxhPA-82KvDI9D4xw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 07/19] qemu: Introduce virQEMUCapsAccelStr Date: Fri, 7 Jan 2022 10:47:34 +0100 Message-Id: <20220107094746.1042621-8-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1641548992534100001 Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov This makes possible to add more accelerators by touching less code and reduces code duplication. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 081c43e728..c246e1b6ce 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -792,6 +792,16 @@ const char *virQEMUCapsArchToString(virArch arch) } =20 =20 +static const char * +virQEMUCapsAccelStr(virDomainVirtType type) +{ + if (type =3D=3D VIR_DOMAIN_VIRT_QEMU) + return "tcg"; + + return virDomainVirtTypeToString(type); +} + + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -4069,7 +4079,7 @@ virQEMUCapsLoadAccel(virQEMUCaps *qemuCaps, virDomainVirtType type) { virQEMUCapsAccel *caps =3D virQEMUCapsGetAccel(qemuCaps, type); - const char *typeStr =3D type =3D=3D VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg= "; + const char *typeStr =3D virQEMUCapsAccelStr(type); =20 if (virQEMUCapsLoadHostCPUModelInfo(caps, ctxt, typeStr) < 0) return -1; @@ -4622,7 +4632,7 @@ virQEMUCapsFormatAccel(virQEMUCaps *qemuCaps, virDomainVirtType type) { virQEMUCapsAccel *caps =3D virQEMUCapsGetAccel(qemuCaps, type); - const char *typeStr =3D type =3D=3D VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg= "; + const char *typeStr =3D virQEMUCapsAccelStr(type); =20 virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr); virQEMUCapsFormatCPUModels(caps, buf, typeStr); --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549022; cv=none; d=zohomail.com; s=zohoarc; b=cfMRGJu8ptafY8BbOzAl++fKcGU21EmZ1AVeaGH/noUGtihEe7MJSrFHgoEO8mQoE4fhCmXdc4MkicFgd+6ZB7/ADCVw9jtouamHTf6SmR1uKdDZ0Ayav6yK73eLZHgbAw+gfGidGyz491jv0h1lbG8BiS7+zM7uSPDvY5Spxlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549022; 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=3AHeb8gfn01PtRgqTGLFL+tmcSjS3yUTA0KZerd7yZw=; b=hnQf4P5/ikwbb7Gw/GsjyfADkC6Sk/8rV+RrCVlAOeQkCRC2OmKO7xeIbe6rCeRzL4v4ZA1k/lXC2WjlaNHiDCwyNtqfUSTqm4JEiJeY2Xd2/uQTuiq63KSMeZGxts/VBX+9nv824eSKV06RVLA18wkAOeibm9hVO5RBHwrffnI= 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 1641549022450390.00752956056294; Fri, 7 Jan 2022 01:50:22 -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-587-fYP-wSqqMIudElMe8PzvRg-1; Fri, 07 Jan 2022 04:50:18 -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 DBEB6363A4; Fri, 7 Jan 2022 09:50:12 +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 BDFF36F119; Fri, 7 Jan 2022 09:50:12 +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 91DA14A705; Fri, 7 Jan 2022 09:50:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079oADp010030 for ; Fri, 7 Jan 2022 04:50:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 786A660C4B; Fri, 7 Jan 2022 09:50:10 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 935BD60C47; Fri, 7 Jan 2022 09:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549021; 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=3AHeb8gfn01PtRgqTGLFL+tmcSjS3yUTA0KZerd7yZw=; b=exICfaRTyVio25v3Cvs+1UNv/xPQgsNSsQfcUOwWdUvw97m1YQ7qrgmqqJMKAxRK4CnPhH OmOQSKzXBQzbAyUwEqvPbmULj486ZCcHSaYtSqZP0E39qs5cBXXIaCKLXbIXlAS+7qJ+Am Ld0BEZPjxNrcNUakuz6M3EvMwgHWmZw= X-MC-Unique: fYP-wSqqMIudElMe8PzvRg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 08/19] qemu: Introduce virQEMUCapsTypeIsAccelerated Date: Fri, 7 Jan 2022 10:47:35 +0100 Message-Id: <20220107094746.1042621-9-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1641549024776100001 Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov It replaces hardcoded checks for KVM. It'll be cleaner to use the function once multiple accelerators are supported in the QEMU driver. Explicit KVM domain checks should be done only when a feature is available only for KVM. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c246e1b6ce..8e127c9041 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -802,6 +802,13 @@ virQEMUCapsAccelStr(virDomainVirtType type) } =20 =20 +static bool +virQEMUCapsTypeIsAccelerated(virDomainVirtType type) +{ + return type =3D=3D VIR_DOMAIN_VIRT_KVM; +} + + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -2342,7 +2349,7 @@ virQEMUCapsIsCPUModeSupported(virQEMUCaps *qemuCaps, =20 switch (mode) { case VIR_CPU_MODE_HOST_PASSTHROUGH: - return type =3D=3D VIR_DOMAIN_VIRT_KVM && + return virQEMUCapsTypeIsAccelerated(type) && virQEMUCapsGuestIsNative(hostarch, qemuCaps->arch); =20 case VIR_CPU_MODE_HOST_MODEL: @@ -3004,7 +3011,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, qemuMonitor *mon, virDomainVirtType virtType) { - const char *model =3D virtType =3D=3D VIR_DOMAIN_VIRT_KVM ? "host" : "= max"; + const char *model =3D virQEMUCapsTypeIsAccelerated(virtType) ? "host" = : "max"; g_autoptr(qemuMonitorCPUModelInfo) modelInfo =3D NULL; g_autoptr(qemuMonitorCPUModelInfo) nonMigratable =3D NULL; g_autoptr(GHashTable) hash =3D NULL; @@ -3715,7 +3722,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virArchToString(qemuCaps->arch), virDomainVirtTypeToString(type)); goto error; - } else if (type =3D=3D VIR_DOMAIN_VIRT_KVM && + } else if (virQEMUCapsTypeIsAccelerated(type) && virCPUGetHostIsSupported(qemuCaps->arch)) { if (!(fullCPU =3D virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL))) goto error; @@ -5848,10 +5855,10 @@ virQEMUCapsCacheLookupDefault(virFileCache *cache, if (virttype =3D=3D VIR_DOMAIN_VIRT_NONE) virttype =3D capsType; =20 - if (virttype =3D=3D VIR_DOMAIN_VIRT_KVM && capsType =3D=3D VIR_DOMAIN_= VIRT_QEMU) { + if (virQEMUCapsTypeIsAccelerated(virttype) && capsType =3D=3D VIR_DOMA= IN_VIRT_QEMU) { virReportError(VIR_ERR_INVALID_ARG, - _("KVM is not supported by '%s' on this host"), - binary); + _("the accel '%s' is not supported by '%s' on this = host"), + virQEMUCapsAccelStr(virttype), binary); return NULL; } =20 --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549041; cv=none; d=zohomail.com; s=zohoarc; b=B1uEuqS+qzdPF2NTIj0juob47yw+WJUo9v4n/CYPZR0qnF9HLtFDDxDijRZACPh2cZOm9Kv51KuqCRJfSfZ/MwNBYvscvJT/QreKPgyKtDzyNMYjp9vnmdBiy5RO9AZ4E+4gCS6Rb0vEX72jHhAy54LceyrRUs53HTSA5k3G0+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549041; 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=+0KCyO5dgObwrE3dOdkks5IuuxrAvcj/cTOpq4usP5A=; b=Z0cJ1X25sSHLCbtIQna5/bkdowDOTAsq0Ki0TTK3ZJjemrZv6IxPu4aN5Ho5y3UQbdp1jYmr6FE1jM+EqvsYhTQqwc9Iw/UytB67gQCYX8QK87S6Yd6tZtfPN+2wIKQePLqFYffrkgbc1gjDe9WzswES7JVLWwAZUXugsXQ+MLg= 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 1641549041947382.18741780971834; Fri, 7 Jan 2022 01:50:41 -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-245-hXYS14bFNna4KovURojRLg-1; Fri, 07 Jan 2022 04:50:39 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C57E7363A4; Fri, 7 Jan 2022 09:50: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 A1D191F300; Fri, 7 Jan 2022 09:50: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 666C61806D1D; Fri, 7 Jan 2022 09:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079oWCd010162 for ; Fri, 7 Jan 2022 04:50:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 406C060C47; Fri, 7 Jan 2022 09:50:32 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64D03749BE; Fri, 7 Jan 2022 09:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549040; 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=+0KCyO5dgObwrE3dOdkks5IuuxrAvcj/cTOpq4usP5A=; b=fus9FJURGRm59VYkCTXnHqTpi2zvvlfYfHQW/N3O/RQdEyWQV+KxN4bJhi92dhgD5iVXYv +Wqk333oocw2bYzPdOxrFqEmHWkm57oOBB9a7YLN9h+juqOYnkG2FUVzbf3o923X4YnWXt YqK3tWTqWGOMH1GwfNVyTk5+8dK5Axs= X-MC-Unique: hXYS14bFNna4KovURojRLg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 09/19] qemu: Introduce virQEMUCapsHaveAccel Date: Fri, 7 Jan 2022 10:47:36 +0100 Message-Id: <20220107094746.1042621-10-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.23 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: 1641549042868100001 From: Roman Bolshakov The function should be used to check if qemu capabilities include a hardware acceleration, i.e. accel is not TCG. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8e127c9041..8d0a700544 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -809,6 +809,13 @@ virQEMUCapsTypeIsAccelerated(virDomainVirtType type) } =20 =20 +static bool +virQEMUCapsHaveAccel(virQEMUCaps *qemuCaps) +{ + return virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM); +} + + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -5021,7 +5028,7 @@ virQEMUCapsIsValid(void *data, return false; } =20 - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { + if (virQEMUCapsHaveAccel(qemuCaps)) { if (STRNEQ_NULLABLE(priv->hostCPUSignature, qemuCaps->hostCPUSigna= ture)) { VIR_DEBUG("Outdated capabilities for '%s': host CPU changed " "('%s' vs '%s')", @@ -5055,7 +5062,9 @@ virQEMUCapsIsValid(void *data, qemuCaps->binary); return false; } + } =20 + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { kvmSupportsNesting =3D virQEMUCapsKVMSupportsNesting(); if (kvmSupportsNesting !=3D qemuCaps->kvmSupportsNesting) { VIR_DEBUG("Outdated capabilities for '%s': kvm kernel nested " @@ -5520,7 +5529,7 @@ virQEMUCapsInitQMP(virQEMUCaps *qemuCaps, * for TCG capabilities by asking the same binary again and turning KVM * off. */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && + if (virQEMUCapsHaveAccel(qemuCaps) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG) && virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true) <= 0) return -1; @@ -5584,13 +5593,15 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { + if (virQEMUCapsHaveAccel(qemuCaps)) { qemuCaps->hostCPUSignature =3D g_strdup(hostCPUSignature); qemuCaps->microcodeVersion =3D microcodeVersion; qemuCaps->cpuData =3D virCPUDataNewCopy(cpuData); =20 qemuCaps->kernelVersion =3D g_strdup(kernelVersion); + } =20 + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuCaps->kvmSupportsNesting =3D virQEMUCapsKVMSupportsNesting(); =20 qemuCaps->kvmSupportsSecureGuest =3D virQEMUCapsKVMSupportsSecureG= uest(); --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549062; cv=none; d=zohomail.com; s=zohoarc; b=Ya38J7osQYs+NQcqk/wkFtwfL2HIouiNdnNin7mWaT6W4mszVa8xSSw6ADnk1BqvB2SchOsTtgzqzh7WQybdxej00gKqPNlTyjM514iuTXQPK8G/yZDZi3y7GQE0vExnkCxXJMgn0VxT6iDLnvkyLjUqcoPwBcfkCdkPZ/YKtMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549062; 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=+9bkNhhirv7GBp59DlLeK0X+p4a9b/PJdK9t9Ke/RPw=; b=Ay+HJe3l3nR54NLOFy/WnpcOEFRiNRxh9PyfyLNFnXvnTd0Y9dnUVdlG7A/Alzqdn4O97MWaqAQfTHgE3HqOLG4eRs8DnijqV30GuSZ7ZGmVDuArjf4ehrNeSdirpWEMex+k8ixEEQB/X9mzllxp0AU7wVUUu7i7i3hHTVWblIQ= 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 1641549062469756.8792202974126; Fri, 7 Jan 2022 01:51:02 -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-533-4tA-dwS1N9mbMt6tzcHQ0Q-1; Fri, 07 Jan 2022 04:50:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A5C9801AAB; Fri, 7 Jan 2022 09:50:52 +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 6A16A55F7D; Fri, 7 Jan 2022 09:50:52 +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 3941B4A705; Fri, 7 Jan 2022 09:50:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079oocu010197 for ; Fri, 7 Jan 2022 04:50:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id C291460C33; Fri, 7 Jan 2022 09:50:50 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB54960C5A; Fri, 7 Jan 2022 09:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549061; 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=+9bkNhhirv7GBp59DlLeK0X+p4a9b/PJdK9t9Ke/RPw=; b=g4dpqU5sI4VcUEA1YK5tDtB83t6cU9Hb1O+moCSRnhPX36hsS6xofq84E3XAQdHiPP7uOS AEYfBq59MJ4KPUDAaqXj4uvRUlfsqBn6/dVsnaTBPNvw6mVhHo5q9KrWrO6ko/d5p0TORB SEtwAPZLuO/Lnnj8Ezy1lyQYH98LBcs= X-MC-Unique: 4tA-dwS1N9mbMt6tzcHQ0Q-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 10/19] qemu: Correct CPU capabilities probing for hvf Date: Fri, 7 Jan 2022 10:47:37 +0100 Message-Id: <20220107094746.1042621-11-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1641549063046100001 Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov With this change virsh domcapabilites shows: https://gitlab.com/libvirt/libvirt/-/issues/147 Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 32 +++++++++++++++++++++++++++++--- src/qemu/qemu_process.c | 2 ++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8d0a700544..dac8af38e6 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -744,6 +744,7 @@ struct _virQEMUCaps { =20 /* Capabilities which may differ depending on the accelerator. */ virQEMUCapsAccel kvm; + virQEMUCapsAccel hvf; virQEMUCapsAccel tcg; }; =20 @@ -805,14 +806,16 @@ virQEMUCapsAccelStr(virDomainVirtType type) static bool virQEMUCapsTypeIsAccelerated(virDomainVirtType type) { - return type =3D=3D VIR_DOMAIN_VIRT_KVM; + return type =3D=3D VIR_DOMAIN_VIRT_KVM || + type =3D=3D VIR_DOMAIN_VIRT_HVF; } =20 =20 static bool virQEMUCapsHaveAccel(virQEMUCaps *qemuCaps) { - return virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM); + return virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF); } =20 =20 @@ -868,6 +871,8 @@ virQEMUCapsGetAccel(virQEMUCaps *qemuCaps, { if (type =3D=3D VIR_DOMAIN_VIRT_KVM) return &qemuCaps->kvm; + else if (type =3D=3D VIR_DOMAIN_VIRT_HVF) + return &qemuCaps->hvf; =20 return &qemuCaps->tcg; } @@ -998,6 +1003,8 @@ virQEMUCapsGetMachineTypesCaps(virQEMUCaps *qemuCaps, * take the set of machine types we probed first. */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) accel =3D &qemuCaps->kvm; + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) + accel =3D &qemuCaps->hvf; else accel =3D &qemuCaps->tcg; =20 @@ -2016,6 +2023,7 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps) ret->cpuData =3D virCPUDataNewCopy(qemuCaps->cpuData); =20 if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 || + virQEMUCapsAccelCopy(&ret->hvf, &qemuCaps->hvf) < 0 || virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0) return NULL; =20 @@ -2069,6 +2077,7 @@ void virQEMUCapsDispose(void *obj) virSEVCapabilitiesFree(qemuCaps->sevCapabilities); =20 virQEMUCapsAccelClear(&qemuCaps->kvm); + virQEMUCapsAccelClear(&qemuCaps->hvf); virQEMUCapsAccelClear(&qemuCaps->tcg); } =20 @@ -2320,6 +2329,10 @@ virQEMUCapsIsVirtTypeSupported(virQEMUCaps *qemuCaps, virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG)) return true; =20 + if (virtType =3D=3D VIR_DOMAIN_VIRT_HVF && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) + return true; + if (virtType =3D=3D VIR_DOMAIN_VIRT_KVM && virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) return true; @@ -2797,7 +2810,9 @@ bool virQEMUCapsHasMachines(virQEMUCaps *qemuCaps) { =20 - return !!qemuCaps->kvm.nmachineTypes || !!qemuCaps->tcg.nmachineTypes; + return !!qemuCaps->kvm.nmachineTypes || + !!qemuCaps->hvf.nmachineTypes || + !!qemuCaps->tcg.nmachineTypes; } =20 =20 @@ -4486,6 +4501,10 @@ virQEMUCapsLoadCache(virArch hostArch, virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0) { return -1; } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF) && + virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_HVF) < 0) { + return -1; + } if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) return -1; =20 @@ -4497,6 +4516,8 @@ virQEMUCapsLoadCache(virArch hostArch, =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_HV= F); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0) @@ -4731,6 +4752,8 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) + virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_HVF); virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU); =20 for (i =3D 0; i < qemuCaps->ngicCapabilities; i++) { @@ -5591,6 +5614,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_HVF)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_HV= F); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virQEMUCapsHaveAccel(qemuCaps)) { @@ -6585,5 +6610,6 @@ void virQEMUCapsStripMachineAliases(virQEMUCaps *qemuCaps) { virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_KV= M); + virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_HV= F); virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_QE= MU); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c2c10d282a..ff13ac66d7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -9271,6 +9271,8 @@ qemuProcessQMPInit(qemuProcessQMP *proc) =20 #if defined(__linux__) # define hwaccel "kvm:tcg" +#elif defined(__APPLE__) +# define hwaccel "hvf:tcg" #else # define hwaccel "tcg" #endif --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549065; cv=none; d=zohomail.com; s=zohoarc; b=QWX5WcEHu1QdvrVxnK+uKv+4R94VmIeHGA83kChga37tkZhouibnx2hLZ1waqFPjhS8FAz2rJoBs2PQgDI4C7vhn4T1F66xmHjhdHP8/bCVcZaQ6Cde2U98ED48Qdy/+jXUvWvRfSRRUkf0yxwpQQqqbido0nU3dC5YURFVHeBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549065; 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=YkRSJZc5BoRQCBZSohQWnoM86QWPyTaZXrQGeYOx7F4=; b=lJyJPE+Wd2xUJlyOO6lOkQzu1EbiBzATYBfH2FolVZMnoS767fkc/7pq/rwdMmiS8ZxzPqryS32TonNBZC7R+RHeB40LoS75kuZ3RCGwFYRjrzTtBSfxCW5+sDP46J+3z4+4xKzbQ0HqW7Q20ux/ylVa2lEDdRArwH9JCeUXQFc= 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 1641549065339585.5026376097853; Fri, 7 Jan 2022 01:51: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-502-9ya9kc17MKubttNXELKE6w-1; Fri, 07 Jan 2022 04:51:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93E92801B2A; Fri, 7 Jan 2022 09:50:55 +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 6B6077AB7D; Fri, 7 Jan 2022 09:50:55 +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 0C3624A707; Fri, 7 Jan 2022 09:50:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079oqHX010208 for ; Fri, 7 Jan 2022 04:50:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B50A660C5A; Fri, 7 Jan 2022 09:50:52 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6206F60C33; Fri, 7 Jan 2022 09:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549064; 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=YkRSJZc5BoRQCBZSohQWnoM86QWPyTaZXrQGeYOx7F4=; b=iNLZvsBPm9hlQjGlysjYs2cCp0i6qMxmMEj9R3fABMMHTTfndHLmhA3uu2qkmj78jETC1F HXh9COVQ8SAVqDTVX3M/ImGJCuJcoLSykObTa0aCknPkeldrwBFluKs+RnX5lvW05C+QuH 5vhJPyx1ZcI+xrXHv7ctvUb4WvY76cE= X-MC-Unique: 9ya9kc17MKubttNXELKE6w-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 11/19] tests: Introduce testQemuHostOS Date: Fri, 7 Jan 2022 10:47:38 +0100 Message-Id: <20220107094746.1042621-12-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.16 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: 1641549067056100001 Content-Type: text/plain; charset="utf-8" This new enumeration provides a way to specify the host OS that a specific test case expects. The default is Linux, which has been the implicit host OS until now; when Linux is selected as the host OS, KVM support is advertised in capabilies data exposed to test cases. This commit doesn't result in any functional change, and simply sets the stage for introducing macOS host OS support later. Signed-off-by: Andrea Bolognani --- tests/testutilsqemu.c | 87 +++++++++++++++++++++++++++---------------- tests/testutilsqemu.h | 4 ++ 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index cb665e501b..b9835782da 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -160,7 +160,8 @@ virHostCPUX86GetCPUID(uint32_t leaf, =20 static int testQemuAddGuest(virCaps *caps, - virArch arch) + virArch arch, + testQemuHostOS hostOS) { size_t nmachines; virCapsGuestMachine **machines =3D NULL; @@ -193,16 +194,18 @@ testQemuAddGuest(virCaps *caps, virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL); =20 - if (kvm_machines[emu_arch] !=3D NULL) { - nmachines =3D g_strv_length((char **)kvm_machines[emu_arch]); - machines =3D virCapabilitiesAllocMachines(kvm_machines[emu_arch], - nmachines); - if (machines =3D=3D NULL) - goto error; - - virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, - qemu_emulators[emu_arch], - NULL, nmachines, machines); + if (hostOS =3D=3D HOST_OS_LINUX) { + if (kvm_machines[emu_arch] !=3D NULL) { + nmachines =3D g_strv_length((char **)kvm_machines[emu_arch]); + machines =3D virCapabilitiesAllocMachines(kvm_machines[emu_arc= h], + nmachines); + if (machines =3D=3D NULL) + goto error; + + virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, + qemu_emulators[emu_arch], + NULL, nmachines, machines); + } } =20 return 0; @@ -213,7 +216,8 @@ testQemuAddGuest(virCaps *caps, } =20 =20 -virCaps *testQemuCapsInit(void) +static virCaps* +testQemuCapsInitImpl(testQemuHostOS hostOS) { virCaps *caps; size_t i; @@ -233,7 +237,7 @@ virCaps *testQemuCapsInit(void) goto cleanup; =20 for (i =3D 0; i < VIR_ARCH_LAST; i++) { - if (testQemuAddGuest(caps, i) < 0) + if (testQemuAddGuest(caps, i, hostOS) < 0) goto cleanup; } =20 @@ -255,6 +259,12 @@ virCaps *testQemuCapsInit(void) return NULL; } =20 +virCaps* +testQemuCapsInit(void) +{ + return testQemuCapsInitImpl(HOST_OS_LINUX); +} + =20 void qemuTestSetHostArch(virQEMUDriver *driver, @@ -335,10 +345,10 @@ void qemuTestDriverFree(virQEMUDriver *driver) virCPUDefFree(cpuPower9); } =20 - static void qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps, - virArch arch) + virArch arch, + testQemuHostOS hostOS) { size_t i; const char *defaultRAMid =3D NULL; @@ -366,20 +376,22 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps, virQEMUCapsSet(caps, QEMU_CAPS_TCG); } =20 - if (kvm_machines[arch] !=3D NULL) { - for (i =3D 0; kvm_machines[arch][i] !=3D NULL; i++) { - virQEMUCapsAddMachine(caps, - VIR_DOMAIN_VIRT_KVM, - kvm_machines[arch][i], - NULL, - NULL, - 0, - false, - false, - true, - defaultRAMid, - false); - virQEMUCapsSet(caps, QEMU_CAPS_KVM); + if (hostOS =3D=3D HOST_OS_LINUX) { + if (kvm_machines[arch] !=3D NULL) { + for (i =3D 0; kvm_machines[arch][i] !=3D NULL; i++) { + virQEMUCapsAddMachine(caps, + VIR_DOMAIN_VIRT_KVM, + kvm_machines[arch][i], + NULL, + NULL, + 0, + false, + false, + true, + defaultRAMid, + false); + virQEMUCapsSet(caps, QEMU_CAPS_KVM); + } } } } @@ -399,8 +411,10 @@ qemuTestCapsCacheInsertData(virFileCache *cache, } =20 =20 -int qemuTestCapsCacheInsert(virFileCache *cache, - virQEMUCaps *caps) +static int +qemuTestCapsCacheInsertImpl(virFileCache *cache, + virQEMUCaps *caps, + testQemuHostOS hostOS) { size_t i; =20 @@ -425,7 +439,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache, if (!(copyCaps =3D effCaps =3D virQEMUCapsNewCopy(caps))) return -1; =20 - qemuTestCapsPopulateFakeMachines(copyCaps, arch); + qemuTestCapsPopulateFakeMachines(copyCaps, arch, hostOS); } =20 if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], e= ffCaps) < 0) @@ -460,7 +474,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache, if (!tmp) return -1; =20 - qemuTestCapsPopulateFakeMachines(tmp, i); + qemuTestCapsPopulateFakeMachines(tmp, i, hostOS); =20 if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], tmp)= < 0) return -1; @@ -470,6 +484,13 @@ int qemuTestCapsCacheInsert(virFileCache *cache, return 0; } =20 +int +qemuTestCapsCacheInsert(virFileCache *cache, + virQEMUCaps *caps) +{ + return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_LINUX); +} + =20 # define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX" # define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX" diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index d59fa53239..a8de6eb52b 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -33,6 +33,10 @@ enum { GIC_BOTH, }; =20 +typedef enum { + HOST_OS_LINUX =3D 0, +} testQemuHostOS; + typedef enum { ARG_QEMU_CAPS =3D QEMU_CAPS_LAST + 1, ARG_GIC, --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549131; cv=none; d=zohomail.com; s=zohoarc; b=lyFLUzCewEi61kVbWTJNtUhdWloczixv9vjNxOkMYL62VY9B0cFpd4ZLnvakrKl8wvDiWzEtjsnkQ2qy0LZZcYrQc0DRLpTU8S8oNhs7JqSKQC1rVEVa4xi/9uSY/mOxUzdbsVbNlClW0jRYnGVsAAawkDAE6HH3MFm6K2/yYlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549131; 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=DAOcFVACG+ALkamllrK+2uVOj/eF8Y6fsZ5olL3zlRo=; b=iY8JQipfcxwpFd6gpoxhZLY7N3ppdmPpmdDQBiBIoNpuA9r2pJJFtWB1BKNwQnl9TdTsj8bLSx5c/zSP1S92Xzfg5+M+0u8fsyxTpkiyns1AZdTxWAsZzVW54bksIJKshDBwOQ/Ph2ax2vyi3u+CM7UuM4glmrwNDPPk6HG3fko= 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 1641549131381595.6716820724222; Fri, 7 Jan 2022 01:52:11 -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-364-m8mFRVlSPPCCijc_MJPjiw-1; Fri, 07 Jan 2022 04:51:00 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2063D835E35; Fri, 7 Jan 2022 09:50:56 +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 F16DB55F7D; Fri, 7 Jan 2022 09:50:55 +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 BB36C4A708; Fri, 7 Jan 2022 09:50:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079osZP010216 for ; Fri, 7 Jan 2022 04:50:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1196467C99; Fri, 7 Jan 2022 09:50:54 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A9C060C5A; Fri, 7 Jan 2022 09:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549130; 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=DAOcFVACG+ALkamllrK+2uVOj/eF8Y6fsZ5olL3zlRo=; b=QKqEcwZB/lp0PC7+OcRjCF8O/PTCOfKll5h+BMoR4TRauAEamauUHWjDUZSKzm7eusPBCM Ki5U+QrQc5tusEvrLybf//EtXjV/YBGyX9yBJlzH5CfhsU+l3UL9tBoeDSwAxOaxEP9O76 qbasnHxoBTQZZiAaf9o861CI+9bjv2U= X-MC-Unique: m8mFRVlSPPCCijc_MJPjiw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 12/19] tests: Add macOS support to testutilsqemu Date: Fri, 7 Jan 2022 10:47:39 +0100 Message-Id: <20220107094746.1042621-13-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1641549133481100001 Content-Type: text/plain; charset="utf-8" This exposes a couple of macOS-specific variants of existing APIs, which can be used when implementing test programs and result in HVF support being advertised. Signed-off-by: Andrea Bolognani --- tests/testutilsqemu.c | 58 +++++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 4 +++ 2 files changed, 62 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index b9835782da..64c57b0073 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -97,6 +97,18 @@ static const char *const *kvm_machines[VIR_ARCH_LAST] = =3D { [VIR_ARCH_S390X] =3D s390x_machines, }; =20 +static const char *const *hvf_machines[VIR_ARCH_LAST] =3D { + [VIR_ARCH_I686] =3D NULL, + [VIR_ARCH_X86_64] =3D x86_64_machines, + [VIR_ARCH_AARCH64] =3D aarch64_machines, + [VIR_ARCH_ARMV7L] =3D NULL, + [VIR_ARCH_PPC64] =3D NULL, + [VIR_ARCH_PPC] =3D NULL, + [VIR_ARCH_RISCV32] =3D NULL, + [VIR_ARCH_RISCV64] =3D NULL, + [VIR_ARCH_S390X] =3D NULL, +}; + static const char *qemu_default_ram_id[VIR_ARCH_LAST] =3D { [VIR_ARCH_I686] =3D "pc.ram", [VIR_ARCH_X86_64] =3D "pc.ram", @@ -208,6 +220,20 @@ testQemuAddGuest(virCaps *caps, } } =20 + if (hostOS =3D=3D HOST_OS_MACOS) { + if (hvf_machines[emu_arch] !=3D NULL) { + nmachines =3D g_strv_length((char **)hvf_machines[emu_arch]); + machines =3D virCapabilitiesAllocMachines(hvf_machines[emu_arc= h], + nmachines); + if (machines =3D=3D NULL) + goto error; + + virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HVF, + qemu_emulators[emu_arch], + NULL, nmachines, machines); + } + } + return 0; =20 error: @@ -265,6 +291,12 @@ testQemuCapsInit(void) return testQemuCapsInitImpl(HOST_OS_LINUX); } =20 +virCaps* +testQemuCapsInitMacOS(void) +{ + return testQemuCapsInitImpl(HOST_OS_MACOS); +} + =20 void qemuTestSetHostArch(virQEMUDriver *driver, @@ -394,6 +426,25 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps, } } } + + if (hostOS =3D=3D HOST_OS_MACOS) { + if (hvf_machines[arch] !=3D NULL) { + for (i =3D 0; hvf_machines[arch][i] !=3D NULL; i++) { + virQEMUCapsAddMachine(caps, + VIR_DOMAIN_VIRT_HVF, + hvf_machines[arch][i], + NULL, + NULL, + 0, + false, + false, + true, + defaultRAMid, + false); + virQEMUCapsSet(caps, QEMU_CAPS_HVF); + } + } + } } =20 =20 @@ -491,6 +542,13 @@ qemuTestCapsCacheInsert(virFileCache *cache, return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_LINUX); } =20 +int +qemuTestCapsCacheInsertMacOS(virFileCache *cache, + virQEMUCaps *caps) +{ + return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_MACOS); +} + =20 # define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX" # define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX" diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index a8de6eb52b..a9202d2ae6 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -35,6 +35,7 @@ enum { =20 typedef enum { HOST_OS_LINUX =3D 0, + HOST_OS_MACOS, } testQemuHostOS; =20 typedef enum { @@ -92,6 +93,7 @@ struct testQemuInfo { }; =20 virCaps *testQemuCapsInit(void); +virCaps *testQemuCapsInitMacOS(void); virDomainXMLOption *testQemuXMLConfInit(void); =20 =20 @@ -113,6 +115,8 @@ int qemuTestDriverInit(virQEMUDriver *driver); void qemuTestDriverFree(virQEMUDriver *driver); int qemuTestCapsCacheInsert(virFileCache *cache, virQEMUCaps *caps); +int qemuTestCapsCacheInsertMacOS(virFileCache *cache, + virQEMUCaps *caps); =20 int testQemuCapsSetGIC(virQEMUCaps *qemuCaps, int gic); --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549068; cv=none; d=zohomail.com; s=zohoarc; b=dbqtRuwRMYF1rlhSA8DrN3Ky0UTfIc+tA4RqJPX1ce2KRLc48xxM1N2jfEzdYN2dw1ZK9olQs6lG7rfMje1GWTyqInYhOQLECsBrjaFaBvKxj6kkDngkhOMY+bSnPf4Y6ilVe+CWX5TElInqMRYZ65hO1DnhT/1C6T3sMjgX0d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549068; 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=DOW7/G6J69fs921Bv4tX0nER3yDZywrNlDBbd3JYGfA=; b=nOyj55WT+2nu4IVlZjjSaKWBDqSSo5322U0N3OX6s1Y2MNEj95OgC22HPkkRpfgrYmITTOz6T1qxb1+AmOd2J5Xul0v562a8sVjN+FbRATF8k09vowt64+3dvj+EK6nfCwqMoazW+TDrofRE7HkEF5Ov1NyQ1KXFdGMsCefdEFk= 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 1641549068056695.9535746542384; Fri, 7 Jan 2022 01:51:08 -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-368-kjRkw2pyMUucKzEZTDmjvA-1; Fri, 07 Jan 2022 04:51:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4A8F100CCD0; Fri, 7 Jan 2022 09:50:58 +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 8F4F25B2C5; Fri, 7 Jan 2022 09:50:58 +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 5CB301806D03; Fri, 7 Jan 2022 09:50:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079ot44010228 for ; Fri, 7 Jan 2022 04:50:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id ADB4F6128B; Fri, 7 Jan 2022 09:50:55 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D01060C5A; Fri, 7 Jan 2022 09:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549067; 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=DOW7/G6J69fs921Bv4tX0nER3yDZywrNlDBbd3JYGfA=; b=ZLhIr09Sezyoy3vSqiM0Aa2o/PwXjC6ppD6iO7SOMNH+Km17Srb5ePrRPkXbSRyfcypkGr LZuFu/5CnFhcDdZ9D2c1zgseCNSQ3cF1Dj9wEUU+IZMsz93umzbfp3aflmiTbYXYteJaSv hnAk0wpKEVdp57gzqjK97W6ou1mMf04= X-MC-Unique: kjRkw2pyMUucKzEZTDmjvA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 13/19] tests: Add macOS support to qemuxml2*test Date: Fri, 7 Jan 2022 10:47:40 +0100 Message-Id: <20220107094746.1042621-14-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.23 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: 1641549069130100001 Content-Type: text/plain; charset="utf-8" The new DO_TEST_MACOS() macro makes it possible to create test cases that verify the behavior of libvirt on a macOS machine with HVF support available. Signed-off-by: Andrea Bolognani --- tests/qemuxml2argvtest.c | 25 ++++++++++++++++++++++++- tests/qemuxml2xmltest.c | 27 ++++++++++++++++++++++++++- tests/testutilsqemu.c | 4 ++++ tests/testutilsqemu.h | 2 ++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index cc67d806e4..6bb330e27e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -39,6 +39,8 @@ # define VIR_FROM_THIS VIR_FROM_QEMU =20 static virQEMUDriver driver; +static virCaps *linuxCaps; +static virCaps *macOSCaps; =20 static unsigned char * fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED, @@ -716,12 +718,18 @@ testCompareXMLToArgv(const void *data) g_autofree char *archstr =3D NULL; virArch arch =3D VIR_ARCH_NONE; g_autoptr(virIdentity) sysident =3D virIdentityGetSystem(); + int rc; =20 memset(&monitor_chr, 0, sizeof(monitor_chr)); =20 if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0) goto cleanup; =20 + if (info->args.hostOS =3D=3D HOST_OS_MACOS) + driver.caps =3D macOSCaps; + else + driver.caps =3D linuxCaps; + if (info->arch !=3D VIR_ARCH_NONE && info->arch !=3D VIR_ARCH_X86_64) qemuTestSetHostArch(&driver, info->arch); =20 @@ -771,7 +779,11 @@ testCompareXMLToArgv(const void *data) goto cleanup; } =20 - if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0) + if (info->args.hostOS =3D=3D HOST_OS_MACOS) + rc =3D qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qe= muCaps); + else + rc =3D qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCap= s); + if (rc < 0) goto cleanup; =20 if (info->migrateFrom && @@ -934,6 +946,13 @@ mymain(void) if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 + /* By default, the driver gets a virCaps instance that's suitable for + * tests that expect Linux as the host OS. We create another one for + * macOS, and keep around pointers to both so that we can pick the + * best one for each test case */ + linuxCaps =3D driver.caps; + macOSCaps =3D testQemuCapsInitMacOS(); + driver.privileged =3D true; =20 VIR_FREE(driver.config->defaultTLSx509certdir); @@ -1074,6 +1093,10 @@ mymain(void) DO_TEST_FULL(name, "", \ ARG_GIC, gic, \ ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) +# define DO_TEST_MACOS(name, ...) \ + DO_TEST_FULL(name, "", \ + ARG_HOST_OS, HOST_OS_MACOS, \ + ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) =20 # define DO_TEST_FAILURE(name, ...) \ DO_TEST_FULL(name, "", \ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index fb438269b9..90047197b4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -21,6 +21,8 @@ #define VIR_FROM_THIS VIR_FROM_NONE =20 static virQEMUDriver driver; +static virCaps *linuxCaps; +static virCaps *macOSCaps; =20 enum { WHEN_INACTIVE =3D 1, @@ -32,13 +34,24 @@ enum { static int testXML2XMLCommon(const struct testQemuInfo *info) { + int rc; + if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0) return -1; =20 + if (info->args.hostOS =3D=3D HOST_OS_MACOS) + driver.caps =3D macOSCaps; + else + driver.caps =3D linuxCaps; + if (!(info->flags & FLAG_REAL_CAPS)) virQEMUCapsInitQMPBasicArch(info->qemuCaps); =20 - if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0) + if (info->args.hostOS =3D=3D HOST_OS_MACOS) + rc =3D qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qe= muCaps); + else + rc =3D qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCap= s); + if (rc < 0) return -1; =20 return 0; @@ -143,6 +156,13 @@ mymain(void) if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 + /* By default, the driver gets a virCaps instance that's suitable for + * tests that expect Linux as the host OS. We create another one for + * macOS, and keep around pointers to both so that we can pick the + * best one for each test case */ + linuxCaps =3D driver.caps; + macOSCaps =3D testQemuCapsInitMacOS(); + cfg =3D virQEMUDriverGetConfig(&driver); driver.privileged =3D true; =20 @@ -206,6 +226,11 @@ mymain(void) #define DO_TEST_NOCAPS(name) \ DO_TEST_FULL(name, "", WHEN_BOTH, ARG_END) =20 +#define DO_TEST_MACOS(name, ...) \ + DO_TEST_FULL(name, "", WHEN_BOTH, \ + ARG_HOST_OS, HOST_OS_MACOS, \ + ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) + /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 64c57b0073..cba404e5cc 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -869,6 +869,10 @@ testQemuInfoSetArgs(struct testQemuInfo *info, info->args.capsver =3D va_arg(argptr, char *); break; =20 + case ARG_HOST_OS: + info->args.hostOS =3D va_arg(argptr, int); + break; + case ARG_END: default: info->args.invalidarg =3D true; diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index a9202d2ae6..51139e6a97 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -47,6 +47,7 @@ typedef enum { ARG_PARSEFLAGS, ARG_CAPS_ARCH, ARG_CAPS_VER, + ARG_HOST_OS, ARG_END, } testQemuInfoArgName; =20 @@ -72,6 +73,7 @@ struct testQemuArgs { char *capsver; char *capsarch; int gic; + testQemuHostOS hostOS; bool invalidarg; }; =20 --=20 2.31.1 From nobody Fri Mar 29 12:09:46 2024 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=1641549068; cv=none; d=zohomail.com; s=zohoarc; b=kS4g90nvOwTO+RBU5wlHIprWti/zwZRBujuetXAjXwguGF88uVvJuLHyDaJOf+mDPXXFLMasZZvLxpxWZ1xtsMI1tbE5CNT2qMMjUGognzUDpbUhoZF3/KyHQu+dRgoXuq5VKieIAXeWiw3cGBcuMOlGi5bq7YZjZI6t1+A7uEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641549068; 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=e1MLrhCUZ/zWzV4IvHWI7S0kqm0y0nC/ZuXb9qwFeXU=; b=E0Z3whIW3FXqTLDasMzH4Xgs6kaDB6FP7eRj3ZMUth+h2u4VymdjGUSfKKGc6y9dP2FqcEcJwRHHWk96jJs4Tzt8vqF/GD5gX/QheoSGydvFC0Dg4i6hZvOh7SEsWcQF9A1ASI2wQPIxhFJ35XqKpML9Y8ncC97esMmBOzNzeok= 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 164154906833298.39441217837759; Fri, 7 Jan 2022 01:51:08 -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-204-hOwSoopXOD2PLvrADDNZDw-1; Fri, 07 Jan 2022 04:51:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95183192AB98; Fri, 7 Jan 2022 09:51:01 +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 72F851059161; Fri, 7 Jan 2022 09:51:01 +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 3BA3C18045C5; Fri, 7 Jan 2022 09:51:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2079ovCI010250 for ; Fri, 7 Jan 2022 04:50:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id A0666749BE; Fri, 7 Jan 2022 09:50:57 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 419226128B; Fri, 7 Jan 2022 09:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641549067; 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=e1MLrhCUZ/zWzV4IvHWI7S0kqm0y0nC/ZuXb9qwFeXU=; b=NxYs3RoYYThrRgZFEEZ/5BdcZqtOE0GCLFUGRWz/e80THyhXaZfiYh0J78ZnTUYnFfCj6F YxHM6Gl+NY6Y7CJHRDGRON8hDvks6NGMUq0vG4QyN6FgjGgy3AeTwfWjauZkm9jhml5sGI VI+JPcyHILQ+ZLfcCfLTPuRrCNSgDvY= X-MC-Unique: hOwSoopXOD2PLvrADDNZDw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 14/19] tests: Add HVF test cases Date: Fri, 7 Jan 2022 10:47:41 +0100 Message-Id: <20220107094746.1042621-15-abologna@redhat.com> In-Reply-To: <20220107094746.1042621-1-abologna@redhat.com> References: <20220107094746.1042621-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1641549069164100002 Content-Type: text/plain; charset="utf-8" We need to use a hardcoded list of capabilities because we don't yet have proper replies files obtained from QEMU running on actual macOS machines. Signed-off-by: Andrea Bolognani --- .../hvf-aarch64-virt-headless.args | 48 +++++++++ .../hvf-aarch64-virt-headless.xml | 45 +++++++++ .../hvf-x86_64-q35-headless.args | 47 +++++++++ .../hvf-x86_64-q35-headless.x86_64-latest.err | 1 + .../hvf-x86_64-q35-headless.xml | 44 +++++++++ tests/qemuxml2argvtest.c | 18 ++++ .../hvf-aarch64-virt-headless.xml | 94 ++++++++++++++++++ .../hvf-x86_64-q35-headless.xml | 97 +++++++++++++++++++ tests/qemuxml2xmltest.c | 16 +++ 9 files changed, 410 insertions(+) create mode 100644 tests/qemuxml2argvdata/hvf-aarch64-virt-headless.args create mode 100644 tests/qemuxml2argvdata/hvf-aarch64-virt-headless.xml create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.args create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.x86_64-l= atest.err create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.xml create mode 100644 tests/qemuxml2xmloutdata/hvf-aarch64-virt-headless.xml create mode 100644 tests/qemuxml2xmloutdata/hvf-x86_64-q35-headless.xml diff --git a/tests/qemuxml2argvdata/hvf-aarch64-virt-headless.args b/tests/= qemuxml2argvdata/hvf-aarch64-virt-headless.args new file mode 100644 index 0000000000..0f1eed66c2 --- /dev/null +++ b/tests/qemuxml2argvdata/hvf-aarch64-virt-headless.args @@ -0,0 +1,48 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-aarch64 \ +-name guest=3Dtest,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-test= /master-key.aes \ +-machine virt,usb=3Doff,dump-guest-core=3Doff,gic-version=3D2 \ +-accel hvf \ +-drive file=3D/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw,if=3Dpfla= sh,format=3Draw,unit=3D0,readonly=3Don \ +-drive file=3D/var/lib/libvirt/qemu/nvram/test_VARS.fd,if=3Dpflash,format= =3Draw,unit=3D1 \ +-m 4096 \ +-realtime mlock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 1b826c23-8767-47ad-a6b5-c83a88277f71 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-test/monitor.so= ck,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc,driftfix=3Dslew \ +-no-shutdown \ +-boot strict=3Don \ +-device pcie-root-port,port=3D8,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,multif= unction=3Don,addr=3D0x1 \ +-device pcie-root-port,port=3D9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ +-device pcie-root-port,port=3D10,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr= =3D0x1.0x2 \ +-device pcie-root-port,port=3D11,chassis=3D4,id=3Dpci.4,bus=3Dpcie.0,addr= =3D0x1.0x3 \ +-device pcie-root-port,port=3D12,chassis=3D5,id=3Dpci.5,bus=3Dpcie.0,addr= =3D0x1.0x4 \ +-device pcie-root-port,port=3D13,chassis=3D6,id=3Dpci.6,bus=3Dpcie.0,addr= =3D0x1.0x5 \ +-device virtio-serial-pci,id=3Dvirtio-serial0,bus=3Dpci.2,addr=3D0x0 \ +-drive file=3D/var/lib/libvirt/images/test.qcow2,format=3Dqcow2,if=3Dnone,= id=3Ddrive-virtio-disk0 \ +-device virtio-blk-pci,bus=3Dpci.3,addr=3D0x0,drive=3Ddrive-virtio-disk0,i= d=3Dvirtio-disk0,bootindex=3D1 \ +-netdev user,id=3Dhostnet0 \ +-device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D52:54:00:9a:e6:c6= ,bus=3Dpci.1,addr=3D0x0 \ +-chardev pty,id=3Dcharserial0 \ +-serial chardev:charserial0 \ +-chardev socket,id=3Dcharchannel0,path=3D/tmp/channel/domain--1-test/org.q= emu.guest_agent.0,server=3Don,wait=3Doff \ +-device virtserialport,bus=3Dvirtio-serial0.0,nr=3D1,chardev=3Dcharchannel= 0,id=3Dchannel0,name=3Dorg.qemu.guest_agent.0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.4,addr=3D0x0 \ +-object rng-random,id=3Dobjrng0,filename=3D/dev/urandom \ +-device virtio-rng-pci,rng=3Dobjrng0,id=3Drng0,bus=3Dpci.5,addr=3D0x0 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/hvf-aarch64-virt-headless.xml b/tests/q= emuxml2argvdata/hvf-aarch64-virt-headless.xml new file mode 100644 index 0000000000..ef13820e17 --- /dev/null +++ b/tests/qemuxml2argvdata/hvf-aarch64-virt-headless.xml @@ -0,0 +1,45 @@ + + test + 1b826c23-8767-47ad-a6b5-c83a88277f71 + 4194304 + 4194304 + 2 + + hvm + /usr/share/edk2/aarch64/QEMU_= EFI-silent-pflash.raw + /var/lib/libvirt/qemu/nvram/test_VARS.fd + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + + + + + + + + + + + + + + + /dev/urandom + + + diff --git a/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.args b/tests/qe= muxml2argvdata/hvf-x86_64-q35-headless.args new file mode 100644 index 0000000000..b3358e3d59 --- /dev/null +++ b/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.args @@ -0,0 +1,47 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-test= /master-key.aes \ +-machine q35,usb=3Doff,dump-guest-core=3Doff \ +-accel hvf \ +-m 4096 \ +-realtime mlock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 1b826c23-8767-47ad-a6b5-c83a88277f71 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-test/monitor.so= ck,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc,driftfix=3Dslew \ +-no-hpet \ +-no-shutdown \ +-boot strict=3Don \ +-device pcie-root-port,port=3D8,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,multif= unction=3Don,addr=3D0x1 \ +-device pcie-root-port,port=3D9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ +-device pcie-root-port,port=3D10,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr= =3D0x1.0x2 \ +-device pcie-root-port,port=3D11,chassis=3D4,id=3Dpci.4,bus=3Dpcie.0,addr= =3D0x1.0x3 \ +-device pcie-root-port,port=3D12,chassis=3D5,id=3Dpci.5,bus=3Dpcie.0,addr= =3D0x1.0x4 \ +-device pcie-root-port,port=3D13,chassis=3D6,id=3Dpci.6,bus=3Dpcie.0,addr= =3D0x1.0x5 \ +-device virtio-serial-pci,id=3Dvirtio-serial0,bus=3Dpci.2,addr=3D0x0 \ +-drive file=3D/var/lib/libvirt/images/test.qcow2,format=3Dqcow2,if=3Dnone,= id=3Ddrive-virtio-disk0 \ +-device virtio-blk-pci,bus=3Dpci.3,addr=3D0x0,drive=3Ddrive-virtio-disk0,i= d=3Dvirtio-disk0,bootindex=3D1 \ +-netdev user,id=3Dhostnet0 \ +-device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D52:54:00:9a:e6:c6= ,bus=3Dpci.1,addr=3D0x0 \ +-chardev pty,id=3Dcharserial0 \ +-device isa-serial,chardev=3Dcharserial0,id=3Dserial0 \ +-chardev socket,id=3Dcharchannel0,path=3D/tmp/channel/domain--1-test/org.q= emu.guest_agent.0,server=3Don,wait=3Doff \ +-device virtserialport,bus=3Dvirtio-serial0.0,nr=3D1,chardev=3Dcharchannel= 0,id=3Dchannel0,name=3Dorg.qemu.guest_agent.0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.4,addr=3D0x0 \ +-object rng-random,id=3Dobjrng0,filename=3D/dev/urandom \ +-device virtio-rng-pci,rng=3Dobjrng0,id=3Drng0,bus=3Dpci.5,addr=3D0x0 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.x86_64-latest.e= rr b/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.x86_64-latest.err new file mode 100644 index 0000000000..374992ce71 --- /dev/null +++ b/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.x86_64-latest.err @@ -0,0 +1 @@ +unsupported configuration: Emulator '/usr/bin/qemu-system-x86_64' does not= support virt type 'hvf' diff --git a/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.xml b/tests/qem= uxml2argvdata/hvf-x86_64-q35-headless.xml new file mode 100644 index 0000000000..cad560e9ca --- /dev/null +++ b/tests/qemuxml2argvdata/hvf-x86_64-q35-headless.xml @@ -0,0 +1,44 @@ + + test + 1b826c23-8767-47ad-a6b5-c83a88277f71 + 4194304 + 4194304 + 2 + + hvm + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + + + + + + /dev/urandom + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6bb330e27e..0ee5802f95 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3509,6 +3509,24 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("devices-acpi-index"); =20 + DO_TEST_MACOS("hvf-x86_64-q35-headless", + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_VIRTIO_NET, + QEMU_CAPS_DEVICE_ISA_SERIAL, + QEMU_CAPS_DEVICE_VIRTIO_RNG, + QEMU_CAPS_OBJECT_RNG_RANDOM); + DO_TEST_MACOS("hvf-aarch64-virt-headless", + QEMU_CAPS_OBJECT_GPEX, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_VIRTIO_NET, + QEMU_CAPS_DEVICE_PL011, + QEMU_CAPS_DEVICE_VIRTIO_RNG, + QEMU_CAPS_OBJECT_RNG_RANDOM); + /* HVF guests should not work on Linux with KVM */ + DO_TEST_CAPS_LATEST_PARSE_ERROR("hvf-x86_64-q35-headless"); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 diff --git a/tests/qemuxml2xmloutdata/hvf-aarch64-virt-headless.xml b/tests= /qemuxml2xmloutdata/hvf-aarch64-virt-headless.xml new file mode 100644 index 0000000000..b5193a02b4 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hvf-aarch64-virt-headless.xml @@ -0,0 +1,94 @@ + + test + 1b826c23-8767-47ad-a6b5-c83a88277f71 + 4194304 + 4194304 + 2 + + hvm + /usr/share/edk2/aarch64/QEMU_= EFI-silent-pflash.raw + /var/lib/libvirt/qemu/nvram/test_VARS.fd + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + +
+ +