From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn4l7-0000kk-QI for qemu-devel@nongnu.org; Wed, 21 May 2014 07:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wn4kz-00022B-H1 for qemu-devel@nongnu.org; Wed, 21 May 2014 07:32:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn4kz-000227-9Q for qemu-devel@nongnu.org; Wed, 21 May 2014 07:32:25 -0400 From: Igor Mammedov Date: Wed, 21 May 2014 13:29:42 +0200 Message-Id: <1400671787-14214-1-git-send-email-imammedo@redhat.com> In-Reply-To: <1400598934-31921-1-git-send-email-imammedo@redhat.com> References: <1400598934-31921-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 22/31] 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: peter.maydell@linaro.org, alex@alex.org.uk, mst@redhat.com, aik@ozlabs.ru, jan.kiszka@siemens.com, mjt@tls.msk.ru, lcapitulino@redhat.com, kraxel@redhat.com, pasteka@kabsi.at, s.priebe@profihost.ag, agarcia@igalia.com, armbru@redhat.com, aliguori@amazon.com, hutao@cn.fujitsu.com, david@gibson.dropbear.id.au, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, tangchen@cn.fujitsu.com, rth@twiddle.net, agraf@suse.de, andrey@xdel.ru, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de, aurelien@aurel32.net ... and report error if plugged in device is not supported. Later these callbacks will be used by memory hotplug. Signed-off-by: Igor Mammedov --- 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