[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 5/7] cpu: avoid using object instance state in p
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH RFC 5/7] cpu: avoid using object instance state in property getter |
Date: |
Wed, 26 Aug 2015 13:03:12 +0100 |
When registering the properties 'feature-words' and 'filtered-features'
object instance data is being passed in. This can easily be accessed
directly via the 'Object *obj' parameter passed to the getter, so
the object instance data does not need to be supplied at property
registration time.
Signed-off-by: Daniel P. Berrange <address@hidden>
---
target-i386/cpu.c | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index cfb8aa7..780a5bc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1766,12 +1766,10 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor
*v, void *opaque,
}
/* Generic getter for "feature-words" and "filtered-features" properties */
-static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static X86CPUFeatureWordInfoList *
+x86_cpu_get_feature_words_helper(Object *obj, uint32_t *array)
{
- uint32_t *array = (uint32_t *)opaque;
FeatureWord w;
- Error *err = NULL;
X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] = { };
X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] = { };
X86CPUFeatureWordInfoList *list = NULL;
@@ -1791,10 +1789,37 @@ static void x86_cpu_get_feature_words(Object *obj,
Visitor *v, void *opaque,
list = &list_entries[w];
}
+ return list;
+}
+
+
+static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ uint32_t *array = cpu->env.features;
+ X86CPUFeatureWordInfoList *list =
+ x86_cpu_get_feature_words_helper(obj, array);
+ Error *err = NULL;
+
visit_type_X86CPUFeatureWordInfoList(v, &list, "feature-words", &err);
error_propagate(errp, err);
}
+
+static void x86_cpu_get_filtered_features(Object *obj, Visitor *v, void
*opaque,
+ const char *name, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ uint32_t *array = cpu->filtered_features;
+ X86CPUFeatureWordInfoList *list =
+ x86_cpu_get_feature_words_helper(obj, array);
+ Error *err = NULL;
+
+ visit_type_X86CPUFeatureWordInfoList(v, &list, "filtered-features", &err);
+ error_propagate(errp, err);
+}
+
static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
@@ -3036,10 +3061,10 @@ static void x86_cpu_initfn(Object *obj)
x86_cpuid_set_apic_id, NULL, NULL, NULL);
object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
- NULL, NULL, (void *)env->features, NULL);
+ NULL, NULL, NULL, NULL);
object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
- x86_cpu_get_feature_words,
- NULL, NULL, (void *)cpu->filtered_features, NULL);
+ x86_cpu_get_filtered_features,
+ NULL, NULL, NULL, NULL);
cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
--
2.4.3
- [Qemu-devel] [PATCH RFC 0/7] Making QOM introspectable, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 3/7] rng: register properties against the class instead of object, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 4/7] tpm: register properties against the class instead of object, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 1/7] qom: allow properties to be registered against classes, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 2/7] hostmem: register properties against the class instead of object, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 6/7] x86-cpu: register properties against the class instead of object, Daniel P. Berrange, 2015/08/26
- [Qemu-devel] [PATCH RFC 5/7] cpu: avoid using object instance state in property getter,
Daniel P. Berrange <=
- [Qemu-devel] [PATCH RFC 7/7] machine: register properties against the class instead of object, Daniel P. Berrange, 2015/08/26