From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jiri Denemark <jdenemar@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
libvir-list@redhat.com, dahi@linux.vnet.ibm.com,
Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH v3 5/5] target-i386: Return runnability information on query-cpu-definitions
Date: Mon, 19 Sep 2016 16:42:55 -0300 [thread overview]
Message-ID: <1474314175-24374-6-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1474314175-24374-1-git-send-email-ehabkost@redhat.com>
Fill the "unavailable-features" field on the x86 implementation
of query-cpu-definitions.
Cc: Jiri Denemark <jdenemar@redhat.com>
Cc: libvir-list@redhat.com
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v2 -> v3:
* Create a x86_cpu_feature_name() function, to
isolate the code that returns the property name
Changes v1 -> v2:
* Updated to the new schema: no @runnable field, and
always report @unavailable-features as present
---
target-i386/cpu.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a755309..9b53ce5 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1987,6 +1987,24 @@ static inline void feat2prop(char *s)
}
}
+/* Return the feature property name for a feature flag bit */
+static char *x86_cpu_feature_name(FeatureWord w, int bitnr)
+{
+ char **parts, *r;
+
+ /*TODO: This can be simplified later, by:
+ * 1) Moving the aliases outside the feat_names array
+ * (making g_strsplit() unnecessary)
+ * 2) Replacing "_" with "-" on all entries
+ * (making feat2prop() unnecessary)
+ */
+ parts = g_strsplit(feature_word_info[w].feat_names[bitnr], "|", 2);
+ r = g_strdup(parts[0]);
+ feat2prop(r);
+ g_strfreev(parts);
+ return r;
+}
+
/* Compatibily hack to maintain legacy +-feat semantic,
* where +-feat overwrites any feature set by
* feat=on|feat even if the later is parsed after +-feat
@@ -2105,6 +2123,41 @@ static void x86_cpu_report_filtered_features(X86CPU *cpu)
}
}
+/* Check for missing features that may prevent the CPU class from
+ * running using the current machine and accelerator.
+ */
+static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
+ strList **missing_feats)
+{
+ X86CPU *xc;
+ FeatureWord w;
+
+ if (xcc->kvm_required && !kvm_enabled()) {
+ strList *new = g_new0(strList, 1);
+ new->value = g_strdup("kvm");;
+ *missing_feats = new;
+ return;
+ }
+
+ xc = X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc))));
+ if (x86_cpu_filter_features(xc)) {
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ uint32_t filtered = xc->filtered_features[w];
+ int i;
+ for (i = 0; i < 32; i++) {
+ if (filtered & (1UL << i)) {
+ strList *new = g_new0(strList, 1);
+ new->value = x86_cpu_feature_name(w, i);
+ new->next = *missing_feats;
+ *missing_feats = new;
+ }
+ }
+ }
+ }
+
+ object_unref(OBJECT(xc));
+}
+
/* Print all cpuid feature names in featureset
*/
static void listflags(FILE *f, fprintf_function print, const char **featureset)
@@ -2197,6 +2250,8 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
info = g_malloc0(sizeof(*info));
info->name = x86_cpu_class_get_model_name(cc);
+ x86_cpu_class_check_missing_features(cc, &info->unavailable_features);
+ info->has_unavailable_features = true;
entry = g_malloc0(sizeof(*entry));
entry->value = info;
--
2.7.4
next prev parent reply other threads:[~2016-09-19 19:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 19:42 [Qemu-devel] [PATCH v3 0/5] Add runnability info to query-cpu-definitions Eduardo Habkost
2016-09-19 19:42 ` [Qemu-devel] [PATCH v3 1/5] target-i386: List CPU models using subclass list Eduardo Habkost
2016-09-19 19:42 ` [Qemu-devel] [PATCH v3 2/5] target-i386: Move warning code outside x86_cpu_filter_features() Eduardo Habkost
2016-09-19 19:42 ` [Qemu-devel] [PATCH v3 3/5] target-i386: Define CPUID filtering functions before x86_cpu_list() Eduardo Habkost
2016-09-19 19:42 ` [Qemu-devel] [PATCH v3 4/5] qmp: Add runnability information to query-cpu-definitions Eduardo Habkost
2016-09-20 18:25 ` [Qemu-devel] [libvirt] " Eric Blake
2016-09-20 19:05 ` Eduardo Habkost
2016-09-19 19:42 ` Eduardo Habkost [this message]
2016-09-19 21:16 ` [Qemu-devel] [libvirt] [PATCH v3 0/5] Add runnability info " no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474314175-24374-6-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=armbru@redhat.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=imammedo@redhat.com \
--cc=jdenemar@redhat.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).