qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
	Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org
Subject: [Qemu-devel] [RFC v2 2/5] machine: prepare machine 'none' to gradually switch to cpu_create() API
Date: Thu, 18 Jan 2018 18:33:59 +0100	[thread overview]
Message-ID: <1516296842-136976-3-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1516296842-136976-1-git-send-email-imammedo@redhat.com>

temporarily add #ifdef CPU_RESOLVING_TYPE in null-machine.c,
so that each target could gradually switch to cpu_create() and
not converted yet could continue to use cpu_init().

Once all targets are converted
   temporary ifdefs, MachineState::cpu_model and cpu_init() API
will be removed

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/core/null-machine.c | 13 ++++++++++++-
 vl.c                   |  8 +++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index 864832d..3cc6a49 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -23,10 +23,18 @@
 static void machine_none_init(MachineState *mch)
 {
     CPUState *cpu = NULL;
+#ifdef CPU_RESOLVING_TYPE
+    MachineClass *mc = MACHINE_GET_CLASS(mch);
 
-    /* Initialize CPU (if a model has been specified) */
+    /* 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);
+#else
     if (mch->cpu_model) {
         cpu = cpu_init(mch->cpu_model);
+#endif
         if (!cpu) {
             error_report("Unable to initialize CPU");
             exit(1);
@@ -54,6 +62,9 @@ static void machine_none_machine_init(MachineClass *mc)
     mc->init = machine_none_init;
     mc->max_cpus = 1;
     mc->default_ram_size = 0;
+#ifdef CPU_RESOLVING_TYPE
+    mc->default_cpu_type = CPU_RESOLVING_TYPE;
+#endif
 }
 
 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

  parent reply	other threads:[~2018-01-18 17:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 17:33 [Qemu-devel] [RFC v2 0/5] generalize parsing of cpu_model (part 4) Igor Mammedov
2018-01-18 17:33 ` [Qemu-devel] [RFC v2 1/5] tests: add machine 'none' with -cpu test Igor Mammedov
2018-01-18 19:01   ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2018-01-18 17:33 ` Igor Mammedov [this message]
2018-01-18 19:06   ` [Qemu-devel] [Qemu-ppc] [RFC v2 2/5] machine: prepare machine 'none' to gradually switch to cpu_create() API Thomas Huth
2018-01-18 20:35     ` Eduardo Habkost
2018-01-18 17:34 ` [Qemu-devel] [RFC v2 3/5] linux-user: prepare for switching " Igor Mammedov
2018-01-18 19:10   ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2018-01-18 20:33   ` [Qemu-devel] " Eduardo Habkost
2018-01-19 10:24     ` Igor Mammedov
2018-01-18 17:34 ` [Qemu-devel] [RFC v2 4/5] arm: cpu: add CPU_RESOLVING_TYPE macro Igor Mammedov
2018-01-18 17:34 ` [Qemu-devel] [RFC v2 5/5] x86: " Igor Mammedov
2018-01-18 17:59 ` [Qemu-devel] [RFC v2 0/5] generalize parsing of cpu_model (part 4) no-reply
2018-01-18 20:17 ` no-reply

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=1516296842-136976-3-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@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).