cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
b38b0f
From 2adf144c57ddef54f5c42cdbc539d0249ce1b0ba Mon Sep 17 00:00:00 2001
b38b0f
From: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Date: Thu, 29 Aug 2019 20:55:32 +0100
b38b0f
Subject: [PATCH 05/10] i386: "unavailable-features" QOM property
b38b0f
b38b0f
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Message-id: <20190829205532.8302-3-ehabkost@redhat.com>
b38b0f
Patchwork-id: 90201
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 2/2] i386: "unavailable-features" QOM property
b38b0f
Bugzilla: 1747185
b38b0f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
b38b0f
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
b38b0f
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
b38b0f
b38b0f
Add a "unavailable-features" QOM property to X86CPU objects that
b38b0f
have the same semantics of "unavailable-features" on
b38b0f
query-cpu-definitions.  The new property has the same goal of
b38b0f
"filtered-features", but is generic enough to let any kind of CPU
b38b0f
feature to be listed there without relying on low level details
b38b0f
like CPUID leaves or MSR numbers.
b38b0f
b38b0f
Message-Id: <20190422234742.15780-3-ehabkost@redhat.com>
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
(cherry picked from commit 506174bf8219dc6d56d2b1f7e66e8cf39157466f)
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 target/i386/cpu.c | 20 ++++++++++++++++++++
b38b0f
 1 file changed, 20 insertions(+)
b38b0f
b38b0f
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
b38b0f
index 934f11b..c8f50a7 100644
b38b0f
--- a/target/i386/cpu.c
b38b0f
+++ b/target/i386/cpu.c
b38b0f
@@ -3580,6 +3580,17 @@ static void x86_cpu_list_feature_names(FeatureWordArray features,
b38b0f
     }
b38b0f
 }
b38b0f
 
b38b0f
+static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v,
b38b0f
+                                             const char *name, void *opaque,
b38b0f
+                                             Error **errp)
b38b0f
+{
b38b0f
+    X86CPU *xc = X86_CPU(obj);
b38b0f
+    strList *result = NULL;
b38b0f
+
b38b0f
+    x86_cpu_list_feature_names(xc->filtered_features, &result);
b38b0f
+    visit_type_strList(v, "unavailable-features", &result, errp);
b38b0f
+}
b38b0f
+
b38b0f
 /* Check for missing features that may prevent the CPU class from
b38b0f
  * running using the current machine and accelerator.
b38b0f
  */
b38b0f
@@ -5479,6 +5490,15 @@ static void x86_cpu_initfn(Object *obj)
b38b0f
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
b38b0f
                         x86_cpu_get_feature_words,
b38b0f
                         NULL, NULL, (void *)cpu->filtered_features, NULL);
b38b0f
+    /*
b38b0f
+     * The "unavailable-features" property has the same semantics as
b38b0f
+     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
b38b0f
+     * QMP command: they list the features that would have prevented the
b38b0f
+     * CPU from running if the "enforce" flag was set.
b38b0f
+     */
b38b0f
+    object_property_add(obj, "unavailable-features", "strList",
b38b0f
+                        x86_cpu_get_unavailable_features,
b38b0f
+                        NULL, NULL, NULL, &error_abort);
b38b0f
 
b38b0f
     object_property_add(obj, "crash-information", "GuestPanicInformation",
b38b0f
                         x86_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL);
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f