From: Eduardo Habkost <ehabkost@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Igor Mammedov <imammedo@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org,
Alistair Francis <alistair.francis@xilinx.com>,
marcel@redhat.com
Subject: [Qemu-devel] [RFC v1 0/2] Add a valid_cpu_types property
Date: Mon, 18 Sep 2017 19:55:52 -0300 [thread overview]
Message-ID: <20170918225552.GM10621@localhost.localdomain> (raw)
In-Reply-To: <20170918215719.16415-1-f4bug@amsat.org>
On Mon, Sep 18, 2017 at 06:57:19PM -0300, Philippe Mathieu-Daudé wrote:
> add a property to restrict the CPU for SoCs once on machine creation and avoid
> duplicate code in each board.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
The valid_cpu_types approach implemented by Alistair is more
generic:
Subject: [Qemu-devel] [RFC v1 0/2] Add a valid_cpu_types property
Message-ID: <cover.1504656490.git.alistair.francis@xilinx.com>
With it, boards that don't support other CPUs just need to set
valid_cpu_types = { default_cpu_type }.
> ---
> Based-on: 1505318697-77161-6-git-send-email-imammedo@redhat.com
>
> include/hw/boards.h | 3 +++
> vl.c | 11 +++++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 6b67adaef6..20dc0a0ab9 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -129,6 +129,8 @@ typedef struct {
> * specifies default CPU_TYPE, which will be used for parsing target
> * specific features and for creating CPUs if CPU name wasn't provided
> * explicitly at CLI
> + * @is_system_on_chip:
> + * If true, board does not support other CPUs than default_cpu_type.
> * @minimum_page_bits:
> * If non-zero, the board promises never to create a CPU with a page size
> * smaller than this, so QEMU can use a more efficient larger page
> @@ -182,6 +184,7 @@ struct MachineClass {
> const char *hw_version;
> ram_addr_t default_ram_size;
> const char *default_cpu_type;
> + bool is_system_on_chip;
> bool option_rom_has_mr;
> bool rom_file_has_mr;
> int minimum_page_bits;
> diff --git a/vl.c b/vl.c
> index fb6a700e55..6e59ffa856 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4717,10 +4717,21 @@ int main(int argc, char **argv, char **envp)
> current_machine->cpu_model = cpu_model;
>
>
> + if (machine_class->is_system_on_chip && !machine_class->default_cpu_type) {
> + error_report("System-on-Chip must have a default CPU type");
> + exit(1);
> + }
> /* parse features once if machine provides default cpu_type */
> if (machine_class->default_cpu_type) {
> current_machine->cpu_type = machine_class->default_cpu_type;
> if (cpu_model) {
> + if (machine_class->is_system_on_chip) {
> + if (strcmp(cpu_model, machine_class->default_cpu_type) != 0) {
> + error_report("This board can only be used with CPU %s",
> + machine_class->default_cpu_type);
> + exit(1);
> + }
> + }
> current_machine->cpu_type =
> cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
> }
> --
> 2.14.1
>
--
Eduardo
next prev parent reply other threads:[~2017-09-18 22:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 21:57 [Qemu-devel] [RFC PATCH] vl.c: add is_system_on_chip flag to force board default cpu Philippe Mathieu-Daudé
2017-09-18 22:55 ` Eduardo Habkost [this message]
2017-09-19 9:51 ` [Qemu-devel] [RFC v1 0/2] Add a valid_cpu_types property Philippe Mathieu-Daudé
2017-09-19 10:42 ` Eduardo Habkost
2017-09-19 9:03 ` [Qemu-devel] [RFC PATCH] vl.c: add is_system_on_chip flag to force board default cpu Peter Maydell
2017-09-19 18:16 ` Alistair Francis
-- strict thread matches above, loose matches on Subject: below --
2017-09-06 0:11 [Qemu-devel] [RFC v1 0/2] Add a valid_cpu_types property Alistair Francis
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=20170918225552.GM10621@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=alistair.francis@xilinx.com \
--cc=f4bug@amsat.org \
--cc=imammedo@redhat.com \
--cc=marcel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).