From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrSHo-0004LE-J3 for qemu-devel@nongnu.org; Mon, 02 Jun 2014 09:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrSHj-00085Z-Dz for qemu-devel@nongnu.org; Mon, 02 Jun 2014 09:28:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrSHj-00085P-3J for qemu-devel@nongnu.org; Mon, 02 Jun 2014 09:28:19 -0400 From: Igor Mammedov Date: Mon, 2 Jun 2014 15:25:19 +0200 Message-Id: <1401715529-636-24-git-send-email-imammedo@redhat.com> In-Reply-To: <1401715529-636-1-git-send-email-imammedo@redhat.com> References: <1401715529-636-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v4 23/33] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lcapitulino@redhat.com, aliguori@amazon.com, mst@redhat.com ... and report error if plugged in device is not supported. Later these callbacks will be used by memory hotplug. Signed-off-by: Igor Mammedov Acked-by: Peter Crosthwaite --- hw/acpi/piix4.c | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 67dc075..4341f82 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -310,19 +310,32 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque) acpi_pm1_evt_power_down(&s->ar); } -static void piix4_pci_device_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PIIX4PMState *s = PIIX4_PM(hotplug_dev); - acpi_pcihp_device_plug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, errp); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_plug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, + errp); + } else { + error_setg(errp, "acpi: device plug request for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } -static void piix4_pci_device_unplug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PIIX4PMState *s = PIIX4_PM(hotplug_dev); - acpi_pcihp_device_unplug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, - errp); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_unplug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, + errp); + } else { + error_setg(errp, "acpi: device unplug request for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque) @@ -553,8 +566,8 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) */ dc->cannot_instantiate_with_device_add_yet = true; dc->hotpluggable = false; - hc->plug = piix4_pci_device_plug_cb; - hc->unplug = piix4_pci_device_unplug_cb; + hc->plug = piix4_device_plug_cb; + hc->unplug = piix4_device_unplug_cb; } static const TypeInfo piix4_pm_info = { -- 1.7.1