spapr: Support setting of compat CPU type for CPU cores
RFC PATCH 1/1 spapr: Support setting of compat CPU type for CPU cores
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.
Support the specification of CPU compat type on device_add command for sPAPRCPUCore devices like:
(qemu) device_add POWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24
---
Applies on ppc-for-2.7 branch of David Gibson's tree.
hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)
hw/ppc/spapr.c +8 -0
@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine)if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) {error_report ("Unable to find sPAPR CPU Core definition" );
@@ -1818,6 +1819,13 @@ static void ppc_spapr_init(MachineState *machine) &error_fatal);object_property_set_int (core, core_dt_id,CPU_CORE_PROP_CORE_ID , &error_fatal); + compat =spapr_get_cpu_compat_type (machine->cpu_model); +if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } +object_property_set_bool (core, true,"realized" , &error_fatal); } }
hw/ppc/spapr_cpu_core.c +73 -0
124 lines not on this page · raw message
include/hw/ppc/spapr_cpu_core.h +2 -0
@@ -24,11 +24,13 @@ typedef struct sPAPRCPUCore {/*< public >*/ void *threads;ObjectClass *cpu_class; +char *cpu_compat; } sPAPRCPUCore;void spapr_core_pre_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);char *spapr_get_cpu_core_type (const char *model); +char *spapr_get_cpu_compat_type (const char *model);void spapr_core_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Signature · 1 line
2.1.0
Quoted 5 lines · Bharata B Rao
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.
Quoted 7 lines
Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.
The implementation looks ok apart from a few nits noted below.
There's a larger problem here, though, in that this doesn't advertise the necessary compat= property via query-hotpluggable-cpus qmp and hmp interfaces. Which means that management has no good way of knowing it's necessary.
Quoted 65 lines
hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +8
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine)if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) {error_report ("Unable to find sPAPR CPU Core definition" );@@ -1818,6 +1819,13 @@ static void ppc_spapr_init(MachineState *machine) &error_fatal);object_property_set_int (core, core_dt_id,CPU_CORE_PROP_CORE_ID , &error_fatal); + compat =spapr_get_cpu_compat_type (machine->cpu_model); +if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } +object_property_set_bool (core, true,"realized" , &error_fatal); } }hw/ppc/spapr_cpu_core.c +18
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model) +{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 ); + +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } + +g_strfreev (model_pieces); +return compat_type; +} +static void spapr_core_release (DeviceState *dev,void *opaque) {sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev));@@ -223,12 +241,31 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,CPUCore *cc =CPU_CORE (dev);char *base_core_type =spapr_get_cpu_core_type (machine->cpu_model);const char *type =object_get_typename (OBJECT (dev));
hw/ppc/spapr_cpu_core.c void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, · line 253
Quoted 10 lines
hw/ppc/spapr_cpu_core.c +4
-0+char *base_compat_type =NULL ; +char *compat =NULL ; +bool compat_set;if (strcmp (base_core_type, type)) {error_setg (&local_err,"CPU core type should be %s" , base_core_type); goto out; } + base_compat_type =spapr_get_cpu_compat_type (machine->cpu_model);
This can go in the initializer to match the base_core_type.
hw/ppc/spapr_cpu_core.c void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, · line 255
Quoted 2 lines
hw/ppc/spapr_cpu_core.c +2
-0+ compat =object_property_get_str (OBJECT (dev),"compat" ,NULL ); + compat_set = (compat && *compat) ? true : false;
You don't need the ?:, the condition is already a boolean.
Quoted 26 lines
hw/ppc/spapr_cpu_core.c +15
-0+ +if (base_compat_type) { +if ((compat_set &&strcmp (base_compat_type, compat)) || + !compat_set) { +error_setg (&local_err,"CPU compat type should be %s" , + base_compat_type); + goto out; + } + }else if (compat_set) { +error_setg (&local_err,"CPU compat type shouldn't be set" ); + goto out; + } +if (!smc->dr_cpu_enabled && dev->hotplugged) {error_setg (&local_err,"CPU hotplug not supported for this machine" ); goto out;@@ -256,6 +293,8 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, } out: +g_free (compat); +g_free (base_compat_type);g_free (base_core_type);error_propagate (errp, local_err); }
hw/ppc/spapr_cpu_core.c static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) · line 331
Quoted 5 lines
hw/ppc/spapr_cpu_core.c +2
-0@@ -288,6 +327,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)Error *local_err =NULL ;Object *obj;int i; +char *compat =object_property_get_str (OBJECT (sc),"compat" ,NULL ); +bool compat_set = (compat && *compat) ? true : false;
Again, don't need ?: here.
Quoted 5 lines
hw/ppc/spapr_cpu_core.c +0
-0sc->threads =g_malloc0 (size * cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) {@@ -298,9 +339,19 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)snprintf (id,sizeof (id),"thread[%d]" , i);
hw/ppc/spapr_cpu_core.c static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) · line 349
Quoted 10 lines
hw/ppc/spapr_cpu_core.c +6
-0object_property_add_child (OBJECT (sc), id, obj, &local_err);if (local_err) { +g_free (compat); goto err; } +if (compat_set) { +CPUClass *cc =CPU_GET_CLASS (CPU (obj)); +char *featurestr =g_strdup_printf ("compat=%s" , compat); + + cc->parse_features (CPU (obj), featurestr, &local_err);
Hmm.. would it make more sense to just do an object_property_set() rather than calling into parse_features?
Quoted 62 lines
hw/ppc/spapr_cpu_core.c +26
-0+g_free (featurestr); + } } + +g_free (compat);object_child_foreach (OBJECT (dev), spapr_cpu_core_realize_child, &local_err);if (local_err) { goto err;@@ -318,6 +369,27 @@ err:error_propagate (errp, local_err); } +static char *spapr_cpu_core_prop_get_compat (Object *obj,Error **errp) +{ +sPAPRCPUCore *core =SPAPR_CPU_CORE (obj); + +return g_strdup (core->cpu_compat); +} + +static void spapr_cpu_core_prop_set_compat (Object *obj,const char *val, +Error **errp) +{ +sPAPRCPUCore *core =SPAPR_CPU_CORE (obj); + + core->cpu_compat =g_strdup (val); +} + +static void spapr_cpu_core_instance_init (Object *obj) +{ +object_property_add_str (obj,"compat" , spapr_cpu_core_prop_get_compat, + spapr_cpu_core_prop_set_compat,NULL ); +} +static void spapr_cpu_core_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);@@ -388,6 +460,7 @@ static const TypeInfo spapr_cpu_core_type_info = { .parent = TYPE_CPU_CORE, .abstract = true, .instance_size = sizeof(sPAPRCPUCore), + .instance_init = spapr_cpu_core_instance_init, .class_init = spapr_cpu_core_class_init, };include/hw/ppc/spapr_cpu_core.h +2
-0@@ -24,11 +24,13 @@ typedef struct sPAPRCPUCore {/*< public >*/ void *threads;ObjectClass *cpu_class; +char *cpu_compat; } sPAPRCPUCore;void spapr_core_pre_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);char *spapr_get_cpu_core_type (const char *model); +char *spapr_get_cpu_compat_type (const char *model);void spapr_core_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 90 lines · David Gibson
Quoted 5 lines · Bharata B Rao
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Quoted 7 lines
Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.The implementation looks ok apart from a few nits noted below.
There's a larger problem here, though, in that this doesn't advertise the necessary compat= property via query-hotpluggable-cpus qmp and hmp interfaces. Which means that management has no good way of knowing it's necessary.
Quoted 69 lines
hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +8
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine)if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) {error_report ("Unable to find sPAPR CPU Core definition" );@@ -1818,6 +1819,13 @@ static void ppc_spapr_init(MachineState *machine) &error_fatal);object_property_set_int (core, core_dt_id,CPU_CORE_PROP_CORE_ID , &error_fatal); + compat =spapr_get_cpu_compat_type (machine->cpu_model); +if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } +object_property_set_bool (core, true,"realized" , &error_fatal); } }hw/ppc/spapr_cpu_core.c +21
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model) +{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 ); + +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } + +g_strfreev (model_pieces); +return compat_type; +} +static void spapr_core_release (DeviceState *dev,void *opaque) {sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev));@@ -223,12 +241,31 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,CPUCore *cc =CPU_CORE (dev);char *base_core_type =spapr_get_cpu_core_type (machine->cpu_model);const char *type =object_get_typename (OBJECT (dev)); +char *base_compat_type =NULL ; +char *compat =NULL ; +bool compat_set;
Quoted 8 lines
hw/ppc/spapr_cpu_core.c void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, · line 253
Quoted 6 lines
hw/ppc/spapr_cpu_core.c +1
-0if (strcmp (base_core_type, type)) {error_setg (&local_err,"CPU core type should be %s" , base_core_type); goto out; } + base_compat_type =spapr_get_cpu_compat_type (machine->cpu_model);This can go in the initializer to match the
base_core_type.
Had it that way, but since there was an error exit possibility when base_core_type is not matching, I thought better to initialize base_compat_type after that check.
Quoted 5 lines
hw/ppc/spapr_cpu_core.c void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, · line 255
Quoted 3 lines
hw/ppc/spapr_cpu_core.c +2
-0+ compat =object_property_get_str (OBJECT (dev),"compat" ,NULL ); + compat_set = (compat && *compat) ? true : false;You don't need the ?:, the condition is already a boolean.
Yeah.
Quoted 45 lines
Quoted 27 lines
hw/ppc/spapr_cpu_core.c +15
-0+ +if (base_compat_type) { +if ((compat_set &&strcmp (base_compat_type, compat)) || + !compat_set) { +error_setg (&local_err,"CPU compat type should be %s" , + base_compat_type); + goto out; + } + }else if (compat_set) { +error_setg (&local_err,"CPU compat type shouldn't be set" ); + goto out; + } +if (!smc->dr_cpu_enabled && dev->hotplugged) {error_setg (&local_err,"CPU hotplug not supported for this machine" ); goto out;@@ -256,6 +293,8 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, } out: +g_free (compat); +g_free (base_compat_type);g_free (base_core_type);error_propagate (errp, local_err); }hw/ppc/spapr_cpu_core.c static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) · line 331
Quoted 5 lines
hw/ppc/spapr_cpu_core.c +2
-0@@ -288,6 +327,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)Error *local_err =NULL ;Object *obj;int i; +char *compat =object_property_get_str (OBJECT (sc),"compat" ,NULL ); +bool compat_set = (compat && *compat) ? true : false;Again, don't need ?: here.
Quoted 10 lines
hw/ppc/spapr_cpu_core.c +1
-0sc->threads =g_malloc0 (size * cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) {@@ -298,9 +339,19 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)snprintf (id,sizeof (id),"thread[%d]" , i);object_property_add_child (OBJECT (sc), id, obj, &local_err);if (local_err) { +g_free (compat); goto err; }
Quoted 8 lines
hw/ppc/spapr_cpu_core.c static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) · line 349
Quoted 5 lines
hw/ppc/spapr_cpu_core.c +5
-0+if (compat_set) { +CPUClass *cc =CPU_GET_CLASS (CPU (obj)); +char *featurestr =g_strdup_printf ("compat=%s" , compat); + + cc->parse_features (CPU (obj), featurestr, &local_err);Hmm.. would it make more sense to just do an
object_property_set()rather than calling intoparse_features?
It would work, but I guess better to use ->parse_features() to ensure future additional properties would work seamlessly.
Regards,
Bharata.
Quoted 96 lines · Bharata B Rao
Quoted 95 lines · David Gibson
Quoted 5 lines · Bharata B Rao
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Quoted 7 lines
Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.The implementation looks ok apart from a few nits noted below.
There's a larger problem here, though, in that this doesn't advertise the necessary compat= property via query-hotpluggable-cpus qmp and hmp interfaces. Which means that management has no good way of knowing it's necessary.
Quoted 74 lines
hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +8
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine)if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) {error_report ("Unable to find sPAPR CPU Core definition" );@@ -1818,6 +1819,13 @@ static void ppc_spapr_init(MachineState *machine) &error_fatal);object_property_set_int (core, core_dt_id,CPU_CORE_PROP_CORE_ID , &error_fatal); + compat =spapr_get_cpu_compat_type (machine->cpu_model); +if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } +object_property_set_bool (core, true,"realized" , &error_fatal); } }hw/ppc/spapr_cpu_core.c +21
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model) +{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 ); + +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } + +g_strfreev (model_pieces); +return compat_type; +} +static void spapr_core_release (DeviceState *dev,void *opaque) {sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev));@@ -223,12 +241,31 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,CPUCore *cc =CPU_CORE (dev);char *base_core_type =spapr_get_cpu_core_type (machine->cpu_model);const char *type =object_get_typename (OBJECT (dev)); +char *base_compat_type =NULL ; +char *compat =NULL ; +bool compat_set;if (strcmp (base_core_type, type)) {error_setg (&local_err,"CPU core type should be %s" , base_core_type); goto out; }
Quoted 7 lines
Quoted 3 lines
hw/ppc/spapr_cpu_core.c void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, · line 253
Quoted 1 line
hw/ppc/spapr_cpu_core.c +1
-0+ base_compat_type =spapr_get_cpu_compat_type (machine->cpu_model);This can go in the initializer to match the
base_core_type.Had it that way, but since there was an error exit possibility when
base_core_typeis not matching, I thought better to initializebase_compat_typeafter that check.
Ah, good point. I forgot that get_cpu_compat_type() had an implicit allocation that needs cleanup.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
hw/ppc/spapr_cpu_core.c +1
-0@@ -298,9 +339,19 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)snprintf (id,sizeof (id),"thread[%d]" , i);object_property_add_child (OBJECT (sc), id, obj, &local_err);if (local_err) { +g_free (compat); goto err; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) · line 349
Quoted 5 lines
hw/ppc/spapr_cpu_core.c +5
-0+if (compat_set) { +CPUClass *cc =CPU_GET_CLASS (CPU (obj)); +char *featurestr =g_strdup_printf ("compat=%s" , compat); + + cc->parse_features (CPU (obj), featurestr, &local_err);Hmm.. would it make more sense to just do an
object_property_set()rather than calling intoparse_features?
Quoted 2 lines
It would work, but I guess better to use ->parse_features() to ensure future additional properties would work seamlessly.
Hmm.. except that the string you're forming to pass to parse_features is always just "compat=%s". So you'd have to change that bit anyway, so I don't see that using parse_features really buys you anything.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 17 lines · Bharata B Rao
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)
[...]
Quoted 15 lines
hw/ppc/spapr_cpu_core.c +7
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model) +{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 );
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 115
Quoted 10 lines
hw/ppc/spapr_cpu_core.c +10
-0+ +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } + +g_strfreev (model_pieces); +return compat_type; +}
Shouldn't you check for "compat=" somewhere in this function (and properly iterate over all parts of the comma separated string)? In case we support more properties than "compat=" some day, this will go wrong otherwise...
Thomas
Quoted 41 lines · Thomas Huth
Quoted 17 lines · Bharata B Rao
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ 3 files changed, 83 insertions(+)[...]
Quoted 22 lines
hw/ppc/spapr_cpu_core.c +14
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model) +{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 ); + +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } +
Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 115
Quoted 3 lines
hw/ppc/spapr_cpu_core.c +3
-0+g_strfreev (model_pieces); +return compat_type; +}Shouldn't you check for "compat=" somewhere in this function (and properly iterate over all parts of the comma separated string)? In case we support more properties than "compat=" some day, this will go wrong otherwise...
Currently since it is only "compat=", anything else would fail gracefully when the property gets set. But obviously that is not future-safe as you note. Let me rework on this.
Regards,
Bharata
Quoted 52 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +6
-0+if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 7 lines
hw/ppc/spapr_cpu_core.c +4
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; } +/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)
CPUClass already has such parser and hook to override it in case of target does legacy parsing, see CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...
it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property in spapr_core type.
Quoted 145 lines
hw/ppc/spapr_cpu_core.c +14
-0+{ +char *compat_type =NULL ; +gchar **model_pieces =g_strsplit (model,"," ,2 ); + +if (model_pieces[1 ]) { +gchar **compat_pieces =g_strsplit (model_pieces[1 ],"=" ,2 ); + + compat_type =g_strdup_printf ("%s" , compat_pieces[1 ]); + } + +g_strfreev (model_pieces); +return compat_type; +} +static void spapr_core_release (DeviceState *dev,void *opaque) {sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev));@@ -223,12 +241,31 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, CPUCore *cc =CPU_CORE (dev); char *base_core_type =
spapr_get_cpu_core_type(machine->cpu_model); const char *type = object_get_typename(OBJECT(dev));hw/ppc/spapr_cpu_core.c +3
-0+char *base_compat_type =NULL ; +char *compat =NULL ; +bool compat_set;if (strcmp (base_core_type, type)) { error_setg(&local_err, "CPU core type should be %s",base_core_type); goto out; }hw/ppc/spapr_cpu_core.c +16
-0+ base_compat_type =spapr_get_cpu_compat_type (machine->cpu_model); + compat =object_property_get_str (OBJECT (dev),"compat" ,NULL ); + compat_set = (compat && *compat) ? true : false; + +if (base_compat_type) { +if ((compat_set &&strcmp (base_compat_type, compat)) || + !compat_set) { +error_setg (&local_err,"CPU compat type should be %s" , + base_compat_type); + goto out; + } + }else if (compat_set) { +error_setg (&local_err,"CPU compat type shouldn't be set" ); + goto out; + } +if (!smc->dr_cpu_enabled && dev->hotplugged) { error_setg(&local_err, "CPU hotplug not supported for thismachine"); goto out;
hw/ppc/spapr_cpu_core.c +4
-0@@ -256,6 +293,8 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, } out: +g_free (compat); +g_free (base_compat_type);g_free (base_core_type);error_propagate (errp, local_err); }@@ -288,6 +327,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) Error *local_err = NULL;Object *obj;int i; +char *compat =object_property_get_str (OBJECT (sc),"compat" ,NULL ); +bool compat_set = (compat && *compat) ? true : false; sc->threads =g_malloc0 (size * cc->nr_threads);for (i = 0; i < cc->nr_threads; i++) {hw/ppc/spapr_cpu_core.c +31
-0@@ -298,9 +339,19 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) snprintf(id, sizeof(id), "thread[%d]", i);object_property_add_child (OBJECT (sc), id, obj, &local_err);if (local_err) { +g_free (compat); goto err; } +if (compat_set) { +CPUClass *cc =CPU_GET_CLASS (CPU (obj)); +char *featurestr =g_strdup_printf ("compat=%s" , compat); + + cc->parse_features (CPU (obj), featurestr, &local_err); +g_free (featurestr); + } } + +g_free (compat);object_child_foreach (OBJECT (dev), spapr_cpu_core_realize_child, &local_err);if (local_err) { goto err;@@ -318,6 +369,27 @@ err:error_propagate (errp, local_err); } +static char *spapr_cpu_core_prop_get_compat (Object *obj,Error **errp) +{ +sPAPRCPUCore *core =SPAPR_CPU_CORE (obj); + +return g_strdup (core->cpu_compat); +} + +static void spapr_cpu_core_prop_set_compat (Object *obj,const char *val, +Error **errp) +{ +sPAPRCPUCore *core =SPAPR_CPU_CORE (obj); + + core->cpu_compat =g_strdup (val); +} + +static void spapr_cpu_core_instance_init (Object *obj) +{ +object_property_add_str (obj,"compat" , spapr_cpu_core_prop_get_compat, + spapr_cpu_core_prop_set_compat,NULL ); +} +static void spapr_cpu_core_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);@@ -388,6 +460,7 @@ static const TypeInfo spapr_cpu_core_type_info = { .parent = TYPE_CPU_CORE, .abstract = true, .instance_size = sizeof(sPAPRCPUCore), + .instance_init = spapr_cpu_core_instance_init, .class_init = spapr_cpu_core_class_init, };(quoted diff) +0
-0
b/include/hw/ppc/spapr_cpu_core.hindex 1c9b319..e697dab 100644include/hw/ppc/spapr_cpu_core.h +2
-0@@ -24,11 +24,13 @@ typedef struct sPAPRCPUCore {/*< public >*/ void *threads;ObjectClass *cpu_class; +char *cpu_compat; } sPAPRCPUCore;void spapr_core_pre_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);char *spapr_get_cpu_core_type (const char *model); +char *spapr_get_cpu_compat_type (const char *model);void spapr_core_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
On Tue, 21 Jun 2016 09:09:57 +0200
Igor Mammedov <[email protected]> wrote:
[...]
Quoted 2 lines
However we are in progress [1] of converting legacy
1) https://www.mail-archive.com/[email protected]/msg378123.html
Quoted 8 lines
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.
[...]
Quoted 58 lines · Igor Mammedov
Quoted 55 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +6
-0+if (compat) { +object_property_set_str (core, compat,"compat" , + &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)return core_type; }
Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.
In fact, I am already using CPUClass->parse_features() to set the feature properties (which right now is only compat= for us) for core device.
What I need in the above routine spapr_get_cpu_compat_type() is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.
Quoted 9 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.
Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
Regards,
Bharata.
Quoted 83 lines · On Wed, 22 Jun 2016 08:00:28 +0530 Bharata B Rao <[email protected]>…
Quoted 59 lines · Igor Mammedov
Quoted 56 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option
like: -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +2
-0+if (compat) { + object_property_set_str(core, compat,"compat",
hw/ppc/spapr.c +4
-0+ &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.In fact, I am already using
CPUClass->parse_features()to set the feature properties (which right now is only compat= for us) for core device.What I need in the above routine
spapr_get_cpu_compat_type()is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.Quoted 6 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...
Quoted 8 lines
Quoted 4 lines
it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
You can use -global without that work but so far it looks like it will make into 2.7.
CCed Eduardo so he could say it for sure as it goes via his tree.
Quoted 5 lines
Regards,
Bharata.
Quoted 91 lines · Igor Mammedov
Quoted 88 lines · On Wed, 22 Jun 2016 08:00:28 +0530 Bharata B Rao <[email protected]>…
Quoted 59 lines · Igor Mammedov
Quoted 56 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option
like: -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +2
-0+if (compat) { + object_property_set_str(core, compat,"compat",
hw/ppc/spapr.c +4
-0+ &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.In fact, I am already using
CPUClass->parse_features()to set the feature properties (which right now is only compat= for us) for core device.What I need in the above routine
spapr_get_cpu_compat_type()is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.Quoted 10 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.
Quoted 5 lines
Quoted 3 lines
Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
You can use -global without that work but so far it looks like it will make into 2.7.
I expect the -cpu => globals series to be included soon, unless there are objections by others.
But as Igor said, globals are already supported. If you want to set a property in the CPU core objects, you just need to use:
-global spapr-cpu-core.compat=XXX
The conflict here seems to be that you want the "-cpu" option to affect the cpu-core objects, not just the VCPU/thread objects. But we have been assuming that "-cpu" would only affect the VCPU/thread objects.
What if you just call the cpu_common_parse_features() function from Igor's series using "spapr-cpu-core" as the typename? This way all the "-cpu" options would be simply translated to spapr-cpu-core global properties.
Is "core" the only property in TYPE_POWERPC_CPU, currently?
Signature · 1 line
Eduardo
Quoted 104 lines · Eduardo Habkost
Quoted 91 lines · Igor Mammedov
Quoted 88 lines · On Wed, 22 Jun 2016 08:00:28 +0530 Bharata B Rao <[email protected]>…
Quoted 59 lines · Igor Mammedov
Quoted 56 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option
like: -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +2
-0+if (compat) { + object_property_set_str(core, compat,"compat",
hw/ppc/spapr.c +4
-0+ &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.In fact, I am already using
CPUClass->parse_features()to set the feature properties (which right now is only compat= for us) for core device.What I need in the above routine
spapr_get_cpu_compat_type()is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.Quoted 10 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.Quoted 5 lines
Quoted 3 lines
Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
You can use -global without that work but so far it looks like it will make into 2.7.
I expect the -cpu => globals series to be included soon, unless there are objections by others.
But as Igor said, globals are already supported. If you want to set a property in the CPU core objects, you just need to use:
Quoted 6 lines
-global spapr-cpu-core.compat=XXX
The conflict here seems to be that you want the "-cpu" option to affect the cpu-core objects, not just the VCPU/thread objects. But we have been assuming that "-cpu" would only affect the VCPU/thread objects.
-cpu property affects the CPU thread objects in our case too. Since those CPU thread objects are aggregated under a core object, I was attempting to add compat= with core device and validate that with -cpu type,compat= from cmdline.
What we really need is this:
If -global cputype.compat= or -cpu cpuname,compat= is set, we need to apply the same to all the CPU thread objects of cpu core object. Hence I am thinking we don't need a separate property for this in the core object.
Regards,
Bharata.
Quoted 117 lines · Bharata B Rao
Quoted 104 lines · Eduardo Habkost
Quoted 91 lines · Igor Mammedov
Quoted 88 lines · On Wed, 22 Jun 2016 08:00:28 +0530 Bharata B Rao <[email protected]>…
Quoted 59 lines · Igor Mammedov
Quoted 56 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option
like: -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +2
-0+if (compat) { + object_property_set_str(core, compat,"compat",
hw/ppc/spapr.c +4
-0+ &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.In fact, I am already using
CPUClass->parse_features()to set the feature properties (which right now is only compat= for us) for core device.What I need in the above routine
spapr_get_cpu_compat_type()is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.Quoted 10 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.Quoted 5 lines
Quoted 3 lines
Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
You can use -global without that work but so far it looks like it will make into 2.7.
I expect the -cpu => globals series to be included soon, unless there are objections by others.
But as Igor said, globals are already supported. If you want to set a property in the CPU core objects, you just need to use:
Quoted 6 lines
-global spapr-cpu-core.compat=XXX
The conflict here seems to be that you want the "-cpu" option to affect the cpu-core objects, not just the VCPU/thread objects. But we have been assuming that "-cpu" would only affect the VCPU/thread objects.
-cpu property affects the CPU thread objects in our case too. Since those CPU thread objects are aggregated under a core object, I was attempting to add compat= with core device and validate that with -cpu type,compat= from cmdline.
Quoted 5 lines
What we really need is this:
If -global cputype.compat= or -cpu cpuname,compat= is set, we need to apply the same to all the CPU thread objects of cpu core object. Hence I am thinking we don't need a separate property for this in the core object.
Right, I was just coming to the same conclusion. Since we always need to set the compat property uniformly, I don't think we actually need to bounce this information via the core object. Instead, the user can either use -global or -cpu to set it directly on all thread objects.
In the unlikely event we ever have a setup where we need different cores in different compat modes we can add a property to the core object then.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 117 lines · Bharata B Rao
Quoted 104 lines · Eduardo Habkost
Quoted 91 lines · Igor Mammedov
Quoted 88 lines · On Wed, 22 Jun 2016 08:00:28 +0530 Bharata B Rao <[email protected]>…
Quoted 59 lines · Igor Mammedov
Quoted 56 lines · On Sat, 18 Jun 2016 14:04:06 +0530 Bharata B Rao <[email protected]>…
Compat CPU type is typically specified on -cpu cmdline option
like: -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. With the introduction of sPAPR CPU core devices, we need to support the same for core devices too.Support the specification of CPU compat type on
device_addcommand for sPAPRCPUCore devices like:
(qemu)device_addPOWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24Signed-off-by Bharata B Rao <[email protected]>---
Applies on ppc-for-2.7 branch of David Gibson's tree.hw/ppc/spapr.c | 8 +++++ hw/ppc/spapr_cpu_core.c | 73+++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_core.h| 2 ++ 3 files changed, 83 insertions(+)hw/ppc/spapr.c +1
-0@@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine) if (i < spapr_cores) {char *type =spapr_get_cpu_core_type (machine->cpu_model);Object *core; +char *compat;if (!object_class_by_name (type)) { error_report("Unable to find sPAPR CPU Coredefinition"); @@ -1818,6 +1819,13 @@ static void
ppc_spapr_init(MachineState *machine)&error_fatal);
object_property_set_int(core,core_dt_id,CPU_CORE_PROP_CORE_ID,&error_fatal);
+ compat =spapr_get_cpu_compat_type(machine->cpu_model);hw/ppc/spapr.c +2
-0+if (compat) { + object_property_set_str(core, compat,"compat",
hw/ppc/spapr.c +4
-0+ &error_fatal); +g_free (compat); + } + object_property_set_bool(core, true, "realized",
&error_fatal); }}hw/ppc/spapr_cpu_core.c +0
-0@@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; }Quoted 8 lines
hw/ppc/spapr_cpu_core.c char *spapr_get_cpu_core_type(const char *model) · line 102
Quoted 4 lines
hw/ppc/spapr_cpu_core.c +4
-0+/* +* Returns the CPU compat type specified in -cpu @model. +*/ +char *spapr_get_cpu_compat_type (const char *model)CPUClass already has such parser and hook to override it in case of target does legacy parsing, see
CPUClass->parse_features. Maybe extending generic core in similar way and reusing generic parser will do the job.In fact, I am already using
CPUClass->parse_features()to set the feature properties (which right now is only compat= for us) for core device.What I need in the above routine
spapr_get_cpu_compat_type()is to extract "compat=", so that I can verify that the compat type specified with -device matches with what was specified with -cpu.Quoted 10 lines
However we are in progress [1] of converting legacy
-cpu cpuname,feat1=x,feat2=y,...
into a set of global properties
-global cputype.feat1=x ...it would be better if you wouldn't start using -cpu for features but use directly -global mechanism,
for that you need only have a corresponding property inspapr_coretype.Quoted 5 lines
Quoted 3 lines
Will this work be part of 2.7 ? If not, we will have to use -cpu to extract the compat type since powerpc core hotplug is already upstream.
You can use -global without that work but so far it looks like it will make into 2.7.
I expect the -cpu => globals series to be included soon, unless there are objections by others.
But as Igor said, globals are already supported. If you want to set a property in the CPU core objects, you just need to use:
Quoted 6 lines
-global spapr-cpu-core.compat=XXX
The conflict here seems to be that you want the "-cpu" option to affect the cpu-core objects, not just the VCPU/thread objects. But we have been assuming that "-cpu" would only affect the VCPU/thread objects.
-cpu property affects the CPU thread objects in our case too. Since those CPU thread objects are aggregated under a core object, I was attempting to add compat= with core device and validate that with -cpu type,compat= from cmdline.
Quoted 5 lines
What we really need is this:
If -global cputype.compat= or -cpu cpuname,compat= is set, we need to apply the same to all the CPU thread objects of cpu core object. Hence I am thinking we don't need a separate property for this in the core object.
I assumed you really needed a spapr-cpu-core property for some other reason. If all you need is to affect the VCPU thread objects, then you only need cpu_common_parse_features() (the default implementation of CPUClass::parse_features()).
Note that Igor's series is changing the CPUClass::parse_features() interface. The current version needs to be called once for each CPU, the version by Igor will call it only once, before CPU creation. I suggest using his series as base, so you don't need to redo your work later.
If everything goes well, I plan to submit a pull request including his series on Monday.
Signature · 1 line
Eduardo