qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 5/6] enable cpu hotplug


From: Anthony Liguori
Subject: [Qemu-devel] Re: [PATCH 5/6] enable cpu hotplug
Date: Fri, 17 Apr 2009 15:18:57 -0500
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

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 <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]