[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [QEMU PATCH 2/3] per-machine-type CPU model alias syste
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [QEMU PATCH 2/3] per-machine-type CPU model alias system |
Date: |
Thu, 26 Jul 2012 00:46:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120601 Thunderbird/13.0 |
Am 25.07.2012 20:18, schrieb Eduardo Habkost:
> 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 <address@hidden>
> ---
> 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);
> }
>
If the model is specified with -M by user or libvirt, then all seems
fine, but renaming default CPUs like qemu64 et al. (as done for
non-default ones in the next patch) would break machines' cpu_init()
call. That's a fairly common use case for non-x86 machines.
The alternative would be to incept closer to object_new(), i.e. call an
alias resolution helper from the various cpu_*_init() functions.
Please keep me cc'ed.
Thanks,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- [Qemu-devel] [QEMU PATCH 0/3] versioned CPU models / per-machine-type aliases, Eduardo Habkost, 2012/07/25
- [Qemu-devel] [QEMU PATCH 1/3] vl.c: extract qemu_machine_init() function, Eduardo Habkost, 2012/07/25
- [Qemu-devel] [QEMU PATCH 2/3] per-machine-type CPU model alias system, Eduardo Habkost, 2012/07/25
- Re: [Qemu-devel] [QEMU PATCH 2/3] per-machine-type CPU model alias system,
Andreas Färber <=
- [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Eduardo Habkost, 2012/07/25
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Andreas Färber, 2012/07/25
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Eduardo Habkost, 2012/07/26
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Andreas Färber, 2012/07/26
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Eduardo Habkost, 2012/07/26
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Igor Mammedov, 2012/07/31
- Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Eduardo Habkost, 2012/07/31
Re: [Qemu-devel] [QEMU PATCH 3/3] x86: pc: versioned CPU model names & compatibility aliases, Jiri Denemark, 2012/07/26
Re: [Qemu-devel] [QEMU PATCH 0/3] versioned CPU models / per-machine-type aliases, Anthony Liguori, 2012/07/25