mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
cpu: Use CPUClass->parse_features() as convertor to global properties
Currently CPUClass->parse_features() is used to parse -cpu features string and set properties on created CPU instances. But considering that features specified by -cpu apply to every created CPU instance, it doesn't make sense to parse the same features string for every CPU created. It also makes every target that cares about parsing features string explicitly call CPUClass->parse_features() parser, which gets in a way if we consider using generic device_add for CPU hotplug as device_add has not a clue about CPU specific hooks. Turns out we can use global properties mechanism to set properties on every created CPU instance for a given type. That way it's possible to convert CPU features into a set of global properties for CPU type specified by -cpu cpu_model and common Device.device_post_init() will apply them to CPU of given type automatically regardless whether it's manually created CPU or CPU created with help of device_add. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
cf2887c973
commit
62a48a2a57
4 changed files with 54 additions and 22 deletions
|
@ -1261,6 +1261,7 @@ static void machvirt_init(MachineState *machine)
|
|||
|
||||
for (n = 0; n < smp_cpus; n++) {
|
||||
ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
|
||||
const char *typename = object_class_get_name(oc);
|
||||
CPUClass *cc = CPU_CLASS(oc);
|
||||
Object *cpuobj;
|
||||
Error *err = NULL;
|
||||
|
@ -1270,10 +1271,10 @@ static void machvirt_init(MachineState *machine)
|
|||
error_report("Unable to find CPU definition");
|
||||
exit(1);
|
||||
}
|
||||
cpuobj = object_new(object_class_get_name(oc));
|
||||
/* convert -smp CPU options specified by the user into global props */
|
||||
cc->parse_features(typename, cpuopts, &err);
|
||||
cpuobj = object_new(typename);
|
||||
|
||||
/* Handle any CPU options specified by the user */
|
||||
cc->parse_features(CPU(cpuobj), cpuopts, &err);
|
||||
g_free(cpuopts);
|
||||
if (err) {
|
||||
error_report_err(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue