[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 11/16] (kvm)apic: add unrealize callbacks
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v4 11/16] (kvm)apic: add unrealize callbacks |
Date: |
Thu, 14 Jul 2016 18:54:40 +0200 |
callbacks will do necessary cleanups before APIC device is deleted
Signed-off-by: Chen Fan <address@hidden>
Signed-off-by: Gu Zheng <address@hidden>
Signed-off-by: Zhu Guihua <address@hidden>
Signed-off-by: Igor Mammedov <address@hidden>
---
CC: address@hidden
---
include/hw/i386/apic_internal.h | 1 +
hw/i386/kvm/apic.c | 5 +++++
hw/intc/apic.c | 10 ++++++++++
hw/intc/apic_common.c | 13 +++++++++++++
4 files changed, 29 insertions(+)
diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
index 8330592..e549a62 100644
--- a/include/hw/i386/apic_internal.h
+++ b/include/hw/i386/apic_internal.h
@@ -136,6 +136,7 @@ typedef struct APICCommonClass
DeviceClass parent_class;
DeviceRealize realize;
+ DeviceUnrealize unrealize;
void (*set_base)(APICCommonState *s, uint64_t val);
void (*set_tpr)(APICCommonState *s, uint8_t val);
uint8_t (*get_tpr)(APICCommonState *s);
diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
index 1f87e73..2bd0de8 100644
--- a/hw/i386/kvm/apic.c
+++ b/hw/i386/kvm/apic.c
@@ -192,11 +192,16 @@ static void kvm_apic_realize(DeviceState *dev, Error
**errp)
}
}
+static void kvm_apic_unrealize(DeviceState *dev, Error **errp)
+{
+}
+
static void kvm_apic_class_init(ObjectClass *klass, void *data)
{
APICCommonClass *k = APIC_COMMON_CLASS(klass);
k->realize = kvm_apic_realize;
+ k->unrealize = kvm_apic_unrealize;
k->reset = kvm_apic_reset;
k->set_base = kvm_apic_set_base;
k->set_tpr = kvm_apic_set_tpr;
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index f473572..45887d9 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -887,11 +887,21 @@ static void apic_realize(DeviceState *dev, Error **errp)
msi_nonbroken = true;
}
+static void apic_unrealize(DeviceState *dev, Error **errp)
+{
+ APICCommonState *s = APIC_COMMON(dev);
+
+ timer_del(s->timer);
+ timer_free(s->timer);
+ local_apics[s->id] = NULL;
+}
+
static void apic_class_init(ObjectClass *klass, void *data)
{
APICCommonClass *k = APIC_COMMON_CLASS(klass);
k->realize = apic_realize;
+ k->unrealize = apic_unrealize;
k->set_base = apic_set_base;
k->set_tpr = apic_set_tpr;
k->get_tpr = apic_get_tpr;
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index fd425d1..0bb9ad5 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -315,6 +315,18 @@ static void apic_common_realize(DeviceState *dev, Error
**errp)
}
+static void apic_common_unrealize(DeviceState *dev, Error **errp)
+{
+ APICCommonState *s = APIC_COMMON(dev);
+ APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
+
+ info->unrealize(dev, errp);
+
+ if (apic_report_tpr_access && info->enable_tpr_reporting) {
+ info->enable_tpr_reporting(s, false);
+ }
+}
+
static int apic_pre_load(void *opaque)
{
APICCommonState *s = APIC_COMMON(opaque);
@@ -421,6 +433,7 @@ static void apic_common_class_init(ObjectClass *klass, void
*data)
dc->reset = apic_reset_common;
dc->props = apic_properties_common;
dc->realize = apic_common_realize;
+ dc->unrealize = apic_common_unrealize;
/*
* Reason: APIC and CPU need to be wired up by
* x86_cpu_apic_create()
--
2.7.4
- Re: [Qemu-devel] [PATCH v4 05/16] pc: enforce adding CPUs contiguously and removing them in opposit order, (continued)
[Qemu-devel] [PATCH v4 06/16] pc: cpu: allow device_add to be used with x86 cpu, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 07/16] pc: implement query-hotpluggable-cpus callback, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 09/16] apic: drop APICCommonState.idx and use APIC ID as index in local_apics[], Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 08/16] apic: move MAX_APICS check to 'apic' class, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 11/16] (kvm)apic: add unrealize callbacks,
Igor Mammedov <=
[Qemu-devel] [PATCH v4 10/16] apic: kvm-apic: fix crash due to access to freed memory region, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 13/16] target-i386: cpu: do not ignore error and fix apic parent, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 12/16] apic: use apic_id as apic's migration instance_id, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 14/16] target-i386: fix apic object leak when CPU is deleted, Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 15/16] target-i386: add x86_cpu_unrealizefn(), Igor Mammedov, 2016/07/14
[Qemu-devel] [PATCH v4 16/16] pc: make device_del CPU work for x86 CPUs, Igor Mammedov, 2016/07/14
Re: [Qemu-devel] [PATCH v4 00/16] pc: add CPU hot-add/hot-remove with device_add/device_del, Michael S. Tsirkin, 2016/07/18