From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su69y-0004LL-UC for qemu-devel@nongnu.org; Wed, 25 Jul 2012 14:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su69x-0002AG-Hi for qemu-devel@nongnu.org; Wed, 25 Jul 2012 14:18:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su69x-00029v-8f for qemu-devel@nongnu.org; Wed, 25 Jul 2012 14:18:09 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6PII8Kr007501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Jul 2012 14:18:08 -0400 From: Eduardo Habkost Date: Wed, 25 Jul 2012 15:18:42 -0300 Message-Id: <1343240323-7402-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1343240323-7402-1-git-send-email-ehabkost@redhat.com> References: <1343240323-7402-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [QEMU PATCH 2/3] per-machine-type CPU model alias system List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: libvir-list@redhat.com, Jiri Denemark , Gleb Natapov This allow QEMUMachine structs to contain a list of CPU model aliases, used to keep command-line compatibility with older machine types, while making CPU model fixes available on newer machine types. Signed-off-by: Eduardo Habkost --- hw/boards.h | 6 ++++++ vl.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hw/boards.h b/hw/boards.h index f20f5ab..ad48399 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -12,6 +12,11 @@ typedef void QEMUMachineInitFunc(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model); + +typedef struct CPUModelAlias { + const char *alias, *cpu_model; +} CPUModelAlias; + typedef struct QEMUMachine { const char *name; const char *alias; @@ -27,6 +32,7 @@ typedef struct QEMUMachine { no_sdcard:1; int is_default; const char *default_machine_opts; + struct CPUModelAlias *cpu_aliases; GlobalProperty *compat_props; struct QEMUMachine *next; const char *hw_version; diff --git a/vl.c b/vl.c index 34cc145..cd87e06 100644 --- a/vl.c +++ b/vl.c @@ -1209,6 +1209,19 @@ QEMUMachine *find_default_machine(void) return NULL; } +static const char *qemu_machine_resolve_cpu_model(QEMUMachine *m, + const char *cpu_model) +{ + if (cpu_model && m->cpu_aliases) { + CPUModelAlias *a; + for (a = m->cpu_aliases; a->alias; a++) { + if (!strcmp(cpu_model, a->alias)) + return a->cpu_model; + } + } + return cpu_model; +} + void qemu_machine_init(QEMUMachine *machine, ram_addr_t ram_size, const char *boot_devices, @@ -1217,6 +1230,7 @@ void qemu_machine_init(QEMUMachine *machine, const char *initrd_filename, const char *cpu_model) { + cpu_model = qemu_machine_resolve_cpu_model(machine, cpu_model); machine->init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); } -- 1.7.10.4