From 61ad65d0f01d928b259effb57e2a356f3e3dac03 Mon Sep 17 00:00:00 2001 From: Robert Hoo Date: Tue, 22 Sep 2020 15:14:14 +0800 Subject: 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 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 --- target/i386/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'target') diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 25ec64124e..2e3ee41c56 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -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) -- cgit v1.2.3