From nobody Sun Feb 8 21:05:53 2026 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155195099213529.361584262761312; Thu, 7 Mar 2019 01:29:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AE573082B02; Thu, 7 Mar 2019 09:29:50 +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 1F4845C647; Thu, 7 Mar 2019 09:29:50 +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 D5F62181A137; Thu, 7 Mar 2019 09:29:49 +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 x279TZLF009352 for ; Thu, 7 Mar 2019 04:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4F86A5C28C; Thu, 7 Mar 2019 09:29:35 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0CB65C646; Thu, 7 Mar 2019 09:29:34 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 7 Mar 2019 10:29:15 +0100 Message-Id: <7c0617bb1a114b5616b3330d435110771983c824.1551950609.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 Cc: lersek@redhat.com Subject: [libvirt] [PATCH v2 05/15] conf: Introduce VIR_DOMAIN_LOADER_TYPE_NONE 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 07 Mar 2019 09:29:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is going to extend virDomainLoader enum. The reason is that once loader path is NULL its type makes no sense. However, since value of zero corresponds to VIR_DOMAIN_LOADER_TYPE_ROM the following XML would be produced: ... To solve this, introduce VIR_DOMAIN_LOADER_TYPE_NONE which would correspond to value of zero and then use post parse callback to set the default loader type to 'rom' if needed. Signed-off-by: Michal Privoznik Reviewed-by: Laszlo Ersek Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 23 +++++++++++++++++++++-- src/conf/domain_conf.h | 3 ++- src/qemu/qemu_command.c | 1 + src/qemu/qemu_domain.c | 1 + tests/domaincapsschemadata/full.xml | 1 + 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 053b2cb210..fbfdd57224 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1059,6 +1059,7 @@ VIR_ENUM_IMPL(virDomainMemoryAllocation, VIR_DOMAIN_M= EMORY_ALLOCATION_LAST, =20 VIR_ENUM_IMPL(virDomainLoader, VIR_DOMAIN_LOADER_TYPE_LAST, + "none", "rom", "pflash", ); @@ -4305,6 +4306,20 @@ virDomainDefPostParseMemory(virDomainDefPtr def, } =20 =20 +static void +virDomainDefPostParseOs(virDomainDefPtr def) +{ + if (!def->os.loader) + return; + + if (def->os.loader->path && + def->os.loader->type =3D=3D VIR_DOMAIN_LOADER_TYPE_NONE) { + /* By default, loader is type of 'rom' */ + def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_ROM; + } +} + + static void virDomainDefPostParseMemtune(virDomainDefPtr def) { @@ -5480,6 +5495,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefPostParseMemory(def, data->parseFlags) < 0) return -1; =20 + virDomainDefPostParseOs(def); + virDomainDefPostParseMemtune(def); =20 if (virDomainDefRejectDuplicateControllers(def) < 0) @@ -18284,7 +18301,7 @@ virDomainLoaderDefParseXML(xmlNodePtr node, =20 if (type_str) { int type; - if ((type =3D virDomainLoaderTypeFromString(type_str)) < 0) { + if ((type =3D virDomainLoaderTypeFromString(type_str)) <=3D 0) { virReportError(VIR_ERR_XML_DETAIL, _("unknown type value: %s"), type_str); return -1; @@ -27011,12 +27028,14 @@ virDomainLoaderDefFormat(virBufferPtr buf, if (loader->secure) virBufferAsprintf(buf, " secure=3D'%s'", secure); =20 - virBufferAsprintf(buf, " type=3D'%s'", type); + if (loader->type !=3D VIR_DOMAIN_LOADER_TYPE_NONE) + virBufferAsprintf(buf, " type=3D'%s'", type); =20 if (loader->path) virBufferEscapeString(buf, ">%s\n", loader->path); else virBufferAddLit(buf, "/>\n"); + if (loader->nvram || loader->templt) { virBufferAddLit(buf, "templt); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c2dcc87ba1..ed5d00c399 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1954,7 +1954,8 @@ struct _virDomainBIOSDef { }; =20 typedef enum { - VIR_DOMAIN_LOADER_TYPE_ROM =3D 0, + VIR_DOMAIN_LOADER_TYPE_NONE =3D 0, + VIR_DOMAIN_LOADER_TYPE_ROM, VIR_DOMAIN_LOADER_TYPE_PFLASH, =20 VIR_DOMAIN_LOADER_TYPE_LAST diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3a2ec7f26c..5e56447b76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9967,6 +9967,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd, } break; =20 + case VIR_DOMAIN_LOADER_TYPE_NONE: case VIR_DOMAIN_LOADER_TYPE_LAST: /* nada */ break; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2b0d05f2db..e9b2b8453b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12213,6 +12213,7 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg AT= TRIBUTE_UNUSED, goto cleanup; break; =20 + case VIR_DOMAIN_LOADER_TYPE_NONE: case VIR_DOMAIN_LOADER_TYPE_LAST: break; } diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemada= ta/full.xml index 28263466a4..74bc740e0d 100644 --- a/tests/domaincapsschemadata/full.xml +++ b/tests/domaincapsschemadata/full.xml @@ -10,6 +10,7 @@ /foo/bar /tmp/my_path + none rom pflash --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list