From nobody Sat May 11 11:28:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709288959658519.394932854767; Fri, 1 Mar 2024 02:29:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9BAED1C23; Fri, 1 Mar 2024 05:29:18 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B06911BF6; Fri, 1 Mar 2024 05:26:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C37961A5C; Fri, 1 Mar 2024 05:26:11 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E8EE71A4C for ; Fri, 1 Mar 2024 05:26:10 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-_SQDIhvGPVSQzr3hxTeGGw-1; Fri, 01 Mar 2024 05:26:08 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC7E629AB3E1 for ; Fri, 1 Mar 2024 10:26:07 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.224.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 62BBFC0348C for ; Fri, 1 Mar 2024 10:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: _SQDIhvGPVSQzr3hxTeGGw-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 1/5] qemu: Add missing early returns Date: Fri, 1 Mar 2024 11:26:01 +0100 Message-ID: <20240301102605.2579973-2-abologna@redhat.com> In-Reply-To: <20240301102605.2579973-1-abologna@redhat.com> References: <20240301102605.2579973-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OVDDXC5P3XVROAIUE4MGVVBVEKZSJEFK X-Message-ID-Hash: OVDDXC5P3XVROAIUE4MGVVBVEKZSJEFK X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709288960469100001 In a couple of cases, we were reporting an error without actually terminating the parse process. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index d39e61d071..3fd4f75778 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -439,6 +439,7 @@ qemuFirmwareMappingKernelParse(const char *path, virReportError(VIR_ERR_INTERNAL_ERROR, _("missing 'filename' in '%1$s'"), path); + return -1; } =20 kernel->filename =3D g_strdup(filename); @@ -458,6 +459,7 @@ qemuFirmwareMappingMemoryParse(const char *path, virReportError(VIR_ERR_INTERNAL_ERROR, _("missing 'filename' in '%1$s'"), path); + return -1; } =20 memory->filename =3D g_strdup(filename); --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 11:28:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709289056679146.35627202318915; Fri, 1 Mar 2024 02:30:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9E7C818EF; Fri, 1 Mar 2024 05:30:55 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D92451A5E; Fri, 1 Mar 2024 05:26:30 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C85CA1A4C; Fri, 1 Mar 2024 05:26:11 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 611BB1A15 for ; Fri, 1 Mar 2024 05:26:10 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-ZXx-859EP9KUn7XaP0ZuOA-1; Fri, 01 Mar 2024 05:26:08 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 818871C05EAF for ; Fri, 1 Mar 2024 10:26:08 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.224.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 189C1C03488 for ; Fri, 1 Mar 2024 10:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: ZXx-859EP9KUn7XaP0ZuOA-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 2/5] qemu: Rewrite qemuFirmwareFetchParsedConfigs() Date: Fri, 1 Mar 2024 11:26:02 +0100 Message-ID: <20240301102605.2579973-3-abologna@redhat.com> In-Reply-To: <20240301102605.2579973-1-abologna@redhat.com> References: <20240301102605.2579973-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CFECI427HTDVWFV2ALT6LV3YWENCZAWX X-Message-ID-Hash: CFECI427HTDVWFV2ALT6LV3YWENCZAWX X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709289056955100001 Instead of returning the list of paths exactly as obtained from qemuFirmwareFetchConfigs(), and allocating the list of firmwares to be exactly that size right away, start with two empty lists and add elements to them one by one. At the moment this only makes things more verbose, but later we're going to change things so that it's possible that some of the paths/firmwares are not included in the lists returned to the caller, and at that point the changes will pay off. Note that we can't use g_auto() for the new list of paths, because until the very last moment it's not null-terminated, so g_strfreev() wouldn't be able to handle it correctly. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 46 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 3fd4f75778..4fc7dd3b71 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1562,35 +1562,49 @@ qemuFirmwareFetchParsedConfigs(bool privileged, qemuFirmware ***firmwaresRet, char ***pathsRet) { - g_auto(GStrv) paths =3D NULL; - size_t npaths; + g_auto(GStrv) possiblePaths =3D NULL; + char **currentPath =3D NULL; qemuFirmware **firmwares =3D NULL; - size_t i; + char **paths =3D NULL; + size_t nfirmwares =3D 0; + size_t npaths =3D 0; =20 - if (qemuFirmwareFetchConfigs(&paths, privileged) < 0) + if (qemuFirmwareFetchConfigs(&possiblePaths, privileged) < 0) return -1; =20 - if (!paths) + if (!possiblePaths) return 0; =20 - npaths =3D g_strv_length(paths); + for (currentPath =3D possiblePaths; *currentPath; currentPath++) { + qemuFirmware *firmware =3D qemuFirmwareParse(*currentPath); =20 - firmwares =3D g_new0(qemuFirmware *, npaths); - - for (i =3D 0; i < npaths; i++) { - if (!(firmwares[i] =3D qemuFirmwareParse(paths[i]))) + if (!firmware) goto error; + + VIR_APPEND_ELEMENT(firmwares, nfirmwares, firmware); + + if (pathsRet) { + char *path =3D g_strdup(*currentPath); + VIR_APPEND_ELEMENT(paths, npaths, path); + } + } + + *firmwaresRet =3D firmwares; + if (pathsRet) { + char *terminator =3D NULL; + VIR_APPEND_ELEMENT(paths, npaths, terminator); + *pathsRet =3D paths; } =20 - *firmwaresRet =3D g_steal_pointer(&firmwares); - if (pathsRet) - *pathsRet =3D g_steal_pointer(&paths); - return npaths; + return nfirmwares; =20 error: - while (i > 0) - qemuFirmwareFree(firmwares[--i]); + while (nfirmwares > 0) + qemuFirmwareFree(firmwares[--nfirmwares]); VIR_FREE(firmwares); + while (npaths > 0) + VIR_FREE(paths[--npaths]); + VIR_FREE(paths); return -1; } =20 --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 11:28:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709289277517815.4808535092213; Fri, 1 Mar 2024 02:34:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6CD991958; Fri, 1 Mar 2024 05:34:36 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3DA3A1E1A; Fri, 1 Mar 2024 05:26:51 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2038C1A4C; Fri, 1 Mar 2024 05:26:14 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2662B1A56 for ; Fri, 1 Mar 2024 05:26:11 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-U39dYACHMHaImHnbb9zxmQ-1; Fri, 01 Mar 2024 05:26:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38789185A781 for ; Fri, 1 Mar 2024 10:26:09 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.224.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2FD9C03488 for ; Fri, 1 Mar 2024 10:26:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: U39dYACHMHaImHnbb9zxmQ-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 3/5] qemu: Make firmware parsing failures non-fatal Date: Fri, 1 Mar 2024 11:26:03 +0100 Message-ID: <20240301102605.2579973-4-abologna@redhat.com> In-Reply-To: <20240301102605.2579973-1-abologna@redhat.com> References: <20240301102605.2579973-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3LORZQLPY6TIYJEUEMRFAA4PAL2QF46G X-Message-ID-Hash: 3LORZQLPY6TIYJEUEMRFAA4PAL2QF46G X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709289277986100001 At the moment, any kind of issue being detected in any of the firmware descriptor files will result in the entire process being aborted. In particular, installing a build of edk2 for an architecture that libvirt doesn't yet know about, for example loongarch64, will break most firmware-related functionality: it will no longer be possible to define new EFI VMs, start existing ones, or even just obtain the domcapabilities for any architecture. This is obviously unnecessarily harsh. Adopt a more relaxed approach and simply ignore the firmware descriptors that we are unable to parse correctly. https://bugzilla.redhat.com/show_bug.cgi?id=3D2258946 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 86 ++++++++++------------------------------ 1 file changed, 20 insertions(+), 66 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 4fc7dd3b71..78844e3066 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -307,9 +307,7 @@ qemuFirmwareInterfaceParse(const char *path, size_t i; =20 if (!(interfacesJSON =3D virJSONValueObjectGetArray(doc, "interface-ty= pes"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to get interface-types from '%1$s'"), - path); + VIR_DEBUG("failed to get interface-types from '%s'", path); return -1; } =20 @@ -323,9 +321,7 @@ qemuFirmwareInterfaceParse(const char *path, int tmp; =20 if ((tmp =3D qemuFirmwareOSInterfaceTypeFromString(tmpStr)) <=3D 0= ) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown interface type: '%1$s'"), - tmpStr); + VIR_DEBUG("unknown interface type: '%s'", tmpStr); return -1; } =20 @@ -351,18 +347,14 @@ qemuFirmwareFlashFileParse(const char *path, const char *format; =20 if (!(filename =3D virJSONValueObjectGetString(doc, "filename"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'filename' in '%1$s'"), - path); + VIR_DEBUG("missing 'filename' in '%s'", path); return -1; } =20 flash->filename =3D g_strdup(filename); =20 if (!(format =3D virJSONValueObjectGetString(doc, "format"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'format' in '%1$s'"), - path); + VIR_DEBUG("missing 'format' in '%s'", path); return -1; } =20 @@ -388,24 +380,19 @@ qemuFirmwareMappingFlashParse(const char *path, const char *modestr =3D virJSONValueGetString(mode); int modeval; if (!modestr) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Firmware flash mode value was malformed")); + VIR_DEBUG("Firmware flash mode value was malformed"); return -1; } modeval =3D qemuFirmwareFlashModeTypeFromString(modestr); if (modeval < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Firmware flash mode value '%1$s' unexpected"= ), - modestr); + VIR_DEBUG("Firmware flash mode value '%s' unexpected", modestr= ); return -1; } flash->mode =3D modeval; } =20 if (!(executable =3D virJSONValueObjectGet(doc, "executable"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'executable' in '%1$s'"), - path); + VIR_DEBUG("missing 'executable' in '%s'", path); return -1; } =20 @@ -414,9 +401,7 @@ qemuFirmwareMappingFlashParse(const char *path, =20 if (flash->mode =3D=3D QEMU_FIRMWARE_FLASH_MODE_SPLIT) { if (!(nvram_template =3D virJSONValueObjectGet(doc, "nvram-templat= e"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'nvram-template' in '%1$s'"), - path); + VIR_DEBUG("missing 'nvram-template' in '%s'", path); return -1; } =20 @@ -436,9 +421,7 @@ qemuFirmwareMappingKernelParse(const char *path, const char *filename; =20 if (!(filename =3D virJSONValueObjectGetString(doc, "filename"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'filename' in '%1$s'"), - path); + VIR_DEBUG("missing 'filename' in '%s'", path); return -1; } =20 @@ -456,9 +439,7 @@ qemuFirmwareMappingMemoryParse(const char *path, const char *filename; =20 if (!(filename =3D virJSONValueObjectGetString(doc, "filename"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'filename' in '%1$s'"), - path); + VIR_DEBUG("missing 'filename' in '%s'", path); return -1; } =20 @@ -478,23 +459,17 @@ qemuFirmwareMappingParse(const char *path, int tmp; =20 if (!(mapping =3D virJSONValueObjectGet(doc, "mapping"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing mapping in '%1$s'"), - path); + VIR_DEBUG("missing mapping in '%s'", path); return -1; } =20 if (!(deviceStr =3D virJSONValueObjectGetString(mapping, "device"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing device type in '%1$s'"), - path); + VIR_DEBUG("missing device type in '%s'", path); return -1; } =20 if ((tmp =3D qemuFirmwareDeviceTypeFromString(deviceStr)) <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown device type in '%1$s'"), - path); + VIR_DEBUG("unknown device type in '%s'", path); return -1; } =20 @@ -535,9 +510,7 @@ qemuFirmwareTargetParse(const char *path, int ret =3D -1; =20 if (!(targetsJSON =3D virJSONValueObjectGetArray(doc, "targets"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to get targets from '%1$s'"), - path); + VIR_DEBUG("failed to get targets from '%s'", path); return -1; } =20 @@ -556,23 +529,17 @@ qemuFirmwareTargetParse(const char *path, t =3D g_new0(qemuFirmwareTarget, 1); =20 if (!(architectureStr =3D virJSONValueObjectGetString(item, "archi= tecture"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'architecture' in '%1$s'"), - path); + VIR_DEBUG("missing 'architecture' in '%s'", path); goto cleanup; } =20 if ((t->architecture =3D virQEMUCapsArchFromString(architectureStr= )) =3D=3D VIR_ARCH_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown architecture '%1$s'"), - architectureStr); + VIR_DEBUG("unknown architecture '%s'", architectureStr); goto cleanup; } =20 if (!(machines =3D virJSONValueObjectGetArray(item, "machines"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'machines' in '%1$s'"), - path); + VIR_DEBUG("missing 'machines' in '%s'", path); goto cleanup; } =20 @@ -617,9 +584,7 @@ qemuFirmwareFeatureParse(const char *path, size_t i; =20 if (!(featuresJSON =3D virJSONValueObjectGetArray(doc, "features"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to get features from '%1$s'"), - path); + VIR_DEBUG("failed to get features from '%s'", path); return -1; } =20 @@ -661,9 +626,7 @@ qemuFirmwareParse(const char *path) return NULL; =20 if (!(doc =3D virJSONValueFromString(cont))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to parse json file '%1$s'"), - path); + VIR_DEBUG("unable to parse json file '%s'", path); return NULL; } =20 @@ -1579,7 +1542,7 @@ qemuFirmwareFetchParsedConfigs(bool privileged, qemuFirmware *firmware =3D qemuFirmwareParse(*currentPath); =20 if (!firmware) - goto error; + continue; =20 VIR_APPEND_ELEMENT(firmwares, nfirmwares, firmware); =20 @@ -1597,15 +1560,6 @@ qemuFirmwareFetchParsedConfigs(bool privileged, } =20 return nfirmwares; - - error: - while (nfirmwares > 0) - qemuFirmwareFree(firmwares[--nfirmwares]); - VIR_FREE(firmwares); - while (npaths > 0) - VIR_FREE(paths[--npaths]); - VIR_FREE(paths); - return -1; } =20 =20 --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 11:28:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17092890814151020.2395382146623; Fri, 1 Mar 2024 02:31:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 598ED1BEE; Fri, 1 Mar 2024 05:31:20 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4D62C1DC6; Fri, 1 Mar 2024 05:26:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id AD3B11A5F; Fri, 1 Mar 2024 05:26:13 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E63301A53 for ; Fri, 1 Mar 2024 05:26:11 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-_qEzxSwXNXKQPUQ8UT4_lg-1; Fri, 01 Mar 2024 05:26:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E29171C0515C for ; Fri, 1 Mar 2024 10:26:09 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.224.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 797A9C185C3 for ; Fri, 1 Mar 2024 10:26:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: _qEzxSwXNXKQPUQ8UT4_lg-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 4/5] tests: Add firmware descriptor for edk2 on loongarch64 Date: Fri, 1 Mar 2024 11:26:04 +0100 Message-ID: <20240301102605.2579973-5-abologna@redhat.com> In-Reply-To: <20240301102605.2579973-1-abologna@redhat.com> References: <20240301102605.2579973-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: ZBS53BPTHFCO57W2SQNB5P2LVRLTERDJ X-Message-ID-Hash: ZBS53BPTHFCO57W2SQNB5P2LVRLTERDJ X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709289083068100001 This fails to be parsed because libvirt doesn't yet know about the architecture, but thanks to the recent improvements this is a merely a local failure rather than bringing everything else down with it. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- .../qemu/firmware/50-edk2-loongarch64.json | 29 +++++++++++++++++++ tests/qemufirmwaretest.c | 26 +++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/50-edk2-= loongarch64.json diff --git a/tests/qemufirmwaredata/usr/share/qemu/firmware/50-edk2-loongar= ch64.json b/tests/qemufirmwaredata/usr/share/qemu/firmware/50-edk2-loongarc= h64.json new file mode 100644 index 0000000000..8251137ba9 --- /dev/null +++ b/tests/qemufirmwaredata/usr/share/qemu/firmware/50-edk2-loongarch64.js= on @@ -0,0 +1,29 @@ +{ + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode": "split", + "executable": { + "filename": "/usr/share/edk2/loongarch64/QEMU_EFI.fd", + "format": "raw" + }, + "nvram-template": { + "filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd", + "format": "raw" + } + }, + "targets": [ + { + "architecture": "loongarch64", + "machines": [ + "virt", + "virt-*" + ] + } + ], + "features": [ + "acpi" + ] +} diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 7596c746ab..3a3aedb1c7 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -61,6 +61,23 @@ testParseFormatFW(const void *opaque) } =20 =20 +static int +testParseFailureFW(const void *opaque) +{ + const char *filename =3D opaque; + g_autofree char *inpath =3D NULL; + + inpath =3D g_strdup_printf("%s/qemufirmwaredata/%s", abs_srcdir, filen= ame); + + /* This is a negative test case, so if the file was parsed + * successfully we need to report a failure */ + if (qemuFirmwareParse(inpath)) + return -1; + + return 0; +} + + static int testFWPrecedence(const void *opaque G_GNUC_UNUSED) { @@ -73,6 +90,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED) PREFIX "/share/qemu/firmware/40-edk2-ovmf-4m-qcow2-x64-sb.json", PREFIX "/share/qemu/firmware/41-edk2-ovmf-2m-raw-x64-sb.json", PREFIX "/share/qemu/firmware/50-edk2-aarch64-qcow2.json", + PREFIX "/share/qemu/firmware/50-edk2-loongarch64.json", PREFIX "/share/qemu/firmware/50-edk2-ovmf-4m-qcow2-x64-nosb.json", PREFIX "/share/qemu/firmware/50-edk2-ovmf-x64-microvm.json", PREFIX "/share/qemu/firmware/51-edk2-aarch64-raw.json", @@ -238,11 +256,19 @@ mymain(void) ret =3D -1; \ } while (0) =20 +#define DO_PARSE_FAILURE_TEST(filename) \ + do { \ + if (virTestRun("QEMU FW FAILURE " filename, \ + testParseFailureFW, filename) < 0) \ + ret =3D -1; \ + } while (0) + DO_PARSE_TEST("usr/share/qemu/firmware/30-edk2-ovmf-4m-qcow2-x64-sb-en= rolled.json"); DO_PARSE_TEST("usr/share/qemu/firmware/31-edk2-ovmf-2m-raw-x64-sb-enro= lled.json"); DO_PARSE_TEST("usr/share/qemu/firmware/40-edk2-ovmf-4m-qcow2-x64-sb.js= on"); DO_PARSE_TEST("usr/share/qemu/firmware/41-edk2-ovmf-2m-raw-x64-sb.json= "); DO_PARSE_TEST("usr/share/qemu/firmware/50-edk2-aarch64-qcow2.json"); + DO_PARSE_FAILURE_TEST("usr/share/qemu/firmware/50-edk2-loongarch64.jso= n"); DO_PARSE_TEST("usr/share/qemu/firmware/50-edk2-ovmf-4m-qcow2-x64-nosb.= json"); DO_PARSE_TEST("usr/share/qemu/firmware/50-edk2-ovmf-x64-microvm.json"); DO_PARSE_TEST("usr/share/qemu/firmware/51-edk2-aarch64-raw.json"); --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 11:28:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 170928938992413.598850795251906; Fri, 1 Mar 2024 02:36:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C41261C5B; Fri, 1 Mar 2024 05:36:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 164861E57; Fri, 1 Mar 2024 05:27:02 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C3C21A4C; Fri, 1 Mar 2024 05:26:14 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 832D81A15 for ; Fri, 1 Mar 2024 05:26:12 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-HvLCKSzXPaqC2L3nuwjtJg-1; Fri, 01 Mar 2024 05:26:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 98D6A890FC3 for ; Fri, 1 Mar 2024 10:26:10 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.224.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F95FC0348C for ; Fri, 1 Mar 2024 10:26:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: HvLCKSzXPaqC2L3nuwjtJg-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 5/5] tests: Add invalid firmware descriptor Date: Fri, 1 Mar 2024 11:26:05 +0100 Message-ID: <20240301102605.2579973-6-abologna@redhat.com> In-Reply-To: <20240301102605.2579973-1-abologna@redhat.com> References: <20240301102605.2579973-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: PDOBHWQ7JSJ32SAJ3L4BZJGDF3VRYHDD X-Message-ID-Hash: PDOBHWQ7JSJ32SAJ3L4BZJGDF3VRYHDD X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709289391409100001 This is guaranteed to keep failing even after loongarch64 support is introduced. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- .../qemufirmwaredata/usr/share/qemu/firmware/93-invalid.json | 5 +++++ tests/qemufirmwaretest.c | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/93-inval= id.json diff --git a/tests/qemufirmwaredata/usr/share/qemu/firmware/93-invalid.json= b/tests/qemufirmwaredata/usr/share/qemu/firmware/93-invalid.json new file mode 100644 index 0000000000..5e75b9a41a --- /dev/null +++ b/tests/qemufirmwaredata/usr/share/qemu/firmware/93-invalid.json @@ -0,0 +1,5 @@ +{ + "firmware": { + "invalid": true + } +} diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 3a3aedb1c7..1b5baf5c5e 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -102,6 +102,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED) PREFIX "/share/qemu/firmware/60-edk2-ovmf-x64-inteltdx.json", PREFIX "/share/qemu/firmware/90-combined.json", PREFIX "/share/qemu/firmware/91-bios.json", + PREFIX "/share/qemu/firmware/93-invalid.json", NULL }; const char **e; @@ -279,6 +280,7 @@ mymain(void) DO_PARSE_TEST("usr/share/qemu/firmware/60-edk2-ovmf-x64-inteltdx.json"= ); DO_PARSE_TEST("usr/share/qemu/firmware/90-combined.json"); DO_PARSE_TEST("usr/share/qemu/firmware/91-bios.json"); + DO_PARSE_FAILURE_TEST("usr/share/qemu/firmware/93-invalid.json"); =20 if (virTestRun("QEMU FW precedence test", testFWPrecedence, NULL) < 0) ret =3D -1; --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org