cryptospore / rpms / qemu-kvm

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