From nobody Sun Feb 8 19:59:41 2026 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