On Tue, May 02, 2017 at 05:31:15PM -0300, Eduardo Habkost wrote:
> Introduce a new CPUFeatureSetting QAPI data type, and use it to support
> feature=force on -cpu.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
I will include this in v2 to fix the coding style issues.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
tests/test-x86-cpuid-compat.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 9940f4de1c..02f56ad0e8 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -103,16 +103,24 @@ typedef struct FeatureTestArgs {
} FeatureTestArgs;
/* Get the value for a feature word in a X86CPUFeatureWordInfo list */
-static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx, const char *reg)
+static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx,
+ const char *reg)
{
const QListEntry *e;
for (e = qlist_first(features); e; e = qlist_next(e)) {
QDict *w = qobject_to_qdict(qlist_entry_obj(e));
- if (eax == qint_get_int(qobject_to_qint(qdict_get(w, "cpuid-input-eax")))
- && (!qdict_haskey(w, "cpuid-input-ecx")
- || ecx == qint_get_int(qobject_to_qint(qdict_get(w, "cpuid-input-ecx"))))
- && !strcmp(qstring_get_str(qobject_to_qstring(qdict_get(w, "cpuid-register"))), reg)) {
+ const char *rreg =
+ qstring_get_str(qobject_to_qstring(qdict_get(w, "cpuid-register")));
+ uint32_t reax =
+ qint_get_int(qobject_to_qint(qdict_get(w, "cpuid-input-eax")));
+ bool has_ecx = qdict_haskey(w, "cpuid-input-ecx");
+ uint32_t recx = 0;
+
+ if (has_ecx) {
+ recx = qint_get_int(qobject_to_qint(qdict_get(w, "cpuid-input-ecx")));
+ }
+ if (eax == reax && (!has_ecx || ecx == recx) && !strcmp(rreg, reg)) {
return qint_get_int(qobject_to_qint(qdict_get(w, "features")));
}
}
--
2.11.0.259.g40922b1
--
Eduardo