From nobody Sat May 4 04:36:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1576603573; cv=none; d=zohomail.com; s=zohoarc; b=EMzyPzAFj3H97GNF68fAr1QuFR0cheXJohhlh5ipsw/rw7xSig3fmtf2wiKQMksdU4ITXahc+LbiYr0T8B+5S06iCanyNRYCQMosCGJOGPfLPAYYuvIq2XCGU2cLui9dEmLkQH8lhgugBoCJobHBzWpFA5GE2dnr0WREwymf97w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576603573; 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=k3rr+HJHpdSzcTxl9Us4N0dkd3WkHcvrwjGAHXQUwzM=; b=AWC6a8zzuB9AV6t4M8aWzM36uuD1ajuRtHtxT6sE2eqLlBNv+67vD5oHlL3OmBt9tuIZEVfTPL8/ttxFuuZ5A9vFKhxXMnyPoYi9dz8nNT8QeAMwRlfnI2+lOCtIL77xPphlWyk/egc8Xi7R5Pq4F7YVz2AVrQMtIOYrJp+h1Co= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576603573948865.2787275937877; Tue, 17 Dec 2019 09:26:13 -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-277-bL-4Q4GFP4GAeN5jV1ZGEQ-1; Tue, 17 Dec 2019 12:26:11 -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 6531E800C75; Tue, 17 Dec 2019 17:26:05 +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 A156C10018FF; Tue, 17 Dec 2019 17:26:04 +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 B5C04104906; Tue, 17 Dec 2019 17:26:03 +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 xBHHPPcx031597 for ; Tue, 17 Dec 2019 12:25:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD5095C28F; Tue, 17 Dec 2019 17:25:25 +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 5EBCE5C28C for ; Tue, 17 Dec 2019 17:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576603572; 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=k3rr+HJHpdSzcTxl9Us4N0dkd3WkHcvrwjGAHXQUwzM=; b=TtV8qTGVOLmPklGwZYNjsVGY43sl2WYnwCplmyQ9DXZePw91zzuPD5FF7Ep9l+UOenpwk3 jhP/iYzilxONA3AZqsDbkvYRsDTcE2+M0pbZrQIQGmy1nPo2bp2n6DYNmebuopXkymWrFy BHs++M07o95l9T1kgQnh6JzVNO/7kKs= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 17 Dec 2019 18:25:19 +0100 Message-Id: <565e183bfb6cf523b491affa6c2f7cbd385c00e8.1576603498.git.mprivozn@redhat.com> 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 1/2] qemu_firmware: Pass virDomainDef into qemuFirmwareFillDomain() 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: bL-4Q4GFP4GAeN5jV1ZGEQ-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" This function needs domain definition really, we don't need to pass the whole domain object. This saves couple of dereferences and characters esp. in more checks to come. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/qemu/qemu_firmware.c | 12 ++++++------ src/qemu/qemu_firmware.h | 2 +- src/qemu/qemu_process.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index f62ce90ac9..96058c9b45 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1204,7 +1204,7 @@ qemuFirmwareFetchParsedConfigs(bool privileged, =20 int qemuFirmwareFillDomain(virQEMUDriverPtr driver, - virDomainObjPtr vm, + virDomainDefPtr def, unsigned int flags) { VIR_AUTOSTRINGLIST paths =3D NULL; @@ -1217,7 +1217,7 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, if (!(flags & VIR_QEMU_PROCESS_START_NEW)) return 0; =20 - if (vm->def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) + if (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) return 0; =20 if ((nfirmwares =3D qemuFirmwareFetchParsedConfigs(driver->privileged, @@ -1225,7 +1225,7 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, return -1; =20 for (i =3D 0; i < nfirmwares; i++) { - if (qemuFirmwareMatchDomain(vm->def, firmwares[i], paths[i])) { + if (qemuFirmwareMatchDomain(def, firmwares[i], paths[i])) { theone =3D firmwares[i]; VIR_DEBUG("Found matching firmware (description path '%s')", paths[i]); @@ -1236,7 +1236,7 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, if (!theone) { virReportError(VIR_ERR_OPERATION_FAILED, _("Unable to find any firmware to satisfy '%s'"), - virDomainOsDefFirmwareTypeToString(vm->def->os.firm= ware)); + virDomainOsDefFirmwareTypeToString(def->os.firmware= )); goto cleanup; } =20 @@ -1245,10 +1245,10 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, * likely that admin/FW manufacturer messed up. */ qemuFirmwareSanityCheck(theone, paths[i]); =20 - if (qemuFirmwareEnableFeatures(driver, vm->def, theone) < 0) + if (qemuFirmwareEnableFeatures(driver, def, theone) < 0) goto cleanup; =20 - vm->def->os.firmware =3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE; + def->os.firmware =3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE; =20 ret =3D 0; cleanup: diff --git a/src/qemu/qemu_firmware.h b/src/qemu/qemu_firmware.h index 4be65bc664..37cbfae39d 100644 --- a/src/qemu/qemu_firmware.h +++ b/src/qemu/qemu_firmware.h @@ -45,7 +45,7 @@ qemuFirmwareFetchConfigs(char ***firmwares, =20 int qemuFirmwareFillDomain(virQEMUDriverPtr driver, - virDomainObjPtr vm, + virDomainDefPtr def, unsigned int flags); =20 int diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7e1db50e8f..6d4511a49f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6344,7 +6344,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, goto cleanup; =20 VIR_DEBUG("Prepare bios/uefi paths"); - if (qemuFirmwareFillDomain(driver, vm, flags) < 0) + if (qemuFirmwareFillDomain(driver, vm->def, flags) < 0) goto cleanup; if (qemuDomainInitializePflashStorageSource(vm) < 0) goto cleanup; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:36:28 2024 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