From nobody Mon Feb 9 12:25:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641892322; cv=none; d=zohomail.com; s=zohoarc; b=Gdze9djsjRwUFOUGKI+4o/NjaIvIKTUDlBuci058H8DLxDDwQf1OHOgWjiSy0J7eZd2B2N6cAiLQgsnz4P34HzCXROssnLHYWRfozQCgRd2w1tj5UYAB9eiuaMYLM/MwjMPwBgpZ67gvwEevSIYcfpzf2aBmiF7Asb7wOA4lg7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641892322; 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=7RaX7apN3cdMCZtAPn/59kORUG66uKSm2RTgHEsrJd4=; b=m5J8fvIvPUfPZuxR0mK+EL5ZWsHuZ/T9GMYnkEsjFwXDT9/JDsasd5mxnfAO2t1fQth08p/4B7PcdicGpvwE9auahPkLPK0/S8tqIbcCgGfrS6BOk8KVd9St4USihEuRmBOHL9kb+jcGaFKD2uy2Uh2a15OWbXJFKD6rwy2LLNM= 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 1641892322932215.4976586860206; Tue, 11 Jan 2022 01:12: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-167-bewsgALhNjyixgGphJUE_A-1; Tue, 11 Jan 2022 04:10:16 -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 25951100C67C; Tue, 11 Jan 2022 09:10:10 +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 F2C747AB43; Tue, 11 Jan 2022 09:10: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 B47D44BB7C; Tue, 11 Jan 2022 09:10:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B9A5I4029519 for ; Tue, 11 Jan 2022 04:10:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8910E6F116; Tue, 11 Jan 2022 09:10:05 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.195.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 882F36F11D; Tue, 11 Jan 2022 09:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641892322; 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=7RaX7apN3cdMCZtAPn/59kORUG66uKSm2RTgHEsrJd4=; b=SmCVvCjF7V4NyfXprlc7mXwa7th3OZlNPP26aEf8guGC5cQJ2my9glOjq2irqPXOnxMcgk I14WG7sp+eQ2zzhF0cGrFKtbp7+XLt6PZlvaB7/KyVpZUMwhNvcYzlBDImoDLjPrTNCa0h twLs1shRLAbKFCwDr8L5Zz9ZbrpyUOQ= X-MC-Unique: bewsgALhNjyixgGphJUE_A-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v5 13/20] tests: Add macOS support to testutilsqemu Date: Tue, 11 Jan 2022 10:09:33 +0100 Message-Id: <20220111090940.1315732-14-abologna@redhat.com> In-Reply-To: <20220111090940.1315732-1-abologna@redhat.com> References: <20220111090940.1315732-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: 1641892324963100001 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 Tested-by: Brad Laue --- tests/testutilsqemu.c | 58 +++++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 4 +++ 2 files changed, 62 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index a27e290c6b..e48e449f02 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, @@ -395,6 +427,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 @@ -492,6 +543,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