From nobody Mon Feb 9 03:48:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565021685; cv=none; d=zoho.com; s=zohoarc; b=lwOjcuovlmZt0K1hWtAkT/TBx7C8FFvKc9pBqp0/VwjgxXK7CJRaO7uXHsahOyGZt3vDKOurqt5ZCIHN57kGFnMj0RI//igV+vOmkCq3kee4hnovP4Jthyl0STiCs2iwAxQbaR0Fb1eA2iGaGT5i+/0cMBmiK0Hug/ygOCJIGVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YrWl7HgnEaNmixH7yiCs9mr3QGYAzNGSPNuPnLRSOHk=; b=GbfreIbXepGAaIyglbGzpoAHaBGGAgWO+/nQkk2mJW4yU9mFfTgGg0YVwc+GQrA05skIO524lnB/wjTizlKfSXIf2xYsB7AquTzqgwttAzTBXaERedlI7FtrgbwmuCxV4uHK9L+EBVqKlSWJLw+gCiLN+sAfHO04YbAZnYRfxfw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565021685336141.17185877457234; Mon, 5 Aug 2019 09:14:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 214C481DE3; Mon, 5 Aug 2019 16:14:44 +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 C146260A97; Mon, 5 Aug 2019 16:14:43 +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 4F95D180B536; Mon, 5 Aug 2019 16:14:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEfcN026351 for ; Mon, 5 Aug 2019 12:14:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id A37C1608C1; Mon, 5 Aug 2019 16:14:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23ECB60A97 for ; Mon, 5 Aug 2019 16:14:40 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:24 +0200 Message-Id: <4b00d2c78f15802c722fedee84956555cf82fab2.1565021239.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] qemufirmwaretest: Test FW path getting through qemuFirmwareGetSupported() 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Aug 2019 16:14:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There is one hack hidden here, but since this is in a test, it's okay. In order to get a list of expected firmwares in virFirmwarePtr form I'm using virFirmwareParseList(). But usually, in real life scenario, this function is used only to parse a list of UEFI images which have NVRAM split out. In other words, this function expects ${FW}:${NVRAM} pairs. But in this test, we also want to allow just a single path: ${FW} because some reported firmwares are just a BIOS image really. To avoid writing some parser function, let's just pass "NULL" as ${NVRAM} and fix the result later. Signed-off-by: Michal Privoznik --- tests/qemufirmwaretest.c | 78 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index bab23f696e..653476fdc1 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -105,6 +105,7 @@ struct supportedData { const char *machine; virArch arch; bool secure; + const char *fwlist; unsigned int *interfaces; size_t ninterfaces; }; @@ -117,15 +118,35 @@ testSupportedFW(const void *opaque) uint64_t actualInterfaces; uint64_t expectedInterfaces =3D 0; bool actualSecure; + virFirmwarePtr *expFWs =3D NULL; + size_t nexpFWs =3D 0; + virFirmwarePtr *actFWs =3D NULL; + size_t nactFWs =3D 0; size_t i; + int ret =3D -1; =20 for (i =3D 0; i < data->ninterfaces; i++) expectedInterfaces |=3D 1ULL << data->interfaces[i]; =20 + if (virFirmwareParseList(data->fwlist, &expFWs, &nexpFWs) < 0) { + fprintf(stderr, "Unable to parse list of expected FW paths\n"); + return -1; + } + + /* virFirmwareParseList() expects to see pairs of paths: ${FW}:${NVRAM= }. + * Well, some images don't have a NVRAM store. In that case NULL was p= assed: + * ${FW}:NULL. Now iterate over expected firmwares and fix this. */ + for (i =3D 0; i < nexpFWs; i++) { + virFirmwarePtr tmp =3D expFWs[i]; + + if (STREQ(tmp->nvram, "NULL")) + VIR_FREE(tmp->nvram); + } + if (qemuFirmwareGetSupported(data->machine, data->arch, false, - &actualInterfaces, &actualSecure, NULL, N= ULL) < 0) { + &actualInterfaces, &actualSecure, &actFWs= , &nactFWs) < 0) { fprintf(stderr, "Unable to get list of supported interfaces\n"); - return -1; + goto cleanup; } =20 if (actualInterfaces !=3D expectedInterfaces) { @@ -133,7 +154,7 @@ testSupportedFW(const void *opaque) "Mismatch in supported interfaces. " "Expected 0x%" PRIx64 " got 0x%" PRIx64 "\n", expectedInterfaces, actualInterfaces); - return -1; + goto cleanup; } =20 if (actualSecure !=3D data->secure) { @@ -141,10 +162,42 @@ testSupportedFW(const void *opaque) "Mismatch in SMM requirement/support. " "Expected %d got %d\n", data->secure, actualSecure); - return -1; + goto cleanup; } =20 - return 0; + for (i =3D 0; i < nactFWs; i++) { + virFirmwarePtr actFW =3D actFWs[i]; + virFirmwarePtr expFW =3D NULL; + + if (i >=3D nexpFWs) { + fprintf(stderr, "Unexpected FW image: %s NVRAM: %s\n", + actFW->name, NULLSTR(actFW->nvram)); + goto cleanup; + } + + expFW =3D expFWs[i]; + + if (STRNEQ(actFW->name, expFW->name) || + STRNEQ_NULLABLE(actFW->nvram, expFW->nvram)) { + fprintf(stderr, "Unexpected FW image: %s NVRAM: %s\n" + "Expected: %s NVRAM: %s\n", + actFW->name, NULLSTR(actFW->nvram), + expFW->name, NULLSTR(expFW->nvram)); + goto cleanup; + } + } + + if (i < nexpFWs) { + fprintf(stderr, "Expected FW image: %s NVRAM: %s got nothing\n", + expFWs[i]->name, NULLSTR(expFWs[i]->nvram)); + goto cleanup; + } + + ret =3D 0; + cleanup: + virFirmwareFreeList(actFWs, nactFWs); + virFirmwareFreeList(expFWs, nexpFWs); + return ret; } =20 =20 @@ -176,10 +229,13 @@ mymain(void) if (virTestRun("QEMU FW precedence test", testFWPrecedence, NULL) < 0) ret =3D -1; =20 -#define DO_SUPPORTED_TEST(machine, arch, secure, ...) \ + /* The @fwlist contains pairs of ${FW}:${NVRAM}. If there's + * no NVRAM expected pass literal "NULL" and test fixes that + * later. */ +#define DO_SUPPORTED_TEST(machine, arch, secure, fwlist, ...) \ do { \ unsigned int interfaces[] =3D {__VA_ARGS__}; \ - struct supportedData data =3D {machine, arch, secure, \ + struct supportedData data =3D {machine, arch, secure, fwlist, \ interfaces, ARRAY_CARDINALITY(interfa= ces)}; \ if (virTestRun("QEMU FW SUPPORTED " machine " " #arch, \ testSupportedFW, &data) < 0) \ @@ -187,16 +243,24 @@ mymain(void) } while (0) =20 DO_SUPPORTED_TEST("pc-i440fx-3.1", VIR_ARCH_X86_64, false, + "/usr/share/seabios/bios-256k.bin:NULL:" + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_V= ARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS, VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); DO_SUPPORTED_TEST("pc-i440fx-3.1", VIR_ARCH_I686, false, + "/usr/share/seabios/bios-256k.bin:NULL", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS); DO_SUPPORTED_TEST("pc-q35-3.1", VIR_ARCH_X86_64, true, + "/usr/share/seabios/bios-256k.bin:NULL:" + "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVM= F/OVMF_VARS.secboot.fd:" + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_V= ARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS, VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); DO_SUPPORTED_TEST("pc-q35-3.1", VIR_ARCH_I686, false, + "/usr/share/seabios/bios-256k.bin:NULL", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS); DO_SUPPORTED_TEST("virt-3.1", VIR_ARCH_AARCH64, false, + "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAV= MF_VARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); =20 virFileWrapperClearPrefixes(); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list