From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>,
Marcel Apfelbaum <marcel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model
Date: Thu, 18 Jan 2018 11:10:35 +0100 [thread overview]
Message-ID: <20180118111035.3ab0a533@redhat.com> (raw)
In-Reply-To: <20180118014846.GM627@localhost.localdomain>
On Wed, 17 Jan 2018 23:48:46 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:
> On Wed, Jan 17, 2018 at 04:43:32PM +0100, Igor Mammedov wrote:
> > The last user of it was machine type 'none', which used field
> > to create CPU id user requested it on CLI with -cpu option.
> >
> > We could compare pointers of MachineState::cpu_type and
> > MachineClass::default_cpu_type to check for the same condition,
> > and drop cpu_model concept completly from machine/boards code
> > So that no one would try to reuse obsolete field and only
> > place to deal with cpu model would be vl.c and
> > foo_cpu_class_by_name() callbacks.
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: Marcel Apfelbaum <marcel@redhat.com>
> > CC: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > include/hw/boards.h | 1 -
> > hw/core/null-machine.c | 10 +++++++---
> > vl.c | 8 +++++++-
> > 3 files changed, 14 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > index 156b16f..decd0ec 100644
> > --- a/include/hw/boards.h
> > +++ b/include/hw/boards.h
> > @@ -246,7 +246,6 @@ struct MachineState {
> > char *kernel_filename;
> > char *kernel_cmdline;
> > char *initrd_filename;
> > - const char *cpu_model;
> > const char *cpu_type;
> > AccelState *accelerator;
> > CPUArchIdList *possible_cpus;
> > diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
> > index 864832d..c2e466c 100644
> > --- a/hw/core/null-machine.c
> > +++ b/hw/core/null-machine.c
> > @@ -23,10 +23,13 @@
> > static void machine_none_init(MachineState *mch)
> > {
> > CPUState *cpu = NULL;
> > + MachineClass *mc = MACHINE_GET_CLASS(mch);
> >
> > - /* Initialize CPU (if a model has been specified) */
> > - if (mch->cpu_model) {
> > - cpu = cpu_init(mch->cpu_model);
> > + /* Initialize CPU if cpu_type pointer is user provided
> > + * (i.e. != to pointer tot static default cpu type string)
> > + */
> > + if (mch->cpu_type != mc->default_cpu_type) {
> > + cpu = cpu_create(mch->cpu_type);
>
> This is a big assumption about the code that sets mch->cpu_type.
> A simple g_strdup(machine_class->default_cpu_type) would break
> this silently (as it won't trigger the assert() below).
Yes, it's a bit of a hack to figure out is user has requested
cpu type explicitly. But so far there isn't need to do
g_strdup(machine_class->default_cpu_type)
when copying default in vl.c and guarding against it
looks like overkill currently.
Cleaner way would be to make cpu_type property, add new property
API to set/check flags and use that here, there are other places
that would benefit from such API as well.
But it looks beyond scope of this series, so I used simple
hackish way to make it work with current code.
I can amend comment here:
/* Initialize CPU if cpu_type pointer is user provided
* (i.e. != to pointer to static default cpu type string)
* MachineClass::default_cpu_type must be assigned to
* MachineState::cpu_type directly for this to work.
* TODO:
* - make cpu_type a property
* - add API to add/check user_set flag to property
* - use new API to check if property was user set
*/
>
>
> > if (!cpu) {
> > error_report("Unable to initialize CPU");
> > exit(1);
> > @@ -54,6 +57,7 @@ static void machine_none_machine_init(MachineClass *mc)
> > mc->init = machine_none_init;
> > mc->max_cpus = 1;
> > mc->default_ram_size = 0;
> > + mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
>
> Why do you need this? Isn't it simpler to just leave
> default_cpu_type=NULL here?
vl.c "-cpu" parsing depends on default_cpu_type being set
...
if (machine_class->default_cpu_type) {
...
}
when we get rid of requirement for proxy type in
cpu_parse_cpu_model()
we can drop this ugliness in null-machine.
I'm doing it dirty way to prevent cpu_model resurgence
in boards code as it happened with nios2, even though
I've tried to monitor list for such patches.
> > }
> >
> > DEFINE_MACHINE("none", machine_none_machine_init)
> > diff --git a/vl.c b/vl.c
> > index 2586f25..8aa0131 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -4609,7 +4609,6 @@ int main(int argc, char **argv, char **envp)
> > current_machine->maxram_size = maxram_size;
> > current_machine->ram_slots = ram_slots;
> > current_machine->boot_order = boot_order;
> > - current_machine->cpu_model = cpu_model;
> >
> > parse_numa_opts(current_machine);
> >
> > @@ -4619,6 +4618,13 @@ int main(int argc, char **argv, char **envp)
> > if (cpu_model) {
> > current_machine->cpu_type =
> > cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
> > +
> > + /* machine 'none' depends on default cpu type pointer not being
> > + * equal to resolved type name pointer to fugure out if type was
> > + * user provided, make sure that if it becomes not true in future
> > + * it won't beark silently */
> > + g_assert(
> > + current_machine->cpu_type != machine_class->default_cpu_type);
> > }
> > }
> >
> > --
> > 2.7.4
> >
>
next prev parent reply other threads:[~2018-01-18 10:10 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 02/24] alpha: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 03/24] cris: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 04/24] lm32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 05/24] m68k: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 06/24] microblaze: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 07/24] mips: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 08/24] moxie: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 09/24] nios2: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 10/24] openrisc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
2018-01-18 0:30 ` David Gibson
2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
2018-01-17 16:04 ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2018-01-17 19:20 ` Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 13/24] sh4: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 14/24] sparc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
2018-01-17 16:34 ` Bastian Koppelmann
2018-01-17 15:43 ` [Qemu-devel] [PATCH 16/24] unicore32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
2018-01-17 17:35 ` Max Filippov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 19/24] tilegx: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
2018-01-18 1:48 ` Eduardo Habkost
2018-01-18 10:10 ` Igor Mammedov [this message]
2018-01-18 19:18 ` Eduardo Habkost
2018-01-19 10:14 ` Igor Mammedov
2018-01-19 13:14 ` Eduardo Habkost
2018-01-19 13:39 ` Igor Mammedov
2018-01-19 14:23 ` Eduardo Habkost
2018-01-17 15:43 ` [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead Igor Mammedov
2018-01-17 15:43 ` [Qemu-arm] [PATCH 22/24] cpu: get rid of unused cpu_init() defines Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] " Igor Mammedov
2018-01-18 0:28 ` [Qemu-arm] " David Gibson
2018-01-18 0:28 ` [Qemu-devel] " David Gibson
2018-01-18 1:50 ` [Qemu-arm] " Eduardo Habkost
2018-01-18 1:50 ` [Qemu-devel] " Eduardo Habkost
2018-01-17 15:43 ` [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init() Igor Mammedov
2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
2018-01-17 19:15 ` Igor Mammedov
2018-01-17 20:30 ` Peter Maydell
2018-01-18 10:43 ` Igor Mammedov
2018-01-18 10:50 ` Peter Maydell
2018-01-18 13:06 ` Igor Mammedov
2018-01-18 13:10 ` Peter Maydell
2018-01-18 13:34 ` Igor Mammedov
2018-01-18 13:36 ` Peter Maydell
2018-01-18 13:45 ` Igor Mammedov
2018-01-18 13:49 ` Peter Maydell
2018-01-18 14:02 ` Igor Mammedov
2018-01-18 15:31 ` Philippe Mathieu-Daudé
2018-01-18 15:41 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180118111035.3ab0a533@redhat.com \
--to=imammedo@redhat.com \
--cc=ehabkost@redhat.com \
--cc=laurent@vivier.eu \
--cc=marcel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.