From nobody Tue Feb 10 01:31:29 2026 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 --- 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