[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH 6/6] i386: implement cpu interface 'cpu_common_
From: |
Chen Fan |
Subject: |
[Qemu-devel] [RFC][PATCH 6/6] i386: implement cpu interface 'cpu_common_unrealizefn' |
Date: |
Thu, 29 Aug 2013 10:09:45 +0800 |
Implement cpu interface 'cpu_common_unrealizefn' for emiting vcpu-remove
notifier to ACPI, then ACPI could send sci interrupt to OS for hot-remove
vcpu.
Signed-off-by: Chen Fan <address@hidden>
---
hw/i386/pc.c | 19 ++++++++++++++++++-
qom/cpu.c | 13 +++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 75fc9bb..9a87ac0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -960,7 +960,24 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
void pc_hot_del_cpu(const int64_t id, Error **errp)
{
- /* TODO: hot remove VCPU. */
+ CPUState *s = NULL;
+ X86CPU *cpu = NULL;
+ DeviceState *ds = NULL;
+ DeviceClass *dc = NULL;
+
+ s = qemu_get_cpu(id);
+ if (s == NULL) {
+ error_setg(errp, "Unable to find cpu-index: %" PRIi64
+ ",it non-exists or has been deleted.", id);
+ return;
+ }
+
+ cpu = X86_CPU(s);
+ ds = DEVICE(cpu);
+ dc = DEVICE_GET_CLASS(ds);
+ if (dc->unrealize) {
+ dc->unrealize(ds, errp);
+ }
}
void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
diff --git a/qom/cpu.c b/qom/cpu.c
index 3439c5d..d2b0c9e 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -239,6 +239,18 @@ static void cpu_common_realizefn(DeviceState *dev, Error
**errp)
}
}
+static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
+{
+ CPUNotifier notifier;
+
+ notifier.dev = dev;
+ notifier.type = UNPLUG;
+
+ if (dev->hotplugged) {
+ notifier_list_notify(&cpu_hotplug_notifiers, ¬ifier);
+ }
+}
+
static void cpu_common_initfn(Object *obj)
{
CPUState *cpu = CPU(obj);
@@ -269,6 +281,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
dc->realize = cpu_common_realizefn;
+ dc->unrealize = cpu_common_unrealizefn;
dc->no_user = 1;
}
--
1.8.1.4
- [Qemu-devel] [RFC][PATCH 0/6] i386: add cpu hot remove support, Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 2/6] cpus: release allocated vcpu objects and exit vcpu thread, Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 4/6] qmp: add 'cpu-del' command support, Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 3/6] qom cpu: rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier', Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 1/6] piix4: implement function 'cpu_status_write' for vcpu ejection, Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 5/6] qom cpu: add struct CPUNotifier for supporting PLUG and UNPLUG cpu notifier, Chen Fan, 2013/08/28
- [Qemu-devel] [RFC][PATCH 6/6] i386: implement cpu interface 'cpu_common_unrealizefn',
Chen Fan <=