[PATCH 4/4] cpu_x86: Implement virCPUValidateFeatures

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

 



The function checks whether all CPU features used in a CPU definition
are specified in cpu_map.xml.

https://bugzilla.redhat.com/show_bug.cgi?id=1460086

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 2864454211..5ce205f9c1 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2925,6 +2925,28 @@ virCPUx86CopyMigratable(virCPUDefPtr cpu)
 }
 
 
+static int
+virCPUx86ValidateFeatures(virCPUDefPtr cpu)
+{
+    virCPUx86MapPtr map;
+    size_t i;
+
+    if (!(map = virCPUx86GetMap()))
+        return -1;
+
+    for (i = 0; i < cpu->nfeatures; i++) {
+        if (!x86FeatureFind(map, cpu->features[i].name)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown CPU feature: %s"),
+                           cpu->features[i].name);
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 int
 virCPUx86DataAddCPUID(virCPUDataPtr cpuData,
                       const virCPUx86CPUID *cpuid)
@@ -3001,4 +3023,5 @@ struct cpuArchDriver cpuDriverX86 = {
     .translate  = virCPUx86Translate,
     .expandFeatures = virCPUx86ExpandFeatures,
     .copyMigratable = virCPUx86CopyMigratable,
+    .validateFeatures = virCPUx86ValidateFeatures,
 };
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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