target-i386: X86CPU compatibility properties
cover target-i386: X86CPU compatibility properties
Hello,
It's easier adapting the infrastructure to our needs than working around it:
X86CPU already has QOM properties today. What's lacking is model subclasses, and with the one X86CPU type its global properties are overwritten by models. But we already know the designated naming scheme for the models!
So let's simply prepare compat_props for CPU models and make sure they are already picked up today.
This works just fine for changing the 486 CPUID model value and avoids to redo the PC part once we have X86CPU subclasses.
Tested using: ./QMP/qom-get /machine/icc-bridge/icc/child[0].model
For changing n270 CPUID flags we'll still need to resort to Eduardo's proposed helper functions for now.
Regards,
Andreas
Andreas Färber (4):
qdev: Let qdev_prop_parse() pass through Error
qdev: Introduce qdev_prop_set_custom_globals()
target-i386: Emulate X86CPU subclasses for global properties
target-i386: Change CPUID model of 486 to 8
hw/core/qdev-properties.c | 50 ++++++++++++++++++++++++++------------------ hw/core/qdev.c | 7 ++++++- include/hw/i386/pc.h | 4 ++++ include/hw/qdev-properties.h | 7 +++++-- qdev-monitor.c | 6 +++++- target-i386/cpu.c | 11 +++++++++- 6 files changed, 60 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 3/4 target-i386: Emulate X86CPU subclasses for global properties
After initializing the object from its x86_def_t and before setting any additional -cpu arguments, set any global properties for the designated subclass <name>-{i386,x86_64}-cpu.
--- target-i386/cpu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
target-i386/cpu.c +9 -0
@@ -1626,6 +1626,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,CPUX86State *env;gchar **model_pieces;char *name, *features; +char *typename;Error *error =NULL ; model_pieces =g_strsplit (cpu_model,"," ,2 );
@@ -1653,6 +1654,14 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, goto out; } +/* Emulate per-model subclasses for global properties */ + typename =g_strdup_printf ("%s-" TYPE_X86_CPU , name); +qdev_prop_set_custom_globals (DEVICE (cpu), typename, &error); +g_free (typename); +if (error) { + goto out; + } +cpu_x86_parse_featurestr (cpu, features, &error);if (error) { goto out;
Signature · 1 line
1.8.1.4
PATCH 2/4 qdev: Introduce qdev_prop_set_custom_globals()
In reply to Andreas FärberReuse it in qdev_prop_set_globals().
--- hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++----------- include/hw/qdev-properties.h | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-)
hw/core/qdev-properties.c +24 -11
@@ -1099,23 +1099,36 @@ void qdev_prop_register_global_list(GlobalProperty *props) } } +void qdev_prop_set_custom_globals (DeviceState *dev,const char *driver, +Error **errp) +{ +GlobalProperty *prop; + + QTAILQ_FOREACH(prop, &global_props, next) { +Error *err =NULL ; + +if (strcmp (driver, prop->driver) !=0 ) { +continue ; + } +qdev_prop_parse (dev, prop->property, prop->value, &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; + } + } +} +void qdev_prop_set_globals (DeviceState *dev,Error **errp) {ObjectClass *class =object_get_class (OBJECT (dev));do { -GlobalProperty *prop; - QTAILQ_FOREACH(prop, &global_props, next) { -Error *err =NULL ; +Error *err =NULL ; -if (strcmp (object_class_get_name (class), prop->driver) !=0 ) { -continue ; - } -qdev_prop_parse (dev, prop->property, prop->value, &err); -if (err !=NULL ) { -error_propagate (errp, err); -return ; - } +qdev_prop_set_custom_globals (dev,object_class_get_name (class), &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; } class =object_class_get_parent (class); }while (class);
include/hw/qdev-properties.h +2 -0
@@ -169,6 +169,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global (GlobalProperty *prop);void qdev_prop_register_global_list (GlobalProperty *props);void qdev_prop_set_globals (DeviceState *dev,Error **errp); +void qdev_prop_set_custom_globals (DeviceState *dev,const char *driver, +Error **errp);void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev,Property *prop,const char *value);
Signature · 1 line
1.8.1.4
PATCH 4/4 target-i386: Change CPUID model of 486 to 8
In reply to Andreas FärberThis changes the model number of 486 to 8 (DX4) which matches the feature set presented, and actually has the CPUID instruction.
This adds a compatibility property, to keep model=0 on pc-*-1.4 and older.
--- include/hw/i386/pc.h | 4 ++++ target-i386/cpu.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +4 -0
@@ -242,6 +242,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); .driver = "pc-sysfw",\ .property = "rom_only",\ .value = stringify(0),\ + },{\ + .driver = "486-" TYPE_X86_CPU,\ + .property = "model",\ + .value = stringify(0),\ }#endif
target-i386/cpu.c +1 -1
@@ -550,7 +550,7 @@ static x86_def_t builtin_x86_defs[] = { .level = 1, .vendor = CPUID_VENDOR_INTEL, .family = 4, - .model = 0, + .model = 8, .stepping = 0, .features = I486_FEATURES, .xlevel = 0,
Signature · 1 line
1.8.1.4
PATCH 1/4 qdev: Let qdev_prop_parse() pass through Error
In reply to Andreas FärberMove error reporting to callers.
--- hw/core/qdev-properties.c | 25 +++++++++++-------------- hw/core/qdev.c | 7 ++++++- include/hw/qdev-properties.h | 5 +++-- qdev-monitor.c | 6 +++++- 4 files changed, 25 insertions(+), 18 deletions(-)
hw/core/qdev-properties.c +11 -14
@@ -986,25 +986,18 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, } } -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value) +void qdev_prop_parse (DeviceState *dev,const char *name,const char *value, +Error **errp) {char *legacy_name; -Error *err =NULL ; legacy_name =g_strdup_printf ("legacy-%s" , name);if (object_property_get_type (OBJECT (dev), legacy_name,NULL )) { -object_property_parse (OBJECT (dev), value, legacy_name, &err); +object_property_parse (OBJECT (dev), value, legacy_name, errp); }else { -object_property_parse (OBJECT (dev), value, name, &err); +object_property_parse (OBJECT (dev), value, name, errp); }g_free (legacy_name); - -if (err) { -qerror_report_err (err); -error_free (err); -return -1 ; - } -return 0 ; }void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value)
@@ -1106,18 +1099,22 @@ void qdev_prop_register_global_list(GlobalProperty *props) } } -void qdev_prop_set_globals (DeviceState *dev) +void qdev_prop_set_globals (DeviceState *dev,Error **errp) {ObjectClass *class =object_get_class (OBJECT (dev)); do { GlobalProperty *prop; QTAILQ_FOREACH(prop, &global_props, next) { + Error *err = NULL; + if (strcmp(object_class_get_name(class), prop->driver) != 0) { continue; } - if (qdev_prop_parse(dev, prop->property, prop->value) != 0) { - exit(1); + qdev_prop_parse(dev, prop->property, prop->value, &err); + if (err != NULL) { + error_propagate(errp, err); + return; } } class = object_class_get_parent(class);
hw/core/qdev.c +6 -1
@@ -752,7 +752,12 @@ static void device_initfn(Object *obj) } class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE )); -qdev_prop_set_globals (dev); +qdev_prop_set_globals (dev, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err); +exit (1 ); + }object_property_add_link (OBJECT (dev),"parent_bus" ,TYPE_BUS , (Object **)&dev->parent_bus, &err);
include/hw/qdev-properties.h +3 -2
@@ -148,7 +148,8 @@ extern PropertyInfo qdev_prop_arraylen;/* Set properties between creation and init. */ void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value); +void qdev_prop_parse (DeviceState *dev,const char *name,const char *value, +Error **errp);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value);
@@ -167,7 +168,7 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global (GlobalProperty *prop);void qdev_prop_register_global_list (GlobalProperty *props); -void qdev_prop_set_globals (DeviceState *dev); +void qdev_prop_set_globals (DeviceState *dev,Error **errp);void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev,Property *prop,const char *value);
qdev-monitor.c +5 -1
@@ -105,13 +105,17 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque)static int set_property (const char *name,const char *value,void *opaque) {DeviceState *dev = opaque; +Error *err =NULL ;if (strcmp (name,"driver" ) ==0 )return 0 ;if (strcmp (name,"bus" ) ==0 )return 0 ; -if (qdev_prop_parse (dev, name, value) ==-1 ) { +qdev_prop_parse (dev, name, value, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err);return -1 ; }return 0 ;
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-cpu for-1.5 3/4] target-i386: Emulate X86CPU subclasses for global properties
In reply to Andreas FärberQuoted 22 lines · Andreas Färber
After initializing the object from its
x86_def_tand before setting any additional -cpu arguments, set any global properties for the designated subclass <name>-{i386,x86_64}-cpu.Signed-off-by Andreas Färber <[email protected]>--- target-i386/cpu.c | 9 +++++++++ 1 file changed, 9 insertions(+)target-i386/cpu.c +1
-0@@ -1626,6 +1626,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,CPUX86State *env;gchar **model_pieces;char *name, *features; +char *typename;Error *error =NULL ; model_pieces =g_strsplit (cpu_model,"," ,2 );
target-i386/cpu.c X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, · line 1663
Quoted 10 lines
target-i386/cpu.c +7
-0@@ -1653,6 +1654,14 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge, goto out; } +/* Emulate per-model subclasses for global properties */ + typename =g_strdup_printf ("%s-" TYPE_X86_CPU , name); +qdev_prop_set_custom_globals (DEVICE (cpu), typename, &error); +g_free (typename); +if (error) { + goto out; + }
I really like this solution.
I find it ironic that we spent 2 or 3 releases struggling with the imposed restriction that global-properties can't be used to set dynamic QOM properties (only static properties), and now we are introducing a mechanism to do exactly that. :-)
Quoted 7 lines
target-i386/cpu.c +1
-0+cpu_x86_parse_featurestr (cpu, features, &error);if (error) { goto out;Signature · 1 line
1.8.1.4
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH qom-cpu for-1.5 4/4] target-i386: Change CPUID model of 486 to 8
In reply to Andreas FärberQuoted 9 lines · Andreas Färber
This changes the model number of 486 to 8 (DX4) which matches the feature set presented, and actually has the CPUID instruction.
This adds a compatibility property, to keep model=0 on pc-*-1.4 and older.
Signed-off-by H. Peter Anvin <[email protected]>Cc Eduardo Habkost <[email protected]>[AF: Add compat_props entry]Signed-off-by Andreas Färber <[email protected]>
Tested by running a simple CPUID-dump test kernel, CPUID data is changing according to the machine-type as expected. Didn't test using a Linux kernel.
Quoted 36 lines
--- include/hw/i386/pc.h | 4 ++++ target-i386/cpu.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)include/hw/i386/pc.h +4
-0@@ -242,6 +242,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); .driver = "pc-sysfw",\ .property = "rom_only",\ .value = stringify(0),\ + },{\ + .driver = "486-" TYPE_X86_CPU,\ + .property = "model",\ + .value = stringify(0),\ }#endif target-i386/cpu.c +1
-1@@ -550,7 +550,7 @@ static x86_def_t builtin_x86_defs[] = { .level = 1, .vendor = CPUID_VENDOR_INTEL, .family = 4, - .model = 0, + .model = 8, .stepping = 0, .features = I486_FEATURES, .xlevel = 0,Signature · 1 line
1.8.1.4
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH qom-cpu for-1.5 1/4] qdev: Let qdev_prop_parse() pass through Error
In reply to Andreas FärberQuoted 3 lines · Andreas Färber
Move error reporting to callers.
Signed-off-by Andreas Färber <[email protected]>
Keeps existing behavior, and makes sense even if the rest of the series doesn't get included.
Quoted 134 lines
--- hw/core/qdev-properties.c | 25 +++++++++++-------------- hw/core/qdev.c | 7 ++++++- include/hw/qdev-properties.h | 5 +++-- qdev-monitor.c | 6 +++++- 4 files changed, 25 insertions(+), 18 deletions(-)hw/core/qdev-properties.c +11
-14@@ -986,25 +986,18 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, } } -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value) +void qdev_prop_parse (DeviceState *dev,const char *name,const char *value, +Error **errp) {char *legacy_name; -Error *err =NULL ; legacy_name =g_strdup_printf ("legacy-%s" , name);if (object_property_get_type (OBJECT (dev), legacy_name,NULL )) { -object_property_parse (OBJECT (dev), value, legacy_name, &err); +object_property_parse (OBJECT (dev), value, legacy_name, errp); }else { -object_property_parse (OBJECT (dev), value, name, &err); +object_property_parse (OBJECT (dev), value, name, errp); }g_free (legacy_name); - -if (err) { -qerror_report_err (err); -error_free (err); -return -1 ; - } -return 0 ; }void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value)@@ -1106,18 +1099,22 @@ void qdev_prop_register_global_list(GlobalProperty *props) } } -void qdev_prop_set_globals (DeviceState *dev) +void qdev_prop_set_globals (DeviceState *dev,Error **errp) {ObjectClass *class =object_get_class (OBJECT (dev)); do { GlobalProperty *prop; QTAILQ_FOREACH(prop, &global_props, next) { + Error *err = NULL; + if (strcmp(object_class_get_name(class), prop->driver) != 0) { continue; } - if (qdev_prop_parse(dev, prop->property, prop->value) != 0) { - exit(1); + qdev_prop_parse(dev, prop->property, prop->value, &err); + if (err != NULL) { + error_propagate(errp, err); + return; } } class = object_class_get_parent(class);hw/core/qdev.c +6
-1@@ -752,7 +752,12 @@ static void device_initfn(Object *obj) } class =object_class_get_parent (class); }while (class !=object_class_by_name (TYPE_DEVICE )); -qdev_prop_set_globals (dev); +qdev_prop_set_globals (dev, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err); +exit (1 ); + }object_property_add_link (OBJECT (dev),"parent_bus" ,TYPE_BUS , (Object **)&dev->parent_bus, &err);include/hw/qdev-properties.h +3
-2@@ -148,7 +148,8 @@ extern PropertyInfo qdev_prop_arraylen;/* Set properties between creation and init. */ void *qdev_get_prop_ptr (DeviceState *dev,Property *prop); -int qdev_prop_parse (DeviceState *dev,const char *name,const char *value); +void qdev_prop_parse (DeviceState *dev,const char *name,const char *value, +Error **errp);void qdev_prop_set_bit (DeviceState *dev,const char *name,bool value);void qdev_prop_set_uint8 (DeviceState *dev,const char *name,uint8_t value);void qdev_prop_set_uint16 (DeviceState *dev,const char *name,uint16_t value);@@ -167,7 +168,7 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global (GlobalProperty *prop);void qdev_prop_register_global_list (GlobalProperty *props); -void qdev_prop_set_globals (DeviceState *dev); +void qdev_prop_set_globals (DeviceState *dev,Error **errp);void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev,Property *prop,const char *value);qdev-monitor.c +5
-1@@ -105,13 +105,17 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque)static int set_property (const char *name,const char *value,void *opaque) {DeviceState *dev = opaque; +Error *err =NULL ;if (strcmp (name,"driver" ) ==0 )return 0 ;if (strcmp (name,"bus" ) ==0 )return 0 ; -if (qdev_prop_parse (dev, name, value) ==-1 ) { +qdev_prop_parse (dev, name, value, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err);return -1 ; }return 0 ;Signature · 1 line
1.8.1.4
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH qom-cpu for-1.5 2/4] qdev: Introduce qdev_prop_set_custom_globals()
In reply to Andreas FärberQuoted 3 lines · Andreas Färber
Reuse it in
qdev_prop_set_globals().Signed-off-by Andreas Färber <[email protected]>
Very useful to allow us to implement sane bugfixes while the QOM conversion is still work in progress, and much more flexible than having to write special-purpose compat functions for code that isn't completely QOMified yet.
I assume that although this works with "-global" on the command-line, we will try to use the (currently) fake class names from patch 3/4 only for the internal machine-type compat_props tables, and discourage users from using them in the command-line.
Quoted 73 lines
--- hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++----------- include/hw/qdev-properties.h | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-)hw/core/qdev-properties.c +24
-11@@ -1099,23 +1099,36 @@ void qdev_prop_register_global_list(GlobalProperty *props) } } +void qdev_prop_set_custom_globals (DeviceState *dev,const char *driver, +Error **errp) +{ +GlobalProperty *prop; + + QTAILQ_FOREACH(prop, &global_props, next) { +Error *err =NULL ; + +if (strcmp (driver, prop->driver) !=0 ) { +continue ; + } +qdev_prop_parse (dev, prop->property, prop->value, &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; + } + } +} +void qdev_prop_set_globals (DeviceState *dev,Error **errp) {ObjectClass *class =object_get_class (OBJECT (dev));do { -GlobalProperty *prop; - QTAILQ_FOREACH(prop, &global_props, next) { -Error *err =NULL ; +Error *err =NULL ; -if (strcmp (object_class_get_name (class), prop->driver) !=0 ) { -continue ; - } -qdev_prop_parse (dev, prop->property, prop->value, &err); -if (err !=NULL ) { -error_propagate (errp, err); -return ; - } +qdev_prop_set_custom_globals (dev,object_class_get_name (class), &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; } class =object_class_get_parent (class); }while (class);include/hw/qdev-properties.h +2
-0@@ -169,6 +169,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);void qdev_prop_register_global (GlobalProperty *prop);void qdev_prop_register_global_list (GlobalProperty *props);void qdev_prop_set_globals (DeviceState *dev,Error **errp); +void qdev_prop_set_custom_globals (DeviceState *dev,const char *driver, +Error **errp);void error_set_from_qdev_prop_error (Error **errp,int ret,DeviceState *dev,Property *prop,const char *value);Signature · 1 line
1.8.1.4
Signature · 1 line
Eduardo
Quoted 7 lines · Andreas Färber
Hello,
It's easier adapting the infrastructure to our needs than working around it:
X86CPU already has QOM properties today. What's lacking is model subclasses, and with the one X86CPU type its global properties are overwritten by models. But we already know the designated naming scheme for the models!
Quoted 6 lines
So let's simply prepare
compat_propsfor CPU models and make sure they are already picked up today.This works just fine for changing the 486 CPUID model value and avoids to redo the PC part once we have X86CPU subclasses.
Tested using: ./QMP/qom-get /machine/icc-bridge/icc/child[0].model
So, what's left to do with subclass modelling?
How long are we going to need to carry something like this?
It's a clever work around but I'm a bit concerned that it would grow beyond cpu subclasses and that we'd be stuck with it forever.
Regards,
Anthony Liguori
Quoted 31 lines
For changing n270 CPUID flags we'll still need to resort to Eduardo's proposed helper functions for now.
Regards,
AndreasCc Eduardo Habkost <[email protected]>Cc Igor Mammedov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Borislav Petkov <[email protected]>Cc Anthony Liguori <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Michael S. Tsirkin <[email protected]>Andreas Färber (4):
qdev: Letqdev_prop_parse()pass through Error
qdev: Introduceqdev_prop_set_custom_globals()
target-i386: Emulate X86CPU subclasses for global properties
target-i386: Change CPUID model of 486 to 8hw/core/qdev-properties.c | 50 ++++++++++++++++++++++++++------------------ hw/core/qdev.c | 7 ++++++- include/hw/i386/pc.h | 4 ++++ include/hw/qdev-properties.h | 7 +++++-- qdev-monitor.c | 6 +++++- target-i386/cpu.c | 11 +++++++++- 6 files changed, 60 insertions(+), 25 deletions(-)Signature · 1 line
1.8.1.4
Quoted 9 lines · On Fri, 03 May 2013 11:46:59 -0500 Anthony Liguori <[email protected]>…
Quoted 7 lines · Andreas Färber
Hello,
It's easier adapting the infrastructure to our needs than working around it:
X86CPU already has QOM properties today. What's lacking is model subclasses, and with the one X86CPU type its global properties are overwritten by models. But we already know the designated naming scheme for the models!
Quoted 8 lines
Quoted 6 lines
So let's simply prepare
compat_propsfor CPU models and make sure they are already picked up today.This works just fine for changing the 486 CPUID model value and avoids to redo the PC part once we have X86CPU subclasses.
Tested using: ./QMP/qom-get /machine/icc-bridge/icc/child[0].modelSo, what's left to do with subclass modelling?
I plan to resubmit static properties and then subclass modeling for 1.6.
Quoted 2 lines
How long are we going to need to carry something like this?
It will be removed with x86 CPU static properties and CPU sub-classes.
Quoted 39 lines
It's a clever work around but I'm a bit concerned that it would grow beyond cpu subclasses and that we'd be stuck with it forever.
Regards,
Anthony Liguori
Quoted 31 lines
For changing n270 CPUID flags we'll still need to resort to Eduardo's proposed helper functions for now.
Regards,
AndreasCc Eduardo Habkost <[email protected]>Cc Igor Mammedov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Borislav Petkov <[email protected]>Cc Anthony Liguori <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Michael S. Tsirkin <[email protected]>Andreas Färber (4):
qdev: Letqdev_prop_parse()pass through Error
qdev: Introduceqdev_prop_set_custom_globals()
target-i386: Emulate X86CPU subclasses for global properties
target-i386: Change CPUID model of 486 to 8hw/core/qdev-properties.c | 50 ++++++++++++++++++++++++++------------------ hw/core/qdev.c | 7 ++++++- include/hw/i386/pc.h | 4 ++++ include/hw/qdev-properties.h | 7 +++++-- qdev-monitor.c | 6 +++++- target-i386/cpu.c | 11 +++++++++- 6 files changed, 60 insertions(+), 25 deletions(-)Signature · 1 line
1.8.1.4
Signature · 2 lines
Regards, Igor
Am 03.05.2013 18:46, schrieb Anthony Liguori:
Quoted 9 lines
Quoted 7 lines · Andreas Färber
Hello,
It's easier adapting the infrastructure to our needs than working around it:
X86CPU already has QOM properties today. What's lacking is model subclasses, and with the one X86CPU type its global properties are overwritten by models. But we already know the designated naming scheme for the models!
Quoted 8 lines
Quoted 6 lines
So let's simply prepare
compat_propsfor CPU models and make sure they are already picked up today.This works just fine for changing the 486 CPUID model value and avoids to redo the PC part once we have X86CPU subclasses.
Tested using: ./QMP/qom-get /machine/icc-bridge/icc/child[0].modelSo, what's left to do with subclass modelling?
Well, in the past there had been multiple approaches:
X86CPUInfo (me)instance_init (proposed my PMM, no code)class_init (me)x86_def_t (me)
static properties (imammedo)
Either of the last three ran into issues/discussions for -cpu host.
Igor's proposal is touching on the same issue as this series:
qdev_set_global_properties() is run from device's instance_init, which is run *before* derived classes add any QOM-style properties in theirs. So for 1.6 I would rather like to amend our QOM infrastructure with an .instance_post_init hook (prior art for qdev props: .class_base_init) or otherwise allow to set global defaults for any device or QOM object than converting perfectly fine QOM properties back into qdev static properties, when it's all just for one single function call. :)
Quoted 1 line
How long are we going to need to carry something like this?
I've always been hoping to get subclasses done for the next release... That said, it depends on whether we can find an agreeable solution for the above when-do-we-set-globals problem. If we do need static properties, Igor has a patch to that effect that looked okay.
Quoted 2 lines
It's a clever work around but I'm a bit concerned that it would grow beyond cpu subclasses and that we'd be stuck with it forever.
I would've proposed to add a header comment indicating it's not to be generally used, but experience shows such comments are rarely read.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH qom-cpu for-1.5 2/4] qdev: Introduce qdev_prop_set_custom_globals()
In reply to Andreas FärberAm 01.05.2013 18:07, schrieb Andreas Färber:
Quoted 7 lines
Reuse it in
qdev_prop_set_globals().Signed-off-by Andreas Färber <[email protected]>--- hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++----------- include/hw/qdev-properties.h | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-)
Igor suggested to avoid "custom", so renaming toqdev_prop_set_globals_for_type():
hw/core/qdev-properties.c +0 -0
@@ -1099,15 +1099,15 @@ void
qdev_prop_register_global_list(GlobalProperty *props)
}
}
-void qdev_prop_set_custom_globals(DeviceState *dev, const char *driver,
- Error **errp)
+void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
+ Error **errp)
{
GlobalProperty *prop;
QTAILQ_FOREACH(prop, &global_props, next) {
Error *err = NULL;- if (strcmp(driver, prop->driver) != 0) {
+ if (strcmp(typename, prop->driver) != 0) {
continue;
}
qdev_prop_parse(dev, prop->property, prop->value, &err);
@@ -1125,7 +1125,8 @@ void qdev_prop_set_globals(DeviceState *dev, Error
**errp)
do {
Error *err = NULL;- qdev_prop_set_custom_globals(dev, object_class_get_name(class),
&err);
+ qdev_prop_set_globals_for_type(dev, object_class_get_name(class),
+ &err);
if (err != NULL) {
error_propagate(errp, err);
return;include/hw/qdev-properties.h +0 -0
@@ -169,8 +169,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char
*name, void *value);
void qdev_prop_register_global(GlobalProperty *prop);
void qdev_prop_register_global_list(GlobalProperty *props); void qdev_prop_set_globals(DeviceState *dev, Error **errp);
-void qdev_prop_set_custom_globals(DeviceState *dev, const char *driver,
- Error **errp);
+void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
+ Error **errp);
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState
*dev,
Property *prop, const char *value);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 01.05.2013 18:07, schrieb Andreas Färber:
Quoted 28 lines
Hello,
It's easier adapting the infrastructure to our needs than working around it:
X86CPU already has QOM properties today. What's lacking is model subclasses, and with the one X86CPU type its global properties are overwritten by models. But we already know the designated naming scheme for the models!So let's simply prepare
compat_propsfor CPU models and make sure they are already picked up today.This works just fine for changing the 486 CPUID model value and avoids to redo the PC part once we have X86CPU subclasses.
Tested using: ./QMP/qom-get /machine/icc-bridge/icc/child[0].modelFor changing n270 CPUID flags we'll still need to resort to Eduardo's proposed helper functions for now.
Regards,
AndreasCc Eduardo Habkost <[email protected]>Cc Igor Mammedov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Borislav Petkov <[email protected]>Cc Anthony Liguori <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Michael S. Tsirkin <[email protected]>
Quoted 5 lines
Andreas Färber (4):
qdev: Letqdev_prop_parse()pass through Error
qdev: Introduceqdev_prop_set_custom_globals()
target-i386: Emulate X86CPU subclasses for global properties
target-i386: Change CPUID model of 486 to 8
Hearing no veto from Anthony on IRC, I have applied these to qom-cpu (with helper function renamed):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Andreas
Quoted 9 lines
hw/core/qdev-properties.c | 50 ++++++++++++++++++++++++++------------------ hw/core/qdev.c | 7 ++++++- include/hw/i386/pc.h | 4 ++++ include/hw/qdev-properties.h | 7 +++++-- qdev-monitor.c | 6 +++++- target-i386/cpu.c | 11 +++++++++- 6 files changed, 60 insertions(+), 25 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg