mirror of https://gitee.com/openkylin/qemu.git
cpu: Introduce CPU model deprecation API
Implement the ability of marking some versions deprecated. When that CPU model is chosen, print a warning. The warning message can be customized, e.g. suggesting an alternative CPU model to be used instead. The deprecation message will be printed by x86_cpu_list_entry(), e.g. '-cpu help'. QMP command 'query-cpu-definitions' will return a bool value indicating the deprecation status. Signed-off-by: Robert Hoo <robert.hu@linux.intel.com> Message-Id: <1600758855-80046-1-git-send-email-robert.hu@linux.intel.com> [ehabkost: reword commit message] [ehabkost: Handle NULL cpu_type] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
31c707fb4d
commit
61ad65d0f0
|
@ -1087,6 +1087,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;
|
||||
|
@ -1106,11 +1108,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.
|
||||
|
@ -1133,6 +1134,13 @@ void machine_run_board_init(MachineState *machine)
|
|||
}
|
||||
}
|
||||
|
||||
/* Check if CPU type is deprecated and warn if so */
|
||||
cc = CPU_CLASS(oc);
|
||||
if (cc && cc->deprecation_note) {
|
||||
warn_report("CPU model %s is deprecated -- %s", machine->cpu_type,
|
||||
cc->deprecation_note);
|
||||
}
|
||||
|
||||
machine_class->init(machine);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,8 @@ 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.
|
||||
* @deprecation_note: If this CPUClass is deprecated, this field provides
|
||||
* related information.
|
||||
*
|
||||
* Represents a CPU family or model.
|
||||
*/
|
||||
|
@ -221,6 +223,7 @@ struct CPUClass {
|
|||
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
|
||||
void (*tcg_initialize)(void);
|
||||
|
||||
const char *deprecation_note;
|
||||
/* Keep non-pointer data at the end to minimize holes. */
|
||||
int gdb_num_core_regs;
|
||||
bool gdb_stop_before_watchpoint;
|
||||
|
|
|
@ -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)' }
|
||||
|
||||
##
|
||||
|
|
|
@ -1633,6 +1633,7 @@ typedef struct X86CPUDefinition {
|
|||
* If NULL, version 1 will be registered automatically.
|
||||
*/
|
||||
const X86CPUVersionDefinition *versions;
|
||||
const char *deprecation_note;
|
||||
} X86CPUDefinition;
|
||||
|
||||
/* Reference to a specific CPU model version */
|
||||
|
@ -4990,6 +4991,11 @@ 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;
|
||||
if (cc->model && cc->model->cpudef->deprecation_note) {
|
||||
info->deprecated = true;
|
||||
} else {
|
||||
info->deprecated = false;
|
||||
}
|
||||
/*
|
||||
* Old machine types won't report aliases, so that alias translation
|
||||
* doesn't break compatibility with previous QEMU versions.
|
||||
|
@ -5380,9 +5386,11 @@ 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->deprecation_note = model->cpudef->deprecation_note;
|
||||
}
|
||||
|
||||
static void x86_register_cpu_model_type(const char *name, X86CPUModel *model)
|
||||
|
|
Loading…
Reference in New Issue