target-i386: Make level and xlevel properties static

Static properties require only 1 line of code, much simpler than the
existing code that requires writing new getters/setters.

As a nice side-effect, this fixes an existing bug where the setters were
incorrectly allowing the properties to be changed after the CPU was
already realized.

Backports commit b9472b76d273c7796d877c49af50969c0a879c50 from qemu
This commit is contained in:
Eduardo Habkost 2018-02-12 20:49:49 -05:00 committed by Lioncash
parent 96a99a1bbe
commit f75d72bc3d
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -1361,42 +1361,6 @@ static int x86_cpuid_version_set_stepping(struct uc_struct *uc, Object *obj, Vis
return 0;
}
static void x86_cpuid_get_level(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
X86CPU *cpu = X86_CPU(uc, obj);
visit_type_uint32(v, &cpu->env.cpuid_level, name, errp);
}
static int x86_cpuid_set_level(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
X86CPU *cpu = X86_CPU(uc, obj);
visit_type_uint32(v, &cpu->env.cpuid_level, name, errp);
return 0;
}
static void x86_cpuid_get_xlevel(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
X86CPU *cpu = X86_CPU(uc, obj);
visit_type_uint32(v, &cpu->env.cpuid_xlevel, name, errp);
}
static int x86_cpuid_set_xlevel(struct uc_struct *uc, Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
X86CPU *cpu = X86_CPU(uc, obj);
visit_type_uint32(v, &cpu->env.cpuid_xlevel, name, errp);
return 0;
}
static char *x86_cpuid_get_vendor(struct uc_struct *uc, Object *obj, Error **errp)
{
X86CPU *cpu = X86_CPU(uc, obj);
@ -2449,12 +2413,6 @@ static void x86_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque)
object_property_add(obj, "stepping", "int",
x86_cpuid_version_get_stepping,
x86_cpuid_version_set_stepping, NULL, NULL, NULL);
object_property_add(obj, "level", "int",
x86_cpuid_get_level,
x86_cpuid_set_level, NULL, NULL, NULL);
object_property_add(obj, "xlevel", "int",
x86_cpuid_get_xlevel,
x86_cpuid_set_xlevel, NULL, NULL, NULL);
object_property_add_str(obj, "vendor",
x86_cpuid_get_vendor,
x86_cpuid_set_vendor, NULL);