[libvirt PATCH 3/3] cpu: Fail CPU comparison in the presence of unknown elements.

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/cpu_conf.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index dea950ce68..a2ba92ced3 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -659,6 +659,44 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
         def->cache->mode = mode;
     }
 
+    g_clear_pointer(&nodes, g_free);
+    if ((n = virXPathNodeSet("./@*", ctxt, &nodes)) < 0)
+        return -1;
+
+    for (i = 0; i < n; i++) {
+        if (virXMLNodeNameEqual(nodes[i], "check") ||
+            virXMLNodeNameEqual(nodes[i], "match") ||
+            virXMLNodeNameEqual(nodes[i], "migratable") ||
+            virXMLNodeNameEqual(nodes[i], "mode"))
+            continue;
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("unrecognized attribute in cpu element: %s"),
+                       nodes[i]->name);
+        return -1;
+    }
+
+    g_clear_pointer(&nodes, g_free);
+    if ((n = virXPathNodeSet("./*", ctxt, &nodes)) < 0)
+        return -1;
+
+    for (i = 0; i < n; i++) {
+        if (virXMLNodeNameEqual(nodes[i], "arch") ||
+            virXMLNodeNameEqual(nodes[i], "cache") ||
+            virXMLNodeNameEqual(nodes[i], "counter") ||
+            virXMLNodeNameEqual(nodes[i], "feature") ||
+            virXMLNodeNameEqual(nodes[i], "model") ||
+            virXMLNodeNameEqual(nodes[i], "microcode") ||
+            virXMLNodeNameEqual(nodes[i], "numa") ||
+            virXMLNodeNameEqual(nodes[i], "pages") ||
+            virXMLNodeNameEqual(nodes[i], "topology") ||
+            virXMLNodeNameEqual(nodes[i], "vendor"))
+            continue;
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("unrecognized element in cpu element: %s"),
+                       nodes[i]->name);
+        return -1;
+    }
+
     *cpu = g_steal_pointer(&def);
     return 0;
 }
-- 
2.26.2




[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