[libvirt PATCH v3 2/5] conf: refactor virDomainResourceDefParse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is no need to error out for empty <partition></partition> element
as we can just simply ignore it. This allows to simplify the function
and prepare it for new sub-elements of <resource>.

It makes the <partition> element optional so we need to reflect the
change in schema as well.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 docs/schemas/domaincommon.rng |  8 +++++---
 src/conf/domain_conf.c        | 18 +++++++-----------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 2442078969..9b669d9de5 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1172,9 +1172,11 @@
 
   <define name="respartition">
     <element name="resource">
-      <element name="partition">
-        <ref name="absFilePath"/>
-      </element>
+      <optional>
+        <element name="partition">
+          <ref name="absFilePath"/>
+        </element>
+      </optional>
     </element>
   </define>
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e9bdbbfd74..7dff6c8beb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17284,23 +17284,19 @@ virDomainResourceDefParse(xmlNodePtr node,
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
     virDomainResourceDef *def = NULL;
+    char *partition = NULL;
 
     ctxt->node = node;
 
+    partition = virXPathString("string(./partition)", ctxt);
+
+    if (!partition)
+        return NULL;
+
     def = g_new0(virDomainResourceDef, 1);
-
-    /* Find out what type of virtualization to use */
-    if (!(def->partition = virXPathString("string(./partition)", ctxt))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("missing resource partition attribute"));
-        goto error;
-    }
+    def->partition = partition;
 
     return def;
-
- error:
-    virDomainResourceDefFree(def);
-    return NULL;
 }
 
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux