From nobody Mon Feb 9 03:13:48 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=1641892220; cv=none; d=zohomail.com; s=zohoarc; b=PCIw94Q7xf1wjxMpDwzY8NkJcO3YPYdKo7XQGBUYqqgRMzgXN1XXNq3gVuVqyX8foIbhnnPMzGzWarr2Z59l2ueXwgux2G457ECNNOjUGOifyZbWXkZ37QLp99qHyrCXIWwTy1v8EwGPomM9U/72reBDM7CZt0MuTStUl5sXXnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641892220; 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=ER+uLqCL7szWWb6i/wa0P8NP11ylzFDnd7yIh/sgr/8=; b=nA7vqwUFTrzLuu4TWc7NvThFoFxu9Ev9yMJeMRGHDoQrQzUT2nbs3VVw08HzFuDcrDZ1ntwN31NhxCJ+a/KED/WJzB7FMBrQbGPX/EYYfuE7agNPxpLRvIF4+CVaqKEUAqgTL2DMBzenGKYJ/KUc8XtAZPgIOfw2UCE7AOwS908= 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 1641892220381960.2641451432092; Tue, 11 Jan 2022 01:10: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-470-zLkwyfUNNLi2HmA0Mc5wCQ-1; Tue, 11 Jan 2022 04:10:17 -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 B350F189DF61; Tue, 11 Jan 2022 09:10:09 +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 8D5F51F300; 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 2AB074BB7C; Tue, 11 Jan 2022 09:10:08 +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 20B9A7L1029531 for ; Tue, 11 Jan 2022 04:10:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 135A96F116; Tue, 11 Jan 2022 09:10:07 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.40.195.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FB236F119; Tue, 11 Jan 2022 09:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641892219; 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=ER+uLqCL7szWWb6i/wa0P8NP11ylzFDnd7yIh/sgr/8=; b=dNezQYMDOTsWjq91R8F3kBLu00Qf0Xg2cQIeZAxgswyAgDK5oOsJnvUhtLxp4UhL6G+gbC smRVDk96y57kT6WZAoJn29bvbLNF9jMbfQ2yWI1mtxMd2y5TuGhHsYYB9rhM2H7kzH6jTY R9Mf8LU+4AeGy+r9Tryv5bHsxTQyS0k= X-MC-Unique: zLkwyfUNNLi2HmA0Mc5wCQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v5 14/20] tests: Add macOS support to qemuxml2*test Date: Tue, 11 Jan 2022 10:09:34 +0100 Message-Id: <20220111090940.1315732-15-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.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: 1641892222645100001 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 Tested-by: Brad Laue --- 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..b10850dcce 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: this allows us to later + * pick the appropriate 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..ca351a339a 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: this allows us to later + * pick the appropriate 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 e48e449f02..a77d1e6fe6 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -870,6 +870,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