From nobody Tue Feb 10 12:58:18 2026 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=1642416830; cv=none; d=zohomail.com; s=zohoarc; b=EbpMi8JzoryqpNX9c9AcKLapYG8JQxRoNEXT1SdC9FEbogQFqvoznjzXHIMaxnqk67L0bRcxd5yHq78ivZ5sR/D7+RuRF4fTha2+e7ys7S1sxSrGUsL255H7hFADJFp4BFN+teEQ75nYHfrFmz1FWxZUA5AN2qCYmdChSFOyUUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642416830; 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=Djm02tzXTTQSotVBqz4JanzAKpyXx4Ry6sGrCF7j1/U=; b=MUtwNQpOjBvzM46TvvYVFCHxIJGYuHNZKDE1+oBrO8NjNJTfkU4fQfCkbm8awu8yjEtTNO9Xb4ya1a1EgdKq+H7QhG4HB/soMBOFaekZySeAseLrcOi5L/tZhGtIynl3GQ6qcxOJxQVIWBSLIM27BYFbqhGEplhofEFdr4iO0cg= 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 1642416830278665.6909929105784; Mon, 17 Jan 2022 02:53:50 -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-132-83BvGSccMzGYYm7dH28U8g-1; Mon, 17 Jan 2022 05:53:45 -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 0D42D100CCC3; Mon, 17 Jan 2022 10:53:41 +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 DC35870D4C; Mon, 17 Jan 2022 10:53:40 +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 A62571809CBA; Mon, 17 Jan 2022 10:53:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HArMNM009113 for ; Mon, 17 Jan 2022 05:53:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 554501059A79; Mon, 17 Jan 2022 10:53:22 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.194.229]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8696F1059596; Mon, 17 Jan 2022 10:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642416829; 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=Djm02tzXTTQSotVBqz4JanzAKpyXx4Ry6sGrCF7j1/U=; b=SVUrIx1uQLlCA2hDf6cvzy6/MiPP63xfcdra/2LeN3leffNLXe9928FfTx/w0eADeENEZc 18T5Hc2Uy7n11tjVpYi+zK16EuNZtLHT5FpwBjf2nHA5a8FcOAdQFuhKqgayKXjQKTDdom mRTPqE5rU9EnCuwYBJFLb5agACItxms= X-MC-Unique: 83BvGSccMzGYYm7dH28U8g-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 12/20] tests: Introduce testQemuHostOS Date: Mon, 17 Jan 2022 11:52:52 +0100 Message-Id: <20220117105300.15759-13-abologna@redhat.com> In-Reply-To: <20220117105300.15759-1-abologna@redhat.com> References: <20220117105300.15759-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1642416832572100001 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 Tested-by: Brad Laue --- tests/testutilsqemu.c | 86 +++++++++++++++++++++++++++---------------- tests/testutilsqemu.h | 4 ++ 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index cb665e501b..a27e290c6b 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, @@ -338,7 +348,8 @@ void qemuTestDriverFree(virQEMUDriver *driver) =20 static void qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps, - virArch arch) + virArch arch, + testQemuHostOS hostOS) { size_t i; const char *defaultRAMid =3D NULL; @@ -366,20 +377,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 +412,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 +440,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 +475,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 +485,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.34.1