From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJiN9-0004Rf-1N for qemu-devel@nongnu.org; Thu, 25 Jun 2009 02:23:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJiN4-0004PW-Bk for qemu-devel@nongnu.org; Thu, 25 Jun 2009 02:23:46 -0400 Received: from [199.232.76.173] (port=55432 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJiN4-0004PS-88 for qemu-devel@nongnu.org; Thu, 25 Jun 2009 02:23:42 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:33696) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MJiN3-0004Nn-Nq for qemu-devel@nongnu.org; Thu, 25 Jun 2009 02:23:42 -0400 Message-ID: <4A4317EB.2070908@web.de> Date: Thu, 25 Jun 2009 08:23:39 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB4C1D36BD103693E5EE1ED6B" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] x86: Factor out pc_new_cpu List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB4C1D36BD103693E5EE1ED6B Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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 --- 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 =3D=3D 0; } =20 +static CPUState *pc_new_cpu(const char *cpu_model) +{ + CPUState *env; + + env =3D 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 =3D 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 =3D "qemu32"; #endif } - =20 - for(i =3D 0; i < smp_cpus; i++) { - env =3D 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 =3D env->cpu_index; - /* APIC reset callback resets cpu */ - apic_init(env); - } else { - qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env); - } + for (i =3D 0; i < smp_cpus; i++) { + env =3D pc_new_cpu(cpu_model); } =20 vmport_init(); --------------enigB4C1D36BD103693E5EE1ED6B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpDF+sACgkQniDOoMHTA+kHfACeNEpSntYKu96YTYdZng/D5R4c wsMAn1aglmntLrKimba/1ECXOmE5QmZH =c8ZW -----END PGP SIGNATURE----- --------------enigB4C1D36BD103693E5EE1ED6B--