From: Ian Jackson Date: Fri, 30 Apr 2010 16:41:18 +0000 (+0100) Subject: Update vcpu hotplug logic X-Git-Tag: xen-4.1.0-rc1~40 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=376c64a4e068b3dc83f066b4050ed34d983a5c75;p=qemu-xen-4.1-testing.git Update vcpu hotplug logic Add vcpu online/offline check to avoid redundant SCI interrupt. Signed-off-by: Liu, Jinsong --- diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c index fb905d1a6..3c52c4bf4 100644 --- a/hw/piix4acpi.c +++ b/hw/piix4acpi.c @@ -727,16 +727,24 @@ void i440fx_init_memory_mappings(PCIDevice *d) { /* our implementation doesn't need this */ } -static void enable_processor(GPEState *g, int cpu) +static int enable_processor(GPEState *g, int cpu) { + if (g->cpus_sts[cpu/8] & (1 << (cpu%8))) + return 0; + g->gpe0_sts[0] |= 4; g->cpus_sts[cpu/8] |= (1 << (cpu%8)); + return 1; } -static void disable_processor(GPEState *g, int cpu) +static int disable_processor(GPEState *g, int cpu) { + if (!(g->cpus_sts[cpu/8] & (1 << (cpu%8)))) + return 0; + g->gpe0_sts[0] |= 4; g->cpus_sts[cpu/8] &= ~(1 << (cpu%8)); + return 1; } void qemu_cpu_add_remove(int cpu, int state) @@ -746,10 +754,13 @@ void qemu_cpu_add_remove(int cpu, int state) return; } - if (state) - enable_processor(&gpe_state, cpu); - else - disable_processor(&gpe_state, cpu); + if (state) { + if (!enable_processor(&gpe_state, cpu)) + return; + } else { + if (!disable_processor(&gpe_state, cpu)) + return; + } if (gpe_state.gpe0_en[0] & 4) { qemu_set_irq(sci_irq, 1);