From nobody Wed May 1 19:30:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1567087928; cv=none; d=zoho.com; s=zohoarc; b=KRwvp+vS0SgKtT1veuwJrl4GEppSMRbsq9iTs1U3GSgBpI6f6vok5/YeCRXpwvzUHx+jWKcoVKeXklx0oHJW46CRTJ4O1bP9KzUY4yGUaxnndgMoGG+AHudPC2BNY6I2ZZ3LN15tAT3xFUm0PapG4YehAXuJAtDsOu2X5ius5HM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567087928; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=kRlL8Y0xK85DgBWdkzeApvWXwXkDR65KVFmstHbSvgo=; b=nV3uiwyJTlzmaZpYojT8pE14h6+lpV5T3PdZ3EDD6MhgF+MqxdyIpdCPe9V1qGSG+LHa3zCfOJ+OE1BdFbAnMm95hTZB+3vyHYytZHj/1EbYzW2MVr29Cx0VwvKBQouU84u5GZsX2IZMlHQhVkiuDxpZ7CdJbH8+OVozUIgLQmo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567087928275937.3797047705417; Thu, 29 Aug 2019 07:12:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CED6943D61; Thu, 29 Aug 2019 14:12:06 +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 7EAA15D712; Thu, 29 Aug 2019 14:12:06 +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 753774A486; Thu, 29 Aug 2019 14:12:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TEC5UQ012542 for ; Thu, 29 Aug 2019 10:12:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17E2560C05; Thu, 29 Aug 2019 14:12:05 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9E7B60BF7 for ; Thu, 29 Aug 2019 14:12:02 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 09:11:56 -0500 Message-Id: <20190829141156.14609-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: extract function qemuDomainDefIsUEFI() 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Thu, 29 Aug 2019 14:12:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than repeating the conditions in a couple places, extract it into a separate function for detecting whether a domain definition uses UEFI. Signed-off-by: Jonathon Jongsma Reviewed-by: Martin Kletzander --- As requested by Andrea, I've extracted this little bit of refactoring from = my bochs display patch and am sending it separately. src/qemu/qemu_domain.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4998474dc9..ed4b5c666d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4584,6 +4584,14 @@ qemuDomainValidateCpuCount(const virDomainDef *def, } =20 =20 +static bool +qemuDomainDefIsUEFI(const virDomainDef *def) +{ + return ((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))); +} + static int qemuDomainDefValidate(const virDomainDef *def, virCapsPtr caps ATTRIBUTE_UNUSED, @@ -4606,10 +4614,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)) && - ARCH_IS_X86(def->os.arch) && + if (qemuDomainDefIsUEFI(def) && ARCH_IS_X86(def->os.arch) && def->features[VIR_DOMAIN_FEATURE_ACPI] !=3D VIR_TRISTATE_SWITCH_ON= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("UEFI requires ACPI on this architecture")); @@ -4619,9 +4624,7 @@ qemuDomainDefValidate(const virDomainDef *def, /* On aarch64, ACPI requires UEFI */ 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))) { + !qemuDomainDefIsUEFI(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("ACPI requires UEFI on this architecture")); goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list