All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH] x86: Factor out pc_new_cpu
Date: Thu, 25 Jun 2009 08:23:39 +0200	[thread overview]
Message-ID: <4A4317EB.2070908@web.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

At this point, this refactoring looks like overkill. But we will need it
for CPU hotplugging, and qemu-kvm already carries it. Merging it early
would help qemu-kvm when rebasing against upstream.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 hw/pc.c |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 86e5cfe..09073f5 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -829,6 +829,25 @@ int cpu_is_bsp(CPUState *env)
 	return env->cpuid_apic_id == 0;
 }
 
+static CPUState *pc_new_cpu(const char *cpu_model)
+{
+    CPUState *env;
+
+    env = cpu_init(cpu_model);
+    if (!env) {
+        fprintf(stderr, "Unable to find x86 CPU definition\n");
+        exit(1);
+    }
+    if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+        env->cpuid_apic_id = env->cpu_index;
+        /* APIC reset callback resets cpu */
+        apic_init(env);
+    } else {
+        qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env);
+    }
+    return env;
+}
+
 /* PC hardware initialisation */
 static void pc_init1(ram_addr_t ram_size,
                      const char *boot_device,
@@ -869,20 +888,8 @@ static void pc_init1(ram_addr_t ram_size,
         cpu_model = "qemu32";
 #endif
     }
-    
-    for(i = 0; i < smp_cpus; i++) {
-        env = cpu_init(cpu_model);
-        if (!env) {
-            fprintf(stderr, "Unable to find x86 CPU definition\n");
-            exit(1);
-        }
-        if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
-            env->cpuid_apic_id = env->cpu_index;
-            /* APIC reset callback resets cpu */
-            apic_init(env);
-        } else {
-            qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env);
-        }
+    for (i = 0; i < smp_cpus; i++) {
+        env = pc_new_cpu(cpu_model);
     }
 
     vmport_init();


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

                 reply	other threads:[~2009-06-25  6:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4A4317EB.2070908@web.de \
    --to=jan.kiszka@web.de \
    --cc=aliguori@us.ibm.com \
    --cc=avi@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.