Introduce (x86) CPU model deprecation API
PATCH v3 1/2 Introduce (x86) CPU model deprecation API
Complement versioned CPU model framework with the ability of marking some versions deprecated. When that CPU model is chosen, get some warning. The warning message is customized, e.g. telling in which future QEMU version will it be obsoleted.
The deprecation message will also appear by x86_cpu_list_entry(), e.g. '-cpu help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the deprecation status.
---
Changelog
v3:
Make the deprecation implementation CPUClass generic.
v2:
Move deprecation check from parse_cpu_option() to machine_run_board_init(), so that it can cover implicit cpu_type assignment cases.
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)
hw/core/machine.c +10 -2
@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,void machine_run_board_init (MachineState *machine) {MachineClass *machine_class =MACHINE_GET_CLASS (machine); +ObjectClass *oc =object_class_by_name (machine->cpu_type); +CPUClass *cc;if (machine->ram_memdev_id) {Object *o;
@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine)* specified a CPU with -cpu check here that the user CPU is supported. */ if (machine_class->valid_cpu_types && machine->cpu_type) { -ObjectClass *class =object_class_by_name (machine->cpu_type);int i;for (i =0 ; machine_class->valid_cpu_types[i]; i++) { -if (object_class_dynamic_cast (class, +if (object_class_dynamic_cast (oc, machine_class->valid_cpu_types[i])) {/* The user specificed CPU is in the valid field, we are * good to go.
@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { +warn_report ("CPU model %s is deprecated -- %s" , machine->cpu_type, + cc->deprecation_note); + } + machine_class->init (machine); }
include/hw/core/cpu.h +6 -0
@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. +* @deprecated: True if this CPU model is deprecated (going to be removed in +* near future). +* @deprecation_note: Message about the deprecation. e.g. Since which version +* will it be obsoleted. * * Represents a CPU family or model. */
@@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;
qapi/machine-target.json +6 -1
@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stop being # migration-safe in the future (since 4.1) # +# @deprecated: If true, this CPU model is deprecated and may be removed in +# in some future version of QEMU according to the QEMU deprecation +# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known
@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } ##
target/i386/cpu.c +23 -6
@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */
@@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu-definitions */ bool is_alias; +/* +* If true, this model is deprecated, and may be removed in the future. +* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */
@@ -5096,6 +5102,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; + info->deprecated = cc->model ? cc->model->deprecated : false;/* * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions.
@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note); }static void x86_register_cpu_model_type (const char *name,X86CPUModel *model)
@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version; - m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated; +/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note; + } +x86_register_cpu_model_type (name, vm);if (vdef->alias) {X86CPUModel *am =g_new0 (X86CPUModel,1 ); am->cpudef = def; am->version = vdef->version; am->is_alias = true; + am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am); } }
Signature · 1 line
1.8.3.1
PATCH v3 2/2 Mark Icelake-Client CPU models deprecated
Going to obsolete Icelake-Client CPU models in the future.
---
Change log
v3:
Obsolete in v5.2 --> v5.3.
target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
target/i386/cpu.c +9 -1
@@ -3467,7 +3467,12 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition []) { - { .version =1 }, + { + .version =1 , + .deprecated = true, + .note ="Deprecated. Will be obsoleted in v5.3. Please use " +"'Icelake-Server-v1' CPU model" , + }, { .version =2 , .note ="no TSX" ,
@@ -3477,6 +3482,9 @@ static X86CPUDefinition builtin_x86_defs[] = { { "rtm", "off" }, { /* end of list */ } }, + .deprecated = true, + .note = "Deprecated. Will be obsoleted in v5.3. Please use " + "'Icelake-Server-v2' CPU model", }, { /* end of list */ } }
Signature · 1 line
1.8.3.1
Re: [PATCH v3 2/2] Mark Icelake-Client CPU models deprecated
Quoted 16 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v3:
Obsolete in v5.2 --> v5.3.target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/i386/cpu.c +0
-0
target/i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 3474
Quoted 9 lines
target/i386/cpu.c +5
-1@@ -3467,7 +3467,12 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition []) { - { .version =1 }, + { + .version =1 , + .deprecated = true, + .note ="Deprecated. Will be obsoleted in v5.3. Please use " +"'Icelake-Server-v1' CPU model" ,
What's the difference between "deprecated" and "obsoleted"?
Quoted 17 lines
target/i386/cpu.c +4
-0+ }, { .version = 2, .note = "no TSX",@@ -3477,6 +3482,9 @@ static X86CPUDefinition builtin_x86_defs[] = { { "rtm", "off" }, { /* end of list */ } }, + .deprecated = true, + .note = "Deprecated. Will be obsoleted in v5.3. Please use " + "'Icelake-Server-v2' CPU model", }, { /* end of list */ } }Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo
Re: [PATCH v3 2/2] Mark Icelake-Client CPU models deprecated
Quoted 22 lines · Eduardo Habkost
Quoted 21 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v3:
Obsolete in v5.2 --> v5.3.target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/i386/cpu.c +0
-1@@ -3467,7 +3467,12 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition[]) { - { .version = 1 },
Quoted 9 lines
Quoted 6 lines
target/i386/cpu.c +4
-0+ { + .version = 1, + .deprecated = true, + .note = "Deprecated. Will be obsoleted in v5.3.Please use "
+ "'Icelake-Server-v1' CPU model",What's the difference between "deprecated" and "obsoleted"?
Forgive my non-native understanding on English word:-D Here is my understanding:
'Deprecate' is to express strong disapproval on the usage; but, can still be used if user insists.
'Obsolete' means not usable anymore.
You can feel free to reword the note words. Perhaps substitute 'removed' for 'obsolete' will be better.
Quoted 21 lines
Quoted 19 lines
target/i386/cpu.c +3
-0+ }, { .version = 2, .note = "no TSX",@@ -3477,6 +3482,9 @@ static X86CPUDefinition builtin_x86_defs[] = { { "rtm", "off" }, { /* end of list */ } }, + .deprecated = true, + .note = "Deprecated. Will be obsoleted in v5.3.Please use "
+ "'Icelake-Server-v2' CPU model",}, { /* end of list */ } }Signature · 1 line
1.8.3.1
Re: [PATCH v3 2/2] Mark Icelake-Client CPU models deprecated
Quoted 32 lines · Robert Hoo
Quoted 22 lines · Eduardo Habkost
Quoted 21 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v3:
Obsolete in v5.2 --> v5.3.target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/i386/cpu.c +0
-1@@ -3467,7 +3467,12 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition[]) { - { .version = 1 },Quoted 9 lines
Quoted 6 lines
target/i386/cpu.c +4
-0+ { + .version = 1, + .deprecated = true, + .note = "Deprecated. Will be obsoleted in v5.3.Please use "
+ "'Icelake-Server-v1' CPU model",What's the difference between "deprecated" and "obsoleted"?
Quoted 1 line
Forgive my non-native understanding on English word:-D
No problem! I'm not a native speaker either. :-)
Quoted 7 lines
Here is my understanding:
'Deprecate' is to express strong disapproval on the usage; but, can still be used if user insists.
'Obsolete' means not usable anymore.You can feel free to reword the note words. Perhaps substitute 'removed' for 'obsolete' will be better.
"Removed" would be clearer, yes. It's probably better to not mention the exact version, and just say it will be removed in the future.
Or maybe just make the message shorter and set deprecation_note to "Please use Icelake-Server instead". The details can be documented in docs/system/deprecated.rst.
Signature · 1 line
Eduardo
Re: [PATCH v3 2/2] Mark Icelake-Client CPU models deprecated
Quoted 45 lines · Eduardo Habkost
Quoted 35 lines · Robert Hoo
Quoted 24 lines · Eduardo Habkost
Quoted 23 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v3:
Obsolete in v5.2 --> v5.3.target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/i386/cpu.c +0
-0@@ -3467,7 +3467,12 @@ static X86CPUDefinitionbuiltin_x86_defs[] =
{ .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition[]) {target/i386/cpu.c +1
-1- { .version = 1 }, + {Quoted 9 lines
Quoted 6 lines
target/i386/cpu.c +3
-0+ .version = 1, + .deprecated = true, + .note = "Deprecated. Will be obsoleted inv5.3.
Please use "
+ "'Icelake-Server-v1' CPU model",What's the difference between "deprecated" and "obsoleted"?
Quoted 1 line
Forgive my non-native understanding on English word:-D
No problem! I'm not a native speaker either. :-)
Quoted 5 lines
Here is my understanding:
'Deprecate' is to express strong disapproval on the usage; but, can still be used if user insists.
'Obsolete' means not usable anymore.
Quoted 6 lines
Quoted 2 lines
You can feel free to reword the note words. Perhaps substitute 'removed' for 'obsolete' will be better.
"Removed" would be clearer, yes. It's probably better to not mention the exact version, and just say it will be removed in the future.
Then I would tend to agree with your suggestion of no specific 'deprecation_note' at all; instead, a general warning message "will be removed in the future" in machine_run_board_init().
Quoted 5 lines
Or maybe just make the message shorter and set
deprecation_noteto "Please use Icelake-Server instead". The details can be documented indocs/system/deprecated.rst.
Prefer documenting detail and model specific deprecation plan in docs/system/deprecated.rst.
Re: [PATCH v3 2/2] Mark Icelake-Client CPU models deprecated
Quoted 49 lines · Robert Hoo
Quoted 48 lines · Eduardo Habkost
Quoted 35 lines · Robert Hoo
Quoted 24 lines · Eduardo Habkost
Quoted 23 lines · Robert Hoo
Going to obsolete Icelake-Client CPU models in the future.
Signed-off-by Robert Hoo <[email protected]>---
Change log
v3:
Obsolete in v5.2 --> v5.3.target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/i386/cpu.c +0
-0@@ -3467,7 +3467,12 @@ static X86CPUDefinitionbuiltin_x86_defs[] =
{ .xlevel = 0x80000008, .model_id = "Intel Core Processor (Icelake)", .versions = (X86CPUVersionDefinition[]) {target/i386/cpu.c +1
-1- { .version = 1 }, + {Quoted 9 lines
Quoted 6 lines
target/i386/cpu.c +3
-0+ .version = 1, + .deprecated = true, + .note = "Deprecated. Will be obsoleted inv5.3.
Please use "
+ "'Icelake-Server-v1' CPU model",What's the difference between "deprecated" and "obsoleted"?
Quoted 1 line
Forgive my non-native understanding on English word:-D
No problem! I'm not a native speaker either. :-)
Quoted 7 lines
Here is my understanding:
'Deprecate' is to express strong disapproval on the usage; but, can still be used if user insists.
'Obsolete' means not usable anymore.You can feel free to reword the note words. Perhaps substitute 'removed' for 'obsolete' will be better.
Quoted 7 lines
Quoted 3 lines
"Removed" would be clearer, yes. It's probably better to not mention the exact version, and just say it will be removed in the future.
Then I would tend to agree with your suggestion of no specific '
deprecation_note' at all; instead, a general warning message "will be removed in the future" inmachine_run_board_init().
That would work too, but having "please use Icelake-Server instead" would reduce user confusion. It would also be consistent with how MachineClass does it, and make it easier to combine those two APIs together in the future.
It's not a hard requirement, though. I'm OK if you want to keep it as simple as possible.
Quoted 8 lines
Quoted 5 lines
Or maybe just make the message shorter and set
deprecation_noteto "Please use Icelake-Server instead". The details can be documented indocs/system/deprecated.rst.Prefer documenting detail and model specific deprecation plan in
docs/system/deprecated.rst.
Signature · 1 line
Eduardo
I think the patch looks better now, thanks!
Just a few minor questions and suggestions:
Quoted 10 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some versions deprecated. When that CPU model is chosen, get some warning. The warning message is customized, e.g. telling in which future QEMU version will it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the deprecation status.Signed-off-by Robert Hoo <[email protected]>
Quoted 8 lines
---
Changelog
v3:
Make the deprecation implementation CPUClass generic.v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so that it can cover implicitcpu_typeassignment cases.
What do you mean by implicit cpu_type assignment cases?
Doing it inside parse_cpu_option() like you did in v1 will make the deprecation warnings appear for *-user too (which is a good thing).
Quoted 53 lines
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)hw/core/machine.c +10
-2@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,void machine_run_board_init (MachineState *machine) {MachineClass *machine_class =MACHINE_GET_CLASS (machine); +ObjectClass *oc =object_class_by_name (machine->cpu_type); +CPUClass *cc;if (machine->ram_memdev_id) {Object *o;@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine)* specified a CPU with -cpu check here that the user CPU is supported. */ if (machine_class->valid_cpu_types && machine->cpu_type) { -ObjectClass *class =object_class_by_name (machine->cpu_type);int i;for (i =0 ; machine_class->valid_cpu_types[i]; i++) { -if (object_class_dynamic_cast (class, +if (object_class_dynamic_cast (oc, machine_class->valid_cpu_types[i])) {/* The user specificed CPU is in the valid field, we are * good to go. @@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { +warn_report ("CPU model %s is deprecated -- %s" , machine->cpu_type, + cc->deprecation_note); + } + machine_class->init (machine); }include/hw/core/cpu.h +0
-0
include/hw/core/cpu.h struct TranslationBlock; · line 161
Quoted 7 lines
include/hw/core/cpu.h +4
-0@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. +* @deprecated: True if this CPU model is deprecated (going to be removed in +* near future). +* @deprecation_note: Message about the deprecation. e.g. Since which version +* will it be obsoleted.
We don't need two separate fields if (deprecation_note != NULL) means the CPU model is deprecated. This is how it was implemented in MachineClass (see MachineClass::deprecation_reason).
Quoted 70 lines
include/hw/core/cpu.h +2
-0* * Represents a CPU family or model. */ @@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;qapi/machine-target.json +6
-1@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stop being # migration-safe in the future (since 4.1) # +# @deprecated: If true, this CPU model is deprecated and may be removed in +# in some future version of QEMU according to the QEMU deprecation +# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } ##target/i386/cpu.c +7
-0@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */ @@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu-definitions */ bool is_alias; +/* +* If true, this model is deprecated, and may be removed in the future. +* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */ @@ -5096,6 +5102,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; + info->deprecated = cc->model ? cc->model->deprecated : false;/* * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions.
target/i386/cpu.c static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) · line 5501
Quoted 9 lines
target/i386/cpu.c +3
-0@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note);
The meaning of cc->deprecation_note and model->note is a bit ambiguous here. model->note is not necessarily a deprecation note, but its contents are being copied unconditionally to cc->deprecation_note.
What about setting cc->deprecation_note only if and only if the model is deprecated?
Quoted 15 lines
target/i386/cpu.c +1
-4}static void x86_register_cpu_model_type (const char *name,X86CPUModel *model)@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version;
target/i386/cpu.c static void x86_register_cpudef_types(X86CPUDefinition *def) · line 5548
Quoted 10 lines
target/i386/cpu.c +8
-2- m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated; +/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note;
I'm not sure this rule will always apply. If we deprecate "Model-v1" but not "Model-v2", we probably don't want "Model" to be deprecated too.
Considering that we don't have cases where specific versions are being deprecated, what about making it as simple as possible and just add a new X86CPUDefinition::deprecation_note field? No need for any new fields in X86CPUModel (model->cpudef->deprecation_note can be used directly), no need for two new fields in CPUClass (just deprecation_note).
If one day we decide to deprecate just some versions of a CPU model, we can extend X86CPUVersionDefinition in the future.
Quoted 16 lines
target/i386/cpu.c +4
-0+ } +x86_register_cpu_model_type (name, vm);if (vdef->alias) {X86CPUModel *am =g_new0 (X86CPUModel,1 ); am->cpudef = def; am->version = vdef->version; am->is_alias = true; + am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am); } }Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo
Quoted 25 lines · Eduardo Habkost
I think the patch looks better now, thanks!
Just a few minor questions and suggestions:
Quoted 20 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some
versions deprecated. When that CPU model is chosen, get some warning. The
warning message is customized, e.g. telling in which future QEMU version will
it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu
help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the
deprecation status.Signed-off-by Robert Hoo <[email protected]>---
Changelog
v3:
Make the deprecation implementation CPUClass generic.
Quoted 6 lines
Quoted 4 lines
v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so
that it can cover implicitcpu_typeassignment cases.What do you mean by implicit
cpu_typeassignment cases?
Means the case that user doesn't explicitly assign '-cpu xxx' but implicitly inherits machine's default cpu type.vl.c
/* parse features once if machine provides default cpu_type */
current_machine->cpu_type = machine_class->default_cpu_type;
if (cpu_option) {
current_machine->cpu_type = parse_cpu_option(cpu_option);
}Quoted 5 lines
Doing it inside
parse_cpu_option()like you did in v1 will make the deprecation warnings appear for *-user too (which is a good thing).
So you changed your mind;-)
Could you shed more details? I don't get this point. What do you mean "*-user"?
Quoted 69 lines
Quoted 69 lines
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)hw/core/machine.c +2
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); + ObjectClass *oc = object_class_by_name(machine->cpu_type); + CPUClass *cc; if (machine->ram_memdev_id) {Object *o;hw/core/machine.c +0
-0@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine) * specified a CPU with -cpu check here that the user CPU issupported.
*/ if (machine_class->valid_cpu_types && machine->cpu_type) {- ObjectClass *class = object_class_by_name(machine-
Quoted 1 line
cpu_type);int i; for (i = 0; machine_class->valid_cpu_types[i]; i++) {hw/core/machine.c +1
-1- if (object_class_dynamic_cast(class, + if (object_class_dynamic_cast(oc, machine_class-Quoted 1 line
valid_cpu_types[i])) {
/* The user specificed CPU is in the valid field,we are
* good to go.hw/core/machine.c +7
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { +warn_report ("CPU model %s is deprecated -- %s" , machine- >cpu_type, + cc->deprecation_note); + } + machine_class->init (machine);}
include/hw/core/cpu.h +0
-0@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific
adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecated: True if this CPU model is deprecated (going to be removed in
Quoted 9 lines
Quoted 4 lines
+ * near future).
+ * @deprecation_note: Message about the deprecation. e.g. Since which version
+ * will it be obsoleted.We don't need two separate fields if (
deprecation_note!= NULL) means the CPU model is deprecated. This is how it was implemented in MachineClass (seeMachineClass::deprecation_reason).
Agree.
I think such applies to X86CPUModel::deprecated and X86CPUModel::note as well; and rename X86CPUModel::note --> deprecation_note. How do you like this?
Quoted 96 lines
Quoted 80 lines
*
* Represents a CPU family or model.
*/include/hw/core/cpu.h +2
-0@@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;qapi/machine-target.json +0
-0@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stopbeing
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be removed in
+# in some future version of QEMU according to the
QEMU deprecationqapi/machine-target.json +2
-0+# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU fromrunning.
# If the QOM property is read-only, that means there's no knownqapi/machine-target.json +2
-1@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
defined(TARGET_I386)||defined(TARGET_S390X)||defined(TARGET_MIPS)' }##
target/i386/cpu.c +3
-0@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */ @@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu-definitions */ bool is_alias; +/* +* If true, this model is deprecated, and may be removed in the future.
target/i386/cpu.c +4
-0+* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */ @@ -5096,6 +5102,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; + info->deprecated = cc->model ? cc->model->deprecated : false;/* * Old machine types won't report aliases, so that alias translation
* doesn't break compatibility with previous QEMU versions.target/i386/cpu.c static void · line 5502
Quoted 10 lines
target/i386/cpu.c +3
-0@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note);The meaning of
cc->deprecation_noteandmodel->noteis a bit ambiguous here.model->noteis not necessarily a deprecation note, but its contents are being copied unconditionally tocc->deprecation_note.
Quoted 3 lines
What about setting
cc->deprecation_noteonly if and only if the model is deprecated?
Agree. Since X86CPUModel::note is actually unused by anything now, going to rename it to deprecation_note as aforementioned.
A side concern,cc->deprecation_note = g_strdup(model->note);
I don's see where free the cc object. Assuming the dup'ed string, as well as object, will last through QEMU process life time, freed implicitly as this process gone. Is my understanding right?
Quoted 25 lines
Quoted 25 lines
target/i386/cpu.c +0
-0}static void x86_register_cpu_model_type(const char *name,
X86CPUModel *model)target/i386/cpu.c +5
-6@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version; - m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated;
Quoted 8 lines
target/i386/cpu.c static void x86_register_cpudef_types(X86CPUDefinition *def) · line 5548
Quoted 4 lines
target/i386/cpu.c +4
-0+/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note;I'm not sure this rule will always apply. If we deprecate "Model-v1" but not "Model-v2", we probably don't want "Model" to be deprecated too.
Agree
Quoted 7 lines
Considering that we don't have cases where specific versions are being deprecated, what about making it as simple as possible and just add a new
X86CPUDefinition::deprecation_notefield? No need for any new fields in X86CPUModel (model->cpudef->deprecation_notecan be used directly), no need for two new fields in CPUClass (justdeprecation_note).
How about eliminating the unversioned CPU model? Then we can still have deprecation_note in X86CPUModel, which looks more natural to me than in X86CPUDefition.
For anyway, the unversioned CPU model will eventually be instantiated to its some versioned CPU model. It's like a virtual class.
Quoted 22 lines
If one day we decide to deprecate just some versions of a CPU model, we can extend X86CPUVersionDefinition in the future.
Quoted 16 lines
target/i386/cpu.c +4
-0+ } +x86_register_cpu_model_type (name, vm);if (vdef->alias) {X86CPUModel *am =g_new0 (X86CPUModel,1 ); am->cpudef = def; am->version = vdef->version; am->is_alias = true; + am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am);} }Signature · 1 line
1.8.3.1
Quoted 33 lines · Robert Hoo
Quoted 25 lines · Eduardo Habkost
I think the patch looks better now, thanks!
Just a few minor questions and suggestions:
Quoted 20 lines · Robert Hoo
Complement versioned CPU model framework with the ability of marking some
versions deprecated. When that CPU model is chosen, get some warning. The
warning message is customized, e.g. telling in which future QEMU version will
it be obsoleted.
The deprecation message will also appear byx86_cpu_list_entry(), e.g. '-cpu
help'.
QMP 'query-cpu-definitions' will also return a bool value indicating the
deprecation status.Signed-off-by Robert Hoo <[email protected]>---
Changelog
v3:
Make the deprecation implementation CPUClass generic.Quoted 6 lines
Quoted 4 lines
v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so
that it can cover implicitcpu_typeassignment cases.What do you mean by implicit
cpu_typeassignment cases?
Quoted 8 lines
Means the case that user doesn't explicitly assign '-cpu xxx' but implicitly inherits machine's default cpu type.
vl.c/* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type; if (cpu_option) { current_machine->cpu_type = parse_cpu_option(cpu_option); }
We probably would never deprecate CPU models that are still used by default, so this is not an issue.
Quoted 6 lines
Quoted 5 lines
Doing it inside
parse_cpu_option()like you did in v1 will make the deprecation warnings appear for *-user too (which is a good thing).So you changed your mind;-)
Sorry, I don't remember suggesting this. I couldn't find any reply from myself in v1, and v2 already had the code moved to machine_run_board_init().
Note that doing the check in machine_run_board_init() is not necessarily a problem, I'm just trying to understand why the code was moved from parse_cpu_option() to machine_run_board_init() between v1 and v2.
Quoted 3 lines
Could you shed more details? I don't get this point. What do you mean "*-user"?
I mean QEMU user mode emulator, bsd-user and linux-user (e.g. the qemu-x86_64 binary). They call parse_cpu_option() as well.
Quoted 80 lines
Quoted 70 lines
Quoted 70 lines
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)hw/core/machine.c +2
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); + ObjectClass *oc = object_class_by_name(machine->cpu_type); + CPUClass *cc; if (machine->ram_memdev_id) {Object *o;hw/core/machine.c +0
-0@@ -1114,11 +1116,10 @@ void machine_run_board_init(MachineState *machine) * specified a CPU with -cpu check here that the user CPU issupported.
*/ if (machine_class->valid_cpu_types && machine->cpu_type) {- ObjectClass *class = object_class_by_name(machine-
Quoted 1 line
cpu_type);int i; for (i = 0; machine_class->valid_cpu_types[i]; i++) {hw/core/machine.c +1
-1- if (object_class_dynamic_cast(class, + if (object_class_dynamic_cast(oc, machine_class-Quoted 1 line
valid_cpu_types[i])) {
/* The user specificed CPU is in the valid field,we are
* good to go.hw/core/machine.c +7
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { +warn_report ("CPU model %s is deprecated -- %s" , machine- >cpu_type, + cc->deprecation_note); + } + machine_class->init (machine);}
include/hw/core/cpu.h +0
-0@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific
adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecated: True if this CPU model is deprecated (going to be removed inQuoted 9 lines
Quoted 4 lines
+ * near future).
+ * @deprecation_note: Message about the deprecation. e.g. Since which version
+ * will it be obsoleted.We don't need two separate fields if (
deprecation_note!= NULL) means the CPU model is deprecated. This is how it was implemented in MachineClass (seeMachineClass::deprecation_reason).
Quoted 4 lines
Agree.
I think such applies toX86CPUModel::deprecatedandX86CPUModel::noteas well; and renameX86CPUModel::note-->deprecation_note. How do you like this?
Sound good!
Quoted 97 lines
Quoted 97 lines
Quoted 81 lines
*
* Represents a CPU family or model.
*/include/hw/core/cpu.h +2
-0@@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs;bool gdb_stop_before_watchpoint;qapi/machine-target.json +0
-0@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stopbeing
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be removed in
+# in some future version of QEMU according to the
QEMU deprecationqapi/machine-target.json +2
-0+# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU fromrunning.
# If the QOM property is read-only, that means there's no knownqapi/machine-target.json +2
-1@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
defined(TARGET_I386)||defined(TARGET_S390X)||defined(TARGET_MIPS)' }##
target/i386/cpu.c +3
-0@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */ @@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu-definitions */ bool is_alias; +/* +* If true, this model is deprecated, and may be removed in the future.
target/i386/cpu.c +4
-0+* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */ @@ -5096,6 +5102,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model; + info->deprecated = cc->model ? cc->model->deprecated : false;/* * Old machine types won't report aliases, so that alias translation
* doesn't break compatibility with previous QEMU versions.target/i386/cpu.c static void · line 5502
Quoted 10 lines
target/i386/cpu.c +3
-0@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note);The meaning of
cc->deprecation_noteandmodel->noteis a bit ambiguous here.model->noteis not necessarily a deprecation note, but its contents are being copied unconditionally tocc->deprecation_note.
Quoted 5 lines
Quoted 3 lines
What about setting
cc->deprecation_noteonly if and only if the model is deprecated?Agree. Since
X86CPUModel::noteis actually unused by anything now, going to rename it todeprecation_noteas aforementioned.
.note is used by all the CPU models that set .note. See for example:
x86 Cascadelake-Server-v1 Intel Xeon Processor (Cascadelake) x86 Cascadelake-Server-v2 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES] x86 Cascadelake-Server-v3 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX] x86 Cascadelake-Server-v4 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
Quoted 7 lines
A side concern,
cc->deprecation_note=g_strdup(model->note);I don's see where free the cc object. Assuming the dup'ed string, as well as object, will last through QEMU process life time, freed implicitly as this process gone. Is my understanding right?
We never free QOM class structs (like CPUClass), so that's OK.
Quoted 43 lines
Quoted 25 lines
Quoted 25 lines
target/i386/cpu.c +0
-0}static void x86_register_cpu_model_type(const char *name,
X86CPUModel *model)target/i386/cpu.c +5
-6@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version; - m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated;Quoted 8 lines
target/i386/cpu.c static void x86_register_cpudef_types(X86CPUDefinition *def) · line 5548
Quoted 4 lines
target/i386/cpu.c +4
-0+/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note;I'm not sure this rule will always apply. If we deprecate "Model-v1" but not "Model-v2", we probably don't want "Model" to be deprecated too.
Agree
Quoted 7 lines
Considering that we don't have cases where specific versions are being deprecated, what about making it as simple as possible and just add a new
X86CPUDefinition::deprecation_notefield? No need for any new fields in X86CPUModel (model->cpudef->deprecation_notecan be used directly), no need for two new fields in CPUClass (justdeprecation_note).
Quoted 5 lines
How about eliminating the unversioned CPU model? Then we can still have
deprecation_notein X86CPUModel, which looks more natural to me than in X86CPUDefition.
For anyway, the unversioned CPU model will eventually be instantiated to its some versioned CPU model. It's like a virtual class.
What do you mean by eliminating the unversioned CPU model? Keep in mind that we need "-cpu Model" to keep working, because of compatibility and also because "-cpu Model" is more convenient.
There are ways the representation of CPU models + aliases + versions can be improved, but I assume you wouldn't want a large refactor of the CPU model/version table to get in the way of a simple feature.
Quoted 24 lines
Quoted 23 lines
If one day we decide to deprecate just some versions of a CPU model, we can extend X86CPUVersionDefinition in the future.
Quoted 16 lines
target/i386/cpu.c +4
-0+ } +x86_register_cpu_model_type (name, vm);if (vdef->alias) {X86CPUModel *am =g_new0 (X86CPUModel,1 ); am->cpudef = def; am->version = vdef->version; am->is_alias = true; + am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am);} }Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo
Quoted 22 lines · Eduardo Habkost
...
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
---
Changelog
v3:
Make the deprecation implementation CPUClass generic.v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so
that it can cover implicitcpu_typeassignment cases.What do you mean by implicit
cpu_typeassignment cases?Quoted 8 lines
Means the case that user doesn't explicitly assign '-cpu xxx' but implicitly inherits machine's default cpu type.
vl.c/* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type; if (cpu_option) { current_machine->cpu_type = parse_cpu_option(cpu_option); }
Quoted 2 lines
We probably would never deprecate CPU models that are still used by default, so this is not an issue.
Understand.
Even though less possible, I think it is still doable, say, firstly switch the default model to the other one, then deprecate it.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Doing it inside
parse_cpu_option()like you did in v1 will make the deprecation warnings appear for *-user too (which is a good thing).So you changed your mind;-)
Quoted 9 lines
Sorry, I don't remember suggesting this. I couldn't find any reply from myself in v1, and v2 already had the code moved to
machine_run_board_init().Note that doing the check in
machine_run_board_init()is not necessarily a problem, I'm just trying to understand why the code was moved fromparse_cpu_option()tomachine_run_board_init()between v1 and v2.
Sorry, I just searched my Linux mailbox, cannot find previous thread either. But in my memory, it was your suggestion:) and I prefer this than doing it in parse_cpu_option() as well, as parse_cpu_option() is early time, the passed in cpu_model could be not concrete yet. See my below idea of making unversioned cpu_model virtual.
Quoted 8 lines
Quoted 4 lines
Could you shed more details? I don't get this point. What do you mean
"*-user"?I mean QEMU user mode emulator, bsd-user and linux-user (e.g. the qemu-x86_64 binary). They call
parse_cpu_option()as well.
Oh, I'm not familiar with these user modes yet. How about leave them alone at this moment? let's cover most cases, i.e. based on machine type, first. Then in the future we consider how to expand this to *- user cases.
Quoted 215 lines
Quoted 90 lines
Quoted 80 lines
Quoted 80 lines
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)hw/core/machine.c +2
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); + ObjectClass *oc = object_class_by_name(machine->cpu_type); + CPUClass *cc; if (machine->ram_memdev_id) {Object *o;hw/core/machine.c +0
-0@@ -1114,11 +1116,10 @@ voidmachine_run_board_init(MachineState
*machine)
* specified a CPU with -cpu check here that the user CPU
is
supported.*/ if (machine_class->valid_cpu_types && machine->cpu_type) {- ObjectClass *class = object_class_by_name(machine-
Quoted 1 line
cpu_type);int i; for (i = 0; machine_class->valid_cpu_types[i]; i++) {hw/core/machine.c +1
-1- if (object_class_dynamic_cast(class, + if (object_class_dynamic_cast(oc, machine_class-Quoted 1 line
valid_cpu_types[i])) {
/* The user specificed CPU is in the validfield,
we are
* good to go.hw/core/machine.c +4
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { + warn_report("CPU model %s is deprecated -- %s",machine-
Quoted 1 line
cpu_type,hw/core/machine.c +3
-0+ cc->deprecation_note); + } + machine_class->init (machine); }include/hw/core/cpu.h +0
-0@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific
adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecated: True if this CPU model is deprecated (going to be
removed in
+ * near future).
+ * @deprecation_note: Message about the deprecation. e.g.Quoted 9 lines
Quoted 3 lines
Since
which version
+ * will it be obsoleted.We don't need two separate fields if (
deprecation_note!= NULL) means the CPU model is deprecated. This is how it was implemented in MachineClass (seeMachineClass::deprecation_reason).Quoted 6 lines
Agree.
I think such applies toX86CPUModel::deprecatedandX86CPUModel::note
as well; and renameX86CPUModel::note-->deprecation_note. How do you
like this?Sound good!
Quoted 106 lines
Quoted 106 lines
Quoted 90 lines
*
* Represents a CPU family or model.
*/include/hw/core/cpu.h +2
-0@@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs; bool gdb_stop_before_watchpoint;qapi/machine- renamed from qapi/machine-target.json +0
-0target.json
index 698850c..fec3bb8 100644qapi/machine-target.json +0
-0@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stopbeing
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be
removed in
+# in some future version of QEMU according to the
QEMU deprecationqapi/machine-target.json +2
-0+# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU fromrunning.
# If the QOM property is read-only, that means there's no
knownqapi/machine-target.json +2
-1@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
defined(TARGET_I386)||defined(TARGET_S390X)||defined(TARGET_MIPS)' }##
target/i386/cpu.c +1
-0@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */ @@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu- definitions
*/ bool is_alias;target/i386/cpu.c +2
-0+/* +* If true, this model is deprecated, and may be removed in
the future.target/i386/cpu.c +3
-0+* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */ @@ -5096,6 +5102,7 @@ static voidx86_cpu_definition_entry(gpointer
data, gpointeruser_data)info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model;+
info->deprecated=cc->model?cc->model->deprecated:
false;
/*
* Old machine types won't report aliases, so that alias
translation
* doesn't break compatibility with previous QEMU
versions.target/i386/cpu.c static void · line 5502
Quoted 10 lines
target/i386/cpu.c +3
-0@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note);The meaning of
cc->deprecation_noteandmodel->noteis a bit ambiguous here.model->noteis not necessarily a deprecation note, but its contents are being copied unconditionally tocc->deprecation_note.Quoted 6 lines
Quoted 3 lines
What about setting
cc->deprecation_noteonly if and only if the model is deprecated?Agree. Since
X86CPUModel::noteis actually unused by anything now, going to rename it todeprecation_noteas aforementioned..note is used by all the CPU models that set .note. See for example:
Quoted 8 lines
x86 Cascadelake-Server-v1 Intel Xeon Processor (Cascadelake) x86 Cascadelake-Server-v2 Intel Xeon Processor (Cascadelake) [
ARCH_CAPABILITIES]
x86 Cascadelake-Server-v3 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
x86 Cascadelake-Server-v4 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
OK, then I'll add another deprecation_note.
Quoted 65 lines
Quoted 9 lines
A side concern,
cc->deprecation_note=g_strdup(model->note);I don's see where free the cc object. Assuming the dup'ed string, as
well as object, will last through QEMU process life time, freed implicitly as this process gone. Is my understanding right?We never free QOM class structs (like CPUClass), so that's OK.
Quoted 44 lines
Quoted 25 lines
Quoted 25 lines
target/i386/cpu.c +0
-0}static void x86_register_cpu_model_type(const char *name,
X86CPUModel *model)target/i386/cpu.c +5
-6@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version; - m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated;Quoted 8 lines
target/i386/cpu.c static void x86_register_cpudef_types(X86CPUDefinition *def) · line 5548
Quoted 4 lines
target/i386/cpu.c +4
-0+/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note;I'm not sure this rule will always apply. If we deprecate "Model-v1" but not "Model-v2", we probably don't want "Model" to be deprecated too.
Agree
Quoted 8 lines
Considering that we don't have cases where specific versions are being deprecated, what about making it as simple as possible and just add a new
X86CPUDefinition::deprecation_notefield? No need for any new fields in X86CPUModel (model->cpudef-Quoted 1 line
deprecation_notecan be used directly), no need for two new fields in CPUClass (just
deprecation_note).Quoted 8 lines
How about eliminating the unversioned CPU model? Then we can still have
deprecation_notein X86CPUModel, which looks more natural to me than in
X86CPUDefition.
For anyway, the unversioned CPU model will eventually be instantiated
to its some versioned CPU model. It's like a virtual class.
Quoted 4 lines
What do you mean by eliminating the unversioned CPU model? Keep in mind that we need "-cpu Model" to keep working, because of compatibility and also because "-cpu Model" is more convenient.
Yes, keeping "-cpu Model" usage as before is my thought as well. I mean making it virtual, no real CPU model associate with it, but parse it to some concrete version when CPUModel initializes.
Quoted 5 lines
There are ways the representation of CPU models + aliases + versions can be improved, but I assume you wouldn't want a large refactor of the CPU model/version table to get in the way of a simple feature.
Yes. Trying as less refactor as possible. I think my changes even cannot be called refactor at all. :)
My idea is to make unversioned CPU model virtual. I did some patch, doable:
1) in x86_register_cpudef_types(), don't register cpu_model type for the unversioned 'Model'.
2) in x86_cpu_class_by_name(), check passed-in cpu_model param versioned or not, if the virtual unversioned 'Model', parse it to some concrete version by global default_cpu_version designation.
So, user can still use '-cpu Model' as before, no interface changes. And no nature changes:
1) in current code, even legacy 'Model', you have created a v1 model for it. i.e., every virtual 'Model' already has at least one concrete versioned one.
2) in current code, x86_cpu_model_resolve_version() is called when x86_cpu_load_model(). x86_cpu_model_resolve_version() actually does kind of work that concreting unversioned Model to its versioned one, by global default_cpu_version designation. Same as my aforementioned above.
Would you like me to integrate this implementation in v4? to have a look.
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
If one day we decide to deprecate just some versions of a CPU model, we can extend X86CPUVersionDefinition in the future.
Quoted 3 lines
target/i386/cpu.c +2
-0+ } +x86_register_cpu_model_type (name, vm);Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
if (vdef->alias) { X86CPUModel *am = g_new0(X86CPUModel, 1); am->cpudef = def; am->version = vdef->version; am->is_alias = true;Quoted 10 lines
Quoted 8 lines
target/i386/cpu.c +2
-1+ am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am); } } --1.8.3.1
--
Eduardo
Quoted 23 lines · Robert Hoo
Quoted 22 lines · Eduardo Habkost
...
Quoted 20 lines
Quoted 11 lines
Quoted 9 lines
---
Changelog
v3:
Make the deprecation implementation CPUClass generic.v2:
Move deprecation check fromparse_cpu_option()tomachine_run_board_init(), so
that it can cover implicitcpu_typeassignment cases.What do you mean by implicit
cpu_typeassignment cases?Means the case that user doesn't explicitly assign '-cpu xxx' but implicitly inherits machine's default cpu type.
vl.c/* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type; if (cpu_option) { current_machine->cpu_type = parse_cpu_option(cpu_option); }
Quoted 6 lines
Quoted 2 lines
We probably would never deprecate CPU models that are still used by default, so this is not an issue.
Understand.
Even though less possible, I think it is still doable, say, firstly switch the default model to the other one, then deprecate it.
Right. I mean it's OK to not print warnings if default_cpu_type is deprecated.
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Doing it inside
parse_cpu_option()like you did in v1 will make the deprecation warnings appear for *-user too (which is a good thing).So you changed your mind;-)
Quoted 9 lines
Sorry, I don't remember suggesting this. I couldn't find any reply from myself in v1, and v2 already had the code moved to
machine_run_board_init().Note that doing the check in
machine_run_board_init()is not necessarily a problem, I'm just trying to understand why the code was moved fromparse_cpu_option()tomachine_run_board_init()between v1 and v2.
Quoted 5 lines
Sorry, I just searched my Linux mailbox, cannot find previous thread either. But in my memory, it was your suggestion:) and I prefer this than doing it in
parse_cpu_option()as well, asparse_cpu_option()is early time, the passed incpu_modelcould be not concrete yet. See my below idea of making unversionedcpu_modelvirtual.
That's OK to me.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Could you shed more details? I don't get this point. What do you mean
"*-user"?
Quoted 7 lines
Quoted 3 lines
I mean QEMU user mode emulator, bsd-user and linux-user (e.g. the qemu-x86_64 binary). They call
parse_cpu_option()as well.Oh, I'm not familiar with these user modes yet. How about leave them alone at this moment? let's cover most cases, i.e. based on machine type, first. Then in the future we consider how to expand this to *- user cases.
No problem to me.
Quoted 323 lines
Quoted 215 lines
Quoted 90 lines
Quoted 80 lines
Quoted 80 lines
Add qapi new member documentation. Thanks Eric for comment and guidance on qapi.
hw/core/machine.c | 12 ++++++++++-- include/hw/core/cpu.h | 6 ++++++ qapi/machine-target.json | 7 ++++++- target/i386/cpu.c | 29 +++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-)hw/core/machine.c +2
-0@@ -1095,6 +1095,8 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); + ObjectClass *oc = object_class_by_name(machine->cpu_type); + CPUClass *cc; if (machine->ram_memdev_id) {Object *o;hw/core/machine.c +0
-0@@ -1114,11 +1116,10 @@ voidmachine_run_board_init(MachineState
*machine)
* specified a CPU with -cpu check here that the user CPU
is
supported.*/ if (machine_class->valid_cpu_types && machine->cpu_type) {- ObjectClass *class = object_class_by_name(machine-
Quoted 1 line
cpu_type);int i; for (i = 0; machine_class->valid_cpu_types[i]; i++) {hw/core/machine.c +1
-1- if (object_class_dynamic_cast(class, + if (object_class_dynamic_cast(oc, machine_class-Quoted 1 line
valid_cpu_types[i])) {
/* The user specificed CPU is in the validfield,
we are
* good to go.hw/core/machine.c +4
-0@@ -1141,6 +1142,13 @@ void machine_run_board_init(MachineState *machine) } } +/* Check if CPU type is deprecated and warn if so */ + cc =CPU_CLASS (oc); +if (cc->deprecated) { + warn_report("CPU model %s is deprecated -- %s",machine-
Quoted 1 line
cpu_type,hw/core/machine.c +3
-0+ cc->deprecation_note); + } + machine_class->init (machine); }include/hw/core/cpu.h +0
-0@@ -155,6 +155,10 @@ struct TranslationBlock;* @disas_set_info: Setup architecture specific components of disassembly info
* @adjust_watchpoint_address: Perform a target-specific
adjustment to an
* address before attempting to match it against watchpoints.
+ * @deprecated: True if this CPU model is deprecated (going to be
removed in
+ * near future).
+ * @deprecation_note: Message about the deprecation. e.g.Quoted 9 lines
Quoted 3 lines
Since
which version
+ * will it be obsoleted.We don't need two separate fields if (
deprecation_note!= NULL) means the CPU model is deprecated. This is how it was implemented in MachineClass (seeMachineClass::deprecation_reason).Quoted 6 lines
Agree.
I think such applies toX86CPUModel::deprecatedandX86CPUModel::note
as well; and renameX86CPUModel::note-->deprecation_note. How do you
like this?Sound good!
Quoted 106 lines
Quoted 106 lines
Quoted 90 lines
*
* Represents a CPU family or model.
*/include/hw/core/cpu.h +2
-0@@ -221,6 +225,8 @@ struct CPUClass {vaddr (*adjust_watchpoint_address)(CPUState *cpu,vaddr addr,int len);void (*tcg_initialize)(void ); +bool deprecated; +const char *deprecation_note;/* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs; bool gdb_stop_before_watchpoint;qapi/machine- renamed from qapi/machine-target.json +0
-0target.json
index 698850c..fec3bb8 100644qapi/machine-target.json +0
-0@@ -286,6 +286,10 @@ # in the VM configuration, because aliases may stopbeing
# migration-safe in the future (since 4.1)
#
+# @deprecated: If true, this CPU model is deprecated and may be
removed in
+# in some future version of QEMU according to the
QEMU deprecationqapi/machine-target.json +2
-0+# policy. (since 5.2) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU fromrunning.
# If the QOM property is read-only, that means there's no
knownqapi/machine-target.json +2
-1@@ -310,7 +314,8 @@ 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str', - '*alias-of' : 'str' }, + '*alias-of' : 'str', + 'deprecated' : 'bool' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
defined(TARGET_I386)||defined(TARGET_S390X)||defined(TARGET_MIPS)' }##
target/i386/cpu.c +1
-0@@ -1716,6 +1716,7 @@ typedef struct X86CPUVersionDefinition {const char *alias;const char *note;PropValue *props; +bool deprecated; } X86CPUVersionDefinition;/* Base definition for a CPU model */ @@ -1751,6 +1752,11 @@ struct X86CPUModel {* This matters only for "-cpu help" and query-cpu- definitions
*/ bool is_alias;target/i386/cpu.c +2
-0+/* +* If true, this model is deprecated, and may be removed in
the future.target/i386/cpu.c +3
-0+* Trying to use it now will cause a warning. +*/ +bool deprecated; };/* Get full model name for CPU version */ @@ -5096,6 +5102,7 @@ static voidx86_cpu_definition_entry(gpointer
data, gpointeruser_data)info->migration_safe = cc->migration_safe; info->has_migration_safe = true; info->q_static = cc->static_model;+
info->deprecated=cc->model?cc->model->deprecated:
false;
/*
* Old machine types won't report aliases, so that alias
translation
* doesn't break compatibility with previous QEMU
versions.target/i386/cpu.c static void · line 5502
Quoted 10 lines
target/i386/cpu.c +3
-0@@ -5486,9 +5493,12 @@ static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) {X86CPUModel *model = data;X86CPUClass *xcc =X86_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (oc); xcc->model = model; xcc->migration_safe = true; + cc->deprecated = model->deprecated; + cc->deprecation_note =g_strdup (model->note);The meaning of
cc->deprecation_noteandmodel->noteis a bit ambiguous here.model->noteis not necessarily a deprecation note, but its contents are being copied unconditionally tocc->deprecation_note.Quoted 6 lines
Quoted 3 lines
What about setting
cc->deprecation_noteonly if and only if the model is deprecated?Agree. Since
X86CPUModel::noteis actually unused by anything now, going to rename it todeprecation_noteas aforementioned..note is used by all the CPU models that set .note. See for example:
Quoted 8 lines
x86 Cascadelake-Server-v1 Intel Xeon Processor (Cascadelake) x86 Cascadelake-Server-v2 Intel Xeon Processor (Cascadelake) [
ARCH_CAPABILITIES]
x86 Cascadelake-Server-v3 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
x86 Cascadelake-Server-v4 Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]OK, then I'll add another
deprecation_note.Quoted 65 lines
Quoted 9 lines
A side concern,
cc->deprecation_note=g_strdup(model->note);I don's see where free the cc object. Assuming the dup'ed string, as
well as object, will last through QEMU process life time, freed implicitly as this process gone. Is my understanding right?We never free QOM class structs (like CPUClass), so that's OK.
Quoted 44 lines
Quoted 25 lines
Quoted 25 lines
target/i386/cpu.c +0
-0}static void x86_register_cpu_model_type(const char *name,
X86CPUModel *model)target/i386/cpu.c +5
-6@@ -5524,21 +5534,28 @@ static void x86_register_cpudef_types(X86CPUDefinition *def)x86_register_cpu_model_type (def->name, m);/* Versioned models: */ -for (vdef =x86_cpu_def_get_versions (def); vdef->version; vdef++) { -X86CPUModel *m =g_new0 (X86CPUModel,1 ); +X86CPUModel *vm =g_new0 (X86CPUModel,1 ); g_autofree char *name =x86_cpu_versioned_model_name (def, vdef->version); - m->cpudef = def; - m->version = vdef->version; - m->note = vdef->note; -x86_register_cpu_model_type (name, m); + vm->cpudef = def; + vm->version = vdef->version; + vm->note = vdef->note; + vm->deprecated = vdef->deprecated;Quoted 8 lines
target/i386/cpu.c static void x86_register_cpudef_types(X86CPUDefinition *def) · line 5548
Quoted 4 lines
target/i386/cpu.c +4
-0+/* If Model-v1 is deprecated, Model is deprecated. */ +if (vdef->version ==1 && vdef->deprecated == true) { + m->deprecated = true; + m->note = vdef->note;I'm not sure this rule will always apply. If we deprecate "Model-v1" but not "Model-v2", we probably don't want "Model" to be deprecated too.
Agree
Quoted 8 lines
Considering that we don't have cases where specific versions are being deprecated, what about making it as simple as possible and just add a new
X86CPUDefinition::deprecation_notefield? No need for any new fields in X86CPUModel (model->cpudef-Quoted 1 line
deprecation_notecan be used directly), no need for two new fields in CPUClass (just
deprecation_note).Quoted 8 lines
How about eliminating the unversioned CPU model? Then we can still have
deprecation_notein X86CPUModel, which looks more natural to me than in
X86CPUDefition.
For anyway, the unversioned CPU model will eventually be instantiated
to its some versioned CPU model. It's like a virtual class.Quoted 4 lines
What do you mean by eliminating the unversioned CPU model? Keep in mind that we need "-cpu Model" to keep working, because of compatibility and also because "-cpu Model" is more convenient.
Yes, keeping "-cpu Model" usage as before is my thought as well. I mean making it virtual, no real CPU model associate with it, but parse it to some concrete version when CPUModel initializes.
Quoted 5 lines
There are ways the representation of CPU models + aliases + versions can be improved, but I assume you wouldn't want a large refactor of the CPU model/version table to get in the way of a simple feature.
Yes. Trying as less refactor as possible. I think my changes even cannot be called refactor at all. :)
My idea is to make unversioned CPU model virtual. I did some patch, doable:
1) inx86_register_cpudef_types(), don't registercpu_modeltype for the unversioned 'Model'.
2) inx86_cpu_class_by_name(), check passed-incpu_modelparam versioned or not, if the virtual unversioned 'Model', parse it to some concrete version by globaldefault_cpu_versiondesignation.So, user can still use '-cpu Model' as before, no interface changes. And no nature changes:
1) in current code, even legacy 'Model', you have created a v1 model for it. i.e., every virtual 'Model' already has at least one concrete versioned one.
2) in current code,x86_cpu_model_resolve_version()is called whenx86_cpu_load_model().x86_cpu_model_resolve_version()actually does kind of work that concreting unversioned Model to its versioned one, by globaldefault_cpu_versiondesignation. Same as my aforementioned above.
Quoted 2 lines
Would you like me to integrate this implementation in v4? to have a look.
I think we might give this a try, but I wouldn't like to have your model deprecation series delayed because of this. Some obstacles I expect to see:
Right now the code assumes a 1:1 mapping between CPU model and QOM class. We even have a typename field returned by query-cpu-definitions.
It would also become an obstacle for removing the existing arch-specific class_by_name methods and do the model->class mapping based solely on a string template. See this thread for a glimpse on what we have been trying to do:
https://lore.kernel.org/qemu-devel/[email protected]/
I'm not saying we shouldn't do what you suggest, but it would add a lot of complexity to your CPU model deprecation work (that's very close to be ready to be merged).
Quoted 28 lines
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
If one day we decide to deprecate just some versions of a CPU model, we can extend X86CPUVersionDefinition in the future.
Quoted 3 lines
target/i386/cpu.c +2
-0+ } +x86_register_cpu_model_type (name, vm);Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
if (vdef->alias) { X86CPUModel *am = g_new0(X86CPUModel, 1); am->cpudef = def; am->version = vdef->version; am->is_alias = true;Quoted 10 lines
Quoted 8 lines
target/i386/cpu.c +2
-1+ am->note = vdef->note; + am->deprecated = vdef->deprecated;x86_register_cpu_model_type (vdef->alias, am); } } --1.8.3.1
--
Eduardo
Signature · 1 line
Eduardo
Quoted 1 line · Eduardo Habkost
Quoted 1 line
...
Quoted 44 lines
Quoted 27 lines
Yes. Trying as less refactor as possible. I think my changes even cannot be called refactor at all. :)
My idea is to make unversioned CPU model virtual. I did some patch, doable:
1) inx86_register_cpudef_types(), don't registercpu_modeltype for
the unversioned 'Model'.
2) inx86_cpu_class_by_name(), check passed-incpu_modelparam versioned or not, if the virtual unversioned 'Model', parse it to some
concrete version by globaldefault_cpu_versiondesignation.So, user can still use '-cpu Model' as before, no interface changes.
And no nature changes:
1) in current code, even legacy 'Model', you have created a v1 model
for it. i.e., every virtual 'Model' already has at least one concrete
versioned one.
2) in current code,x86_cpu_model_resolve_version()is called whenx86_cpu_load_model().x86_cpu_model_resolve_version()actually does kind of work that concreting unversioned Model to its versioned one, by
globaldefault_cpu_versiondesignation. Same as my aforementioned above.Quoted 2 lines
Would you like me to integrate this implementation in v4? to have a look.
I think we might give this a try, but I wouldn't like to have your model deprecation series delayed because of this. Some obstacles I expect to see:
Right now the code assumes a 1:1 mapping between CPU model and QOM class. We even have a
typenamefield returned by query-cpu-definitions.It would also become an obstacle for removing the existing arch-specific
class_by_namemethods and do themodel->classmapping based solely on a string template. See this thread for a glimpse on what we have been trying to do:
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 4 lines
I'm not saying we shouldn't do what you suggest, but it would add a lot of complexity to your CPU model deprecation work (that's very close to be ready to be merged).
OK, I'm going to send v4 without this. Then send this in a separate patch for discussion.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
--
Eduardo