[libvirt] [PATCH 05/36] cpu_x86: Require <cpuid> within <feature> in CPU map

Jiri Denemark jdenemar at redhat.com
Mon Apr 8 08:42:09 UTC 2019


A feature with no cpuid element is invalid and it should not be silently
treated as a feature with all CPUID bits set to zero.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/cpu/cpu_x86.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 3b87386270..3a8e3dd37f 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -924,6 +924,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
     if (n < 0)
         goto cleanup;
 
+    if (n == 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Missing cpuid for feature %s"),
+                       feature->name);
+        goto cleanup;
+    }
+
     for (i = 0; i < n; i++) {
         ctxt->node = nodes[i];
         if (x86ParseCPUID(ctxt, &cpuid) < 0) {
-- 
2.21.0




More information about the libvir-list mailing list