From d30410dc9acad19b2b157327b1781de4be14455b Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Sun, 25 Feb 2018 20:51:31 -0500 Subject: [PATCH] target-i386: Add x86_cpu_unrealizefn() First remove VCPU from exec loop and only then remove lapic. Backports commit c884776e9dc947105827bd6c22192863f97267d2 from qemu --- qemu/hw/core/qdev.c | 4 ++-- qemu/include/hw/qdev-core.h | 2 +- qemu/target-i386/cpu.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/qemu/hw/core/qdev.c b/qemu/hw/core/qdev.c index 8fc6dbdf..527c70a6 100644 --- a/qemu/hw/core/qdev.c +++ b/qemu/hw/core/qdev.c @@ -213,7 +213,7 @@ static int device_set_realized(struct uc_struct *uc, Object *obj, bool value, Er } if (dc->unrealize) { local_errp = local_err ? NULL : &local_err; - dc->unrealize(dev, local_errp); + dc->unrealize(uc, dev, local_errp); } dev->pending_deleted_event = true; } @@ -233,7 +233,7 @@ child_realize_fail: post_realize_fail: if (dc->unrealize) { - dc->unrealize(dev, NULL); + dc->unrealize(uc, dev, NULL); } fail: diff --git a/qemu/include/hw/qdev-core.h b/qemu/include/hw/qdev-core.h index f6d5db7e..3e6a11f1 100644 --- a/qemu/include/hw/qdev-core.h +++ b/qemu/include/hw/qdev-core.h @@ -32,7 +32,7 @@ typedef int (*qdev_initfn)(DeviceState *dev); typedef int (*qdev_event)(DeviceState *dev); typedef void (*qdev_resetfn)(DeviceState *dev); typedef int (*DeviceRealize)(struct uc_struct *uc, DeviceState *dev, Error **errp); -typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); +typedef void (*DeviceUnrealize)(struct uc_struct *uc, DeviceState *dev, Error **errp); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus, Error **errp); diff --git a/qemu/target-i386/cpu.c b/qemu/target-i386/cpu.c index 49ddd8ef..6c36fa29 100644 --- a/qemu/target-i386/cpu.c +++ b/qemu/target-i386/cpu.c @@ -3103,6 +3103,22 @@ out: return 0; } +static void x86_cpu_unrealizefn(struct uc_struct *uc, DeviceState *dev, Error **errp) +{ + /* Unicorn: commented out + X86CPU *cpu = X86_CPU(uc, dev); + +#ifndef CONFIG_USER_ONLY + cpu_remove_sync(CPU(dev)); + qemu_unregister_reset(x86_cpu_machine_reset_cb, dev); +#endif + + if (cpu->apic_state) { + object_unparent(OBJECT(cpu->apic_state)); + cpu->apic_state = NULL; + }*/ +} + static void x86_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) { //printf("... X86 initialize (object)\n"); @@ -3206,6 +3222,7 @@ static void x86_cpu_common_class_init(struct uc_struct *uc, ObjectClass *oc, voi xcc->parent_realize = dc->realize; dc->realize = x86_cpu_realizefn; + dc->unrealize = x86_cpu_unrealizefn; dc->bus_type = TYPE_ICC_BUS; xcc->parent_reset = cc->reset;