From nobody Mon Feb 9 01:49:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1576603542; cv=none; d=zohomail.com; s=zohoarc; b=dcC2Y+cbj7PlmC3HcuFD5uu6Y5HsIKJoNIDtbuUYnv7uGJKb7XDz20g6ngeWGu9ML8UleIkiY34cTmHEP3bFf9mC/nmQj0RwEw72ogFF3eKeT1d2AHJdfRk/FtUBhjbx5DR5DsCEEZzwvFTJlPvRPRVTWPNboPJevwwIQvVYsjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576603542; 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; bh=m0eAL8UgVCMd4jrHbf94ugzCaGq4tCVxq9Z8QdIRDLE=; b=OF4bg8GONJDMnyZ2SGR2ulQLv9JVrOGfkNDy2bSskstGQvyCd4F3yA3Xvj+zX8eak0UIfVD1PLLnRocrXho/F3u4ErKrzlnLVslEZrv4tdeGQ/mYkDqG8FZcWw2JT0J6mrpycl4aIB4VkG4tiKZozNRMdFPD2AdLd9E3AwUbnj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1576603542330797.3515342220594; Tue, 17 Dec 2019 09:25:42 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-_GlIIOETP6iM6YES5LvFHQ-1; Tue, 17 Dec 2019 12:25:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDBCA107ACC7; Tue, 17 Dec 2019 17:25:31 +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 C4B3B1000325; Tue, 17 Dec 2019 17:25:31 +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 81DC818089D0; Tue, 17 Dec 2019 17:25:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBHHPQo4031604 for ; Tue, 17 Dec 2019 12:25:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id BC3345C28F; Tue, 17 Dec 2019 17:25:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-155.brq.redhat.com [10.40.204.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C5725C28C for ; Tue, 17 Dec 2019 17:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576603539; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=m0eAL8UgVCMd4jrHbf94ugzCaGq4tCVxq9Z8QdIRDLE=; b=F3/qaKNgM1292XRKXqhuxwar/WlP0XxPLP56DBJKNI5GR0Vp9E/gv+39WH0nx640LwX/NV lcu6sCT4XtI/GC5g7CVfJA2CtMoW+C0DRk1eRWGZyPafxJ7Hyqe1dnp5jt3/fG5zEg6KsK TaOgbxk8ZAGPGmIG4fT5p8JOppD+++w= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 17 Dec 2019 18:25:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu_firmware: Try to autofill for old style UEFI specification 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.22 X-MC-Unique: _GlIIOETP6iM6YES5LvFHQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" While we discourage people to use the old style of specifying UEFI for their domains (the old style is putting path to the FW image under /domain/os/loader/ whilst the new one is using /domain/os/@firmware), some applications might have not adopted yet. They still rely on libvirt autofilling NVRAM path and figuring out NVRAM template when using the old way (notably virt-install does this). And in a way they are right. However, since we really want distro maintainers to leave --with-loader-nvram configure option and rely on JSON descriptors, we need to implement autofilling of NVRAM template for the old way too. Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=3D1782778 RHEL: https://bugzilla.redhat.com/show_bug.cgi?id=3D1776949 Signed-off-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 82 +++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 96058c9b45..a31bde5d04 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -935,17 +935,53 @@ qemuFirmwareMatchDomain(const virDomainDef *def, const qemuFirmware *fw, const char *path) { - size_t i; + qemuFirmwareOSInterface want =3D QEMU_FIRMWARE_OS_INTERFACE_NONE; bool supportsS3 =3D false; bool supportsS4 =3D false; bool requiresSMM =3D false; bool supportsSEV =3D false; + size_t i; + + switch (def->os.firmware) { + case VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS: + want =3D QEMU_FIRMWARE_OS_INTERFACE_BIOS; + break; + case VIR_DOMAIN_OS_DEF_FIRMWARE_EFI: + want =3D QEMU_FIRMWARE_OS_INTERFACE_UEFI; + break; + case VIR_DOMAIN_OS_DEF_FIRMWARE_NONE: + case VIR_DOMAIN_OS_DEF_FIRMWARE_LAST: + break; + } + + if (want =3D=3D QEMU_FIRMWARE_OS_INTERFACE_NONE && + def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE && + def->os.loader) { + switch (def->os.loader->type) { + case VIR_DOMAIN_LOADER_TYPE_ROM: + want =3D QEMU_FIRMWARE_OS_INTERFACE_BIOS; + break; + case VIR_DOMAIN_LOADER_TYPE_PFLASH: + want =3D QEMU_FIRMWARE_OS_INTERFACE_UEFI; + break; + case VIR_DOMAIN_LOADER_TYPE_NONE: + case VIR_DOMAIN_LOADER_TYPE_LAST: + break; + } + + if (fw->mapping.device !=3D QEMU_FIRMWARE_DEVICE_FLASH || + STRNEQ(def->os.loader->path, fw->mapping.data.flash.executable= .filename)) { + VIR_DEBUG("Not matching FW interface %s or loader " + "path '%s' for user provided path '%s'", + qemuFirmwareDeviceTypeToString(fw->mapping.device), + fw->mapping.data.flash.executable.filename, + def->os.loader->path); + return false; + } + } =20 for (i =3D 0; i < fw->ninterfaces; i++) { - if ((def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS && - fw->interfaces[i] =3D=3D QEMU_FIRMWARE_OS_INTERFACE_BIOS) || - (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_EFI && - fw->interfaces[i] =3D=3D QEMU_FIRMWARE_OS_INTERFACE_UEFI)) + if (fw->interfaces[i] =3D=3D want) break; } =20 @@ -1211,14 +1247,33 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, qemuFirmwarePtr *firmwares =3D NULL; ssize_t nfirmwares =3D 0; const qemuFirmware *theone =3D NULL; + bool needResult =3D true; size_t i; int ret =3D -1; =20 if (!(flags & VIR_QEMU_PROCESS_START_NEW)) return 0; =20 - if (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) - return 0; + /* Fill in FW paths if either os.firmware is enabled, or + * loader path was provided with no nvram varstore. */ + if (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) { + /* This is horrific check, but loosely said, if UEFI + * image was provided by the old method (by specifying + * its path in domain XML) but no template for NVRAM was + * specified ... */ + if (!(def->os.loader && + def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH && + def->os.loader->path && + def->os.loader->readonly =3D=3D VIR_TRISTATE_BOOL_YES && + !def->os.loader->templt && + def->os.loader->nvram && + !virFileExists(def->os.loader->nvram))) + return 0; + + /* ... then we want to consult JSON FW descriptors first, + * but we don't want to fail if we haven't found a match. */ + needResult =3D false; + } =20 if ((nfirmwares =3D qemuFirmwareFetchParsedConfigs(driver->privileged, &firmwares, &paths)) = < 0) @@ -1234,9 +1289,16 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, } =20 if (!theone) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to find any firmware to satisfy '%s'"), - virDomainOsDefFirmwareTypeToString(def->os.firmware= )); + if (needResult) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to find any firmware to satisfy '%s'"= ), + virDomainOsDefFirmwareTypeToString(def->os.firm= ware)); + } else { + VIR_DEBUG("Unable to find NVRAM template for '%s', " + "falling back to old style", + NULLSTR(def->os.loader ? def->os.loader->path : NULL= )); + ret =3D 0; + } goto cleanup; } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list