From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuuWi-0005Fy-1y for qemu-devel@nongnu.org; Fri, 17 Apr 2009 16:19:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuuWd-0005Do-Bb for qemu-devel@nongnu.org; Fri, 17 Apr 2009 16:19:07 -0400 Received: from [199.232.76.173] (port=36164 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuuWd-0005Dl-9P for qemu-devel@nongnu.org; Fri, 17 Apr 2009 16:19:03 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:52050) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuuWc-0006WB-Vi for qemu-devel@nongnu.org; Fri, 17 Apr 2009 16:19:03 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e37.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n3HKIVic006841 for ; Fri, 17 Apr 2009 14:18:31 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n3HKJ1e4207498 for ; Fri, 17 Apr 2009 14:19:01 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n3HKJ1pP007867 for ; Fri, 17 Apr 2009 14:19:01 -0600 Message-ID: <49E8E431.4090909@us.ibm.com> Date: Fri, 17 Apr 2009 15:18:57 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1239981649-6366-1-git-send-email-glommer@redhat.com> <1239981649-6366-2-git-send-email-glommer@redhat.com> <1239981649-6366-3-git-send-email-glommer@redhat.com> <1239981649-6366-4-git-send-email-glommer@redhat.com> <1239981649-6366-5-git-send-email-glommer@redhat.com> <1239981649-6366-6-git-send-email-glommer@redhat.com> In-Reply-To: <1239981649-6366-6-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 5/6] enable cpu hotplug Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org Glauber Costa wrote: > This patch enable cpu hotplug to happen via acpi events. > Note that all it does is generate acpi messages. It still needs > guest cooperation, in the very way as real hardware. > > It is basically what we have in kvm, but in a qemuish style, with > a few improvements. > > Signed-off-by: Glauber Costa > --- > cpu-all.h | 1 + > exec.c | 13 +++++++++++ > hw/acpi.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > monitor.c | 21 ++++++++++++++++++ > sysemu.h | 1 + > 5 files changed, 105 insertions(+), 0 deletions(-) > > diff --git a/cpu-all.h b/cpu-all.h > index aaaa70d..a0c97f7 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -745,6 +745,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags); > > void cpu_exec_init_all(unsigned long tb_size); > CPUState *cpu_copy(CPUState *env); > +CPUState *qemu_get_cpu(int cpu); > > void cpu_dump_state(CPUState *env, FILE *f, > int (*cpu_fprintf)(FILE *f, const char *fmt, ...), > diff --git a/exec.c b/exec.c > index 13e43d0..a7ac18f 100644 > --- a/exec.c > +++ b/exec.c > @@ -538,6 +538,19 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) > } > #endif > > +CPUState *qemu_get_cpu(int cpu) > +{ > + CPUState *env = first_cpu; > + > + while (env) { > + if (env->cpu_index == cpu) > + break; > + env = env->next_cpu; > + } > + > + return env; > +} > + > void cpu_exec_init(CPUState *env) > { > CPUState **penv; > diff --git a/hw/acpi.c b/hw/acpi.c > index 22fbc4a..10c0e69 100644 > --- a/hw/acpi.c > +++ b/hw/acpi.c > @@ -26,6 +26,7 @@ > #include "kvm.h" > > //#define DEBUG > +//#define DEBUG_CPU > Consider introducing a cpu_dprintf() or something like that. > @@ -709,11 +712,44 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val) > #endif > } > > +static uint32_t cpuhotplug_read(void *opaque, uint32_t addr) > +{ > + if ((addr < PROC_BASE) || (addr > (PROC_BASE + 31))) { > + /* should never happen, so return a poison */ > + return 0xabcdefab; > + } > + else { > Should be one line. > +void qemu_system_cpu_hot_add(int cpu, int state) > +{ > + CPUState *env; > + > + if ((state) && !qemu_get_cpu(cpu)) { > +#ifdef DEBUG_CPU > + printf("creatng new cpu %d\n", cpu); > +#endif > + env = pc_new_cpu(cpu, first_cpu->cpu_model_str, 1); > + enable_processor(&gpe, cpu); > + } > + else { > Should be one line. > + > + if (!strcmp(status, "online")) > + state = 1; > + else if (!strcmp(status, "offline")) > + state = 0; > Should have {}s. -- Regards, Anthony Liguori