From nobody Wed May 1 23:57:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1578404625; cv=none; d=zohomail.com; s=zohoarc; b=S5Qn2LiZAbKztU2Xskmf6r/Cx200aIjrhLFrMfbYOIC+jVnOKQFPqNakWNFw9ayUq4kTzHNDeZcZ7n0AntEH9IXIXBeDPZZhEkXPbprIstZ21MS6j//lwI4TqEzkg/5AqpSxO48abEzamgH59vGOxU8TUJ8W9rHPq9gLaMwtoEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578404625; 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=AGiGApiwxDTpmNnhyWbQoxyVYzpn5WNkA2R67R1Gdw4=; b=kcPq6e7jGSBaOQ00+4xpbbpTi+lA78yBOU9XeKuWcrIQywUuum7a3E8UjSbI0h6cuIdvpOfQ6dRalOk/uBIctj5wSILI/DbJ5aARs2+dL8K3sYq8pL1wFGRqK1IM9ZEI80t/DvWFoT25/WdlDdBV/SVtdU5zxhAlEYhwqFs95I4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578404625644991.4134139930075; Tue, 7 Jan 2020 05:43:45 -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-320-I_zf8RrENN6E_cffvRanHQ-1; Tue, 07 Jan 2020 08:43:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DC1B1807463; Tue, 7 Jan 2020 13:43:36 +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 33C18277A4; Tue, 7 Jan 2020 13:43:35 +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 7A64818089CD; Tue, 7 Jan 2020 13:43:32 +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 007DhVnw027724 for ; Tue, 7 Jan 2020 08:43:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id C2A6886C48; Tue, 7 Jan 2020 13:43:31 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A4CF86C43 for ; Tue, 7 Jan 2020 13:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578404624; 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=AGiGApiwxDTpmNnhyWbQoxyVYzpn5WNkA2R67R1Gdw4=; b=g6KnPK3No9FIhNop/Uuglcz5sBXZ2OSJ9EmiLOSoGU7LhtFF8hLnJzMNKeMFWIqBsGMd9o l3wMGAYgU9bTa1WhLuLF7g/Xu48Lq42Af6YSFFbhtdaB3Lq+/xMB6LSE4b1Jvv/fmNU4Re 6TrNGEvMhkjHOFS0xVqvL5E5wkzDl4o= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 14:43:22 +0100 Message-Id: <890754a4a0ce50fd27213942ef7562aa0351f639.1578404460.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 v2 1/4] 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.23 X-MC-Unique: I_zf8RrENN6E_cffvRanHQ-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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 6a76d355f5..b9bb1df179 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1202,7 +1202,7 @@ qemuFirmwareFetchParsedConfigs(bool privileged, =20 int qemuFirmwareFillDomain(virQEMUDriverPtr driver, - virDomainObjPtr vm, + virDomainDefPtr def, unsigned int flags) { VIR_AUTOSTRINGLIST paths =3D NULL; @@ -1215,7 +1215,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, @@ -1223,7 +1223,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]); @@ -1234,7 +1234,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 @@ -1243,10 +1243,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 1e128d1d83..4195042194 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6267,7 +6267,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, return -1; =20 VIR_DEBUG("Prepare bios/uefi paths"); - if (qemuFirmwareFillDomain(driver, vm, flags) < 0) + if (qemuFirmwareFillDomain(driver, vm->def, flags) < 0) return -1; if (qemuDomainInitializePflashStorageSource(vm) < 0) return -1; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:57:10 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=1578404625; cv=none; d=zohomail.com; s=zohoarc; b=PPtYR9Nfh2/PjhjkyjS/M9Tj5bxPteRFRhJtrFeuxGte3lGzo5EL8VffuTTCU4+xfTH9lSIoE7jvthFVckU0j5H9SlYBDJ/9XXlXLBWdHckq3CQw3CyrPrF6pi9k74z50ddi2nIrHK5PugKWfv71ZRDEs4D8FOpenMNTf1TZTcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578404625; 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=N9U1ojYrgQGXojoEmfMONe7xYalK+RLkq8+gPQuZrXU=; b=mMJc1LWZ4qX7snOnjCkc0q2Q4T3e3qOU6K287Xq13KG5QlmSEvsRr3QZAeJ41h2VhLCje/yj/mPl1D/7i2UPcGV5W3eSEaK0qfR8K/pqr+mabwXg5+ngFOcKB/m2cLBhfQDK4STqDnVzaYuRjcctaJkQNZPjC+vr3uIHbNH9cWw= 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578404625195265.52157199023327; Tue, 7 Jan 2020 05:43:45 -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-38-xIQ-5NLRMoiUtii9lH3-eQ-1; Tue, 07 Jan 2020 08:43:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F640801E76; Tue, 7 Jan 2020 13:43:36 +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 B2D465D9D6; Tue, 7 Jan 2020 13:43:35 +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 E8E9A81C84; Tue, 7 Jan 2020 13:43:33 +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 007DhWDB027731 for ; Tue, 7 Jan 2020 08:43:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9229386C43; Tue, 7 Jan 2020 13:43:32 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AC7D86C4A for ; Tue, 7 Jan 2020 13:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578404624; 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=N9U1ojYrgQGXojoEmfMONe7xYalK+RLkq8+gPQuZrXU=; b=MMf647jepM2yJYCOpSOLrcDs8l+sVhgw6lDKSKYLPi0PM1zlg+zsyQMN5Q5NlnRZDBKHrd shxzb2T9cLbq69rfaVTCOpwFI4OXuQtk4T+PfAd3XcuiqwJPHAzWdIUyiROV3q6EWx3d5Q XuFmQeqQxVYFOY9S/lzSK9Ei5DViayk= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 14:43:23 +0100 Message-Id: <22f30afdbfd2874b55b7165b09da717971f25424.1578404460.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 v2 2/4] qemu_firmware: Introduce @want variable to qemuFirmwareMatchDomain() 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.79 on 10.5.11.14 X-MC-Unique: xIQ-5NLRMoiUtii9lH3-eQ-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 simplifies condition when matching FW interface by having a single line condition instead of multiline one. Also, it prepares the code for future expansion. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_firmware.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index b9bb1df179..a3305d5554 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -928,22 +928,39 @@ qemuFirmwareMatchesMachineArch(const qemuFirmware *fw, } =20 =20 +static qemuFirmwareOSInterface +qemuFirmwareOSInterfaceTypeFromOsDefFirmware(virDomainOsDefFirmware fw) +{ + switch (fw) { + case VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS: + return QEMU_FIRMWARE_OS_INTERFACE_BIOS; + case VIR_DOMAIN_OS_DEF_FIRMWARE_EFI: + return QEMU_FIRMWARE_OS_INTERFACE_UEFI; + case VIR_DOMAIN_OS_DEF_FIRMWARE_NONE: + case VIR_DOMAIN_OS_DEF_FIRMWARE_LAST: + break; + } + + return QEMU_FIRMWARE_OS_INTERFACE_NONE; +} + + static bool qemuFirmwareMatchDomain(const virDomainDef *def, const qemuFirmware *fw, const char *path) { size_t i; + qemuFirmwareOSInterface want; bool supportsS3 =3D false; bool supportsS4 =3D false; bool requiresSMM =3D false; bool supportsSEV =3D false; =20 + want =3D qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.firmware= ); + 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 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:57:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578404641; cv=none; d=zohomail.com; s=zohoarc; b=X8x6QK/ufY6rncnlE5NtrF7QM9O+2F0r5pQ/PuP7WKF0gPkc64nEmci2ggRYfyiz818Oos71HY8KBa3kWerRZSvChdqkQCZHq2dilJA+AEjf4EvlRqB/hXeGonw8eXZb9P5juz238ViVnBIItm8zySDJQ1OnWqU9hNmk7G5oh64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578404641; 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=bFhThVbpke41YwuaPEB76TilqJjSZ2G/nG44d0vIHqs=; b=HKvkaoAWnESOknfvx18mRsPyMYlbUZzwgdeasr/i8mY+8P343EOC1VsmPaPXk+Eg+NH8v+XXUfan3nmdKeHijLDQBdxL8zb1emJi+8yvhn8y+OexMe+S4TPBep/URIxlUt90MAG96Y5BUlvqXBPM1dW5mOCcmOi+BFbHTz8Blj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 157840464113236.472851556215346; Tue, 7 Jan 2020 05:44:01 -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-207-XRoBwGpSOmSYZOC5Buz_SA-1; Tue, 07 Jan 2020 08:43:58 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08D301005516; Tue, 7 Jan 2020 13:43:53 +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 DD0015D9D6; Tue, 7 Jan 2020 13:43:52 +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 9AD5D18089D0; Tue, 7 Jan 2020 13:43:52 +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 007DhXb1027741 for ; Tue, 7 Jan 2020 08:43:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 622BC86C4B; Tue, 7 Jan 2020 13:43:33 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEEB786C43 for ; Tue, 7 Jan 2020 13:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578404640; 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=bFhThVbpke41YwuaPEB76TilqJjSZ2G/nG44d0vIHqs=; b=Kw1dNKdRcP63Xjo5KeCn1v4uQ4HM3XTM5Y0S8mcMCPshnzRYSqubwpTF6ZCowvi+lDBgct ViCfl6rAd34dcTp4kPOR3kzSpUMaPyXpbZC/ZeOMrkXnjyIZeqVyfxq1Sp+Doz5wfsbz2R iZSKrzjTdcSQWdBQJSjStCW0Yv2gdb4= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 14:43:24 +0100 Message-Id: <0f2ee7db99d7cbc226d1fb0938e8658a845c75ce.1578404460.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 v2 3/4] src: Introduce and use virDomainDefHasOldStyleUEFI() and virDomainDefHasOldStyleROUEFI() 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.79 on 10.5.11.14 X-MC-Unique: XRoBwGpSOmSYZOC5Buz_SA-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" These functions are meant to replace verbose check for the old style of specifying UEFI with a simple function call. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_driver.c | 3 +-- src/conf/domain_conf.c | 16 ++++++++++++++++ src/conf/domain_conf.h | 6 ++++++ src/libvirt_private.syms | 2 ++ src/libxl/libxl_conf.c | 3 +-- src/libxl/xen_xl.c | 8 +++----- src/qemu/qemu_domain.c | 14 ++++---------- src/qemu/qemu_driver.c | 3 +-- 8 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index a764b4d4ed..5b8fba7467 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -704,8 +704,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, if (def->os.bootloader =3D=3D NULL && def->os.loader) { =20 - if ((def->os.loader->readonly !=3D VIR_TRISTATE_BOOL_YES) || - (def->os.loader->type !=3D VIR_DOMAIN_LOADER_TYPE_PFLASH)) { + if (!virDomainDefHasOldStyleROUEFI(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only read-only pflash is supported.")); goto cleanup; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee33b7caf0..64d7af9e3c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31510,6 +31510,22 @@ virDomainDefHasMdevHostdev(const virDomainDef *def) } =20 =20 +bool +virDomainDefHasOldStyleUEFI(const virDomainDef *def) +{ + return def->os.loader && + def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH; +} + + +bool +virDomainDefHasOldStyleROUEFI(const virDomainDef *def) +{ + return virDomainDefHasOldStyleUEFI(def) && + def->os.loader->readonly =3D=3D VIR_TRISTATE_BOOL_YES; +} + + /** * virDomainGraphicsDefHasOpenGL: * @def: domain definition diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e012975fca..e6b06a8eba 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3673,6 +3673,12 @@ virDomainDefHasVFIOHostdev(const virDomainDef *def); bool virDomainDefHasMdevHostdev(const virDomainDef *def); =20 +bool +virDomainDefHasOldStyleUEFI(const virDomainDef *def); + +bool +virDomainDefHasOldStyleROUEFI(const virDomainDef *def); + bool virDomainGraphicsDefHasOpenGL(const virDomainDef *def); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9185e49fda..ec1054cdc3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -311,6 +311,8 @@ virDomainDefHasMdevHostdev; virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; virDomainDefHasNVMeDisk; +virDomainDefHasOldStyleROUEFI; +virDomainDefHasOldStyleUEFI; virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefHasVFIOHostdev; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 1be2a789d5..2488bb9d32 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -545,8 +545,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, * future, Xen will support a user-specified firmware path. See * http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg= 01628.html */ - if (def->os.loader && - def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH) + if (virDomainDefHasOldStyleUEFI(def)) b_info->u.hvm.bios =3D LIBXL_BIOS_TYPE_OVMF; =20 if (def->emulator) { diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index ebcea41d1c..91b1825399 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1228,11 +1228,9 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) if (xenConfigSetString(conf, "builder", "hvm") < 0) return -1; =20 - if (def->os.loader && - def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH) { - if (xenConfigSetString(conf, "bios", "ovmf") < 0) - return -1; - } + if (virDomainDefHasOldStyleUEFI(def) && + xenConfigSetString(conf, "bios", "ovmf") < 0) + return -1; =20 if (def->os.slic_table && xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) = < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 065c9e97a9..788caf864c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5697,8 +5697,7 @@ qemuDomainDefValidate(const virDomainDef *def, =20 /* On x86, UEFI requires ACPI */ if ((def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_EFI || - (def->os.loader && - def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH)) && + virDomainDefHasOldStyleUEFI(def)) && ARCH_IS_X86(def->os.arch) && def->features[VIR_DOMAIN_FEATURE_ACPI] !=3D VIR_TRISTATE_SWITCH_ON= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -5710,8 +5709,7 @@ qemuDomainDefValidate(const virDomainDef *def, if (def->features[VIR_DOMAIN_FEATURE_ACPI] =3D=3D VIR_TRISTATE_SWITCH_= ON && def->os.arch =3D=3D VIR_ARCH_AARCH64 && (def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FIRMWARE_EFI && - (!def->os.loader || - def->os.loader->type !=3D VIR_DOMAIN_LOADER_TYPE_PFLASH))) { + !virDomainDefHasOldStyleUEFI(def))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("ACPI requires UEFI on this architecture")); goto cleanup; @@ -16608,12 +16606,9 @@ void qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg, virDomainDefPtr def) { - if (def->os.loader && - def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH && - def->os.loader->readonly =3D=3D VIR_TRISTATE_BOOL_YES && + if (virDomainDefHasOldStyleROUEFI(def) && !def->os.loader->nvram) qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram); - } =20 =20 @@ -16740,8 +16735,7 @@ qemuDomainInitializePflashStorageSource(virDomainOb= jPtr vm) if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) return 0; =20 - if (!def->os.loader || - def->os.loader->type !=3D VIR_DOMAIN_LOADER_TYPE_PFLASH) + if (!virDomainDefHasOldStyleUEFI(def)) return 0; =20 if (!(pflash0 =3D virStorageSourceNew())) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ae54c00239..34d1374d87 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15218,8 +15218,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, * Avoid the issues by forbidding internal snapshot with pflash comple= tely. */ if (found_internal && - vm->def->os.loader && - vm->def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_PFLASH) { + virDomainDefHasOldStyleUEFI(vm->def)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("internal snapshots of a VM with pflash based " "firmware are not supported")); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:57:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578404644; cv=none; d=zohomail.com; s=zohoarc; b=NbIB2VT9w7fncXEJSt77W+MKnzIlMo/KGQSIYLy/39BCmcL3FqO+Nyg+VmvQeRt+dKq0y7cgzJQrTwRlNulRwKmHZysuPi/edE/9+HnyzJuWBnJLIZBg5tIDfbM5MtvjGga2klnsgRH72gTHQckuICtcCW0wcuA0ey5LHi4YEPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578404644; 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=/ImOP8XQGaFB6QTBVSJYAoGW2itxlsnR0vpZ3jsiF2A=; b=a11m3L/gxh5RkJ99COfyGoTfZEG+mughcTk9c75A3MtDgkkGDTK/ITE+QJnl/Fwpf09BStN8+n8EiOmYc4skM4I6TY1g53M23+TIRxdriB6w0NeFB+6BqEw3HsnsngCT6jAAquivK8Qj1Lr20Y1h6ZTnoMU9Pb9+c2lLi1WVbfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578404644680149.50127723155015; Tue, 7 Jan 2020 05:44:04 -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-207-UL5K7ECFMQCfBepFx6E6hg-1; Tue, 07 Jan 2020 08:43:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EC881800D4E; Tue, 7 Jan 2020 13:43:53 +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 DB939277A4; Tue, 7 Jan 2020 13:43:52 +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 968FC18089CF; Tue, 7 Jan 2020 13:43:52 +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 007Dhagi027751 for ; Tue, 7 Jan 2020 08:43:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0771884672; Tue, 7 Jan 2020 13:43:36 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84655858B9 for ; Tue, 7 Jan 2020 13:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578404642; 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=/ImOP8XQGaFB6QTBVSJYAoGW2itxlsnR0vpZ3jsiF2A=; b=b25G0yKx3e7CPsJ91QQFFZoZMXmINmbmvVTB2vk5fyJ2U6jkfpget7xLwoLb6zFhOJiRnt +c6SOJR6h7HwdESAZMabkapnoWkfThPbl3bW8hjkMz5UEoaYbbjGBoP0u8Nv1p8WPj5o+m ybFTcKK5sut/4L6Ktvco2uqZQIVOsXc= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 14:43:25 +0100 Message-Id: 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 v2 4/4] 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.23 X-MC-Unique: UL5K7ECFMQCfBepFx6E6hg-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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_firmware.c | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index a3305d5554..a835fe6b4a 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -959,6 +959,21 @@ qemuFirmwareMatchDomain(const virDomainDef *def, =20 want =3D qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.firmware= ); =20 + if (want =3D=3D QEMU_FIRMWARE_OS_INTERFACE_NONE && + def->os.loader) { + want =3D qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.load= er->type); + + 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; + } + } + for (i =3D 0; i < fw->ninterfaces; i++) { if (fw->interfaces[i] =3D=3D want) break; @@ -1226,14 +1241,29 @@ 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 and the varstore doesn't exist ... */ + if (!virDomainDefHasOldStyleROUEFI(def) || + def->os.loader->templt || + 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) @@ -1249,9 +1279,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