]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainLoaderDefParseXML: Allow loader path to be NULL
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 25 Feb 2019 10:31:17 +0000 (11:31 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Mar 2019 14:29:43 +0000 (15:29 +0100)
Except not really. At least for now.

In the future, the firmware will be selected automagically.
Therefore, it makes no sense to require the pathname of a
specific firmware binary in the domain XML. But since it is not
implemented do not really allow the path to be NULL. Only move
code around to prepare it for further expansion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
docs/schemas/domaincommon.rng
src/conf/domain_conf.c

index 80f9f84f70e0379bc3e47bcc9ee5f5a92f1a22f9..c8d63c491242feac160913b6c3fea313211c479a 100644 (file)
                 </choice>
               </attribute>
             </optional>
-            <ref name="absFilePath"/>
+            <optional>
+              <ref name="absFilePath"/>
+            </optional>
           </element>
         </optional>
         <optional>
index 995f87bcbe8993740781e2dc10349299c8ebceaa..e4dd263bf495ff3e9b8a21a4201000d5ec8f94b2 100644 (file)
@@ -6590,6 +6590,22 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
 }
 
 
+static int
+virDomainDefOSValidate(const virDomainDef *def)
+{
+    if (!def->os.loader)
+        return 0;
+
+    if (!def->os.loader->path) {
+        virReportError(VIR_ERR_XML_DETAIL, "%s",
+                       _("no loader path specified"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 virDomainDefValidateInternal(const virDomainDef *def)
 {
@@ -6628,6 +6644,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
     if (virDomainDefMemtuneValidate(def) < 0)
         return -1;
 
+    if (virDomainDefOSValidate(def) < 0)
+        return -1;
+
     return 0;
 }
 
@@ -18242,6 +18261,9 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
     type_str = virXMLPropString(node, "type");
     loader->path = (char *) xmlNodeGetContent(node);
 
+    if (STREQ_NULLABLE(loader->path, ""))
+        VIR_FREE(loader->path);
+
     if (readonly_str &&
         (loader->readonly = virTristateBoolTypeFromString(readonly_str)) <= 0) {
         virReportError(VIR_ERR_XML_DETAIL,
@@ -26985,9 +27007,12 @@ virDomainLoaderDefFormat(virBufferPtr buf,
     if (loader->secure)
         virBufferAsprintf(buf, " secure='%s'", secure);
 
-    virBufferAsprintf(buf, " type='%s'>", type);
+    virBufferAsprintf(buf, " type='%s'", type);
 
-    virBufferEscapeString(buf, "%s</loader>\n", loader->path);
+    if (loader->path)
+        virBufferEscapeString(buf, ">%s</loader>\n", loader->path);
+    else
+        virBufferAddLit(buf, "/>\n");
     if (loader->nvram || loader->templt) {
         virBufferAddLit(buf, "<nvram");
         virBufferEscapeString(buf, " template='%s'", loader->templt);