From: Igor Mammedov <imammedo@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: qemu-devel@nongnu.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>,
Cornelia Huck <cohuck@redhat.com>,
Halil Pasic <pasic@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Collin Walling <walling@linux.ibm.com>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-ppc@nongnu.org, qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 09/10] pc: Support for PCI based memory devices
Date: Fri, 18 Jan 2019 15:37:58 +0100 [thread overview]
Message-ID: <20190118153758.2c45a31a@redhat.com> (raw)
In-Reply-To: <1f1b6173-ba9f-46b8-4e54-846f48459b4d@redhat.com>
On Fri, 18 Jan 2019 13:53:14 +0100
David Hildenbrand <david@redhat.com> wrote:
> On 18.01.19 11:20, Igor Mammedov wrote:
> > On Wed, 16 Jan 2019 12:35:22 +0100
> > David Hildenbrand <david@redhat.com> wrote:
> >
> >> Override the PCI device hotplug handler to properly handle the
> >> memory device part from the machine hotplug handler and forward to the
> >> actual PCI bus hotplug handler.
> >>
> >> As PCI hotplug has not been properly factored out into hotplug handlers,
> >> most magic is performed in the (un)realize functions. Also some buses don't
> > ^^^^^^^^ pls, be more specific
>
> Last time I checked there were some TYPE_PCI_HOST_BRIDGE devices in QEMU
> that would not have a hotplug handler. I *think* they are all unrelated
> to x86/pc. But as I was not sure if I am missing something, I introduced
> a simple error check.
>
> >
> >> have a PCI hotplug handler at all yet (not sure if they are actually used
> >> on x86, but just to be sure).
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >> ---
> >> hw/i386/pc.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> >> 1 file changed, 89 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> >> index fd0cb29ba9..62f83859fa 100644
> >> --- a/hw/i386/pc.c
> >> +++ b/hw/i386/pc.c
> >> @@ -75,6 +75,7 @@
> >> #include "hw/usb.h"
> >> #include "hw/i386/intel_iommu.h"
> >> #include "hw/net/ne2000-isa.h"
> >> +#include "hw/mem/memory-device.h"
> >>
> >> /* debug PC/ISA interrupts */
> >> //#define DEBUG_IRQ
> >> @@ -2224,6 +2225,84 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
> >> numa_cpu_pre_plug(cpu_slot, dev, errp);
> >> }
> >>
> >> +static void pc_pci_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >> + Error **errp)
> >> +{
> >> + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
> >> + Error *local_err = NULL;
> >> +
> >> + if (object_dynamic_cast(OBJECT(dev), TYPE_MEMORY_DEVICE)) {
> >> + if (!hotplug_dev2) {
> >> + /*
> >> + * Without a bus hotplug handler, we cannot control the plug/unplug
> >> + * order. Disallow memory devices on such buses.
> >> + */
> >> + error_setg(errp, "Memory devices not supported on this bus.");
> >> + return;
> >> + }
> >> + memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev),
> >> + NULL, errp);
> >> + }
> >> +
> >> + if (hotplug_dev2) {
> >> + hotplug_handler_pre_plug(hotplug_dev2, dev, errp);
> >> + if (local_err) {
> >> + error_propagate(errp, local_err);
> >> + return;
> >> + }
> >> + }
> >> +}
> >> +
> >> +static void pc_pci_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >> + Error **errp)
> >> +{
> >> + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
> >> + Error *local_err = NULL;
> >> +
> >> + if (object_dynamic_cast(OBJECT(dev), TYPE_MEMORY_DEVICE)) {
> >> + memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
> >> + }
> >> +
> >> + if (hotplug_dev2) {
> >> + hotplug_handler_plug(hotplug_dev2, dev, &local_err);
> >> + }
> >> +
> >> + if (local_err) {
> >> + if (object_dynamic_cast(OBJECT(dev), TYPE_MEMORY_DEVICE)) {
> >> + memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
> >> + }
> >> + }
> >> + error_propagate(errp, local_err);
> >> +}
> >> +
> >> +static void pc_pci_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,
> >> + Error **errp)
> >> +{
> >> + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
> >> +
> >> + if (hotplug_dev2) {
> >> + hotplug_handler_unplug_request(hotplug_dev2, dev, errp);
> >> + }
> >> +}
> >> +
> >> +static void pc_pci_device_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >> + Error **errp)
> >> +{
> >> + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
> >> + Error *local_err = NULL;
> >> +
> >> + if (hotplug_dev2) {
> >> + hotplug_handler_unplug(hotplug_dev2, dev, &local_err);
> >> + }
> >> +
> >> + if (!local_err) {
> >> + if (object_dynamic_cast(OBJECT(dev), TYPE_MEMORY_DEVICE)) {
> >> + memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
> >> + }
> >> + }
> >> + error_propagate(errp, local_err);
> >> +}
> >> +
> >> static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> >> DeviceState *dev, Error **errp)
> >> {
> >> @@ -2231,6 +2310,8 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> >> pc_memory_pre_plug(hotplug_dev, dev, errp);
> >> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> pc_cpu_pre_plug(hotplug_dev, dev, errp);
> >> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
> >> + pc_pci_pre_plug(hotplug_dev, dev, errp);
> >> }
> >> }
> >>
> >> @@ -2241,6 +2322,8 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> >> pc_memory_plug(hotplug_dev, dev, errp);
> >> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> pc_cpu_plug(hotplug_dev, dev, errp);
> >> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
> >> + pc_pci_plug(hotplug_dev, dev, errp);
> >> }
> >> }
> >>
> >> @@ -2251,6 +2334,8 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
> >> pc_memory_unplug_request(hotplug_dev, dev, errp);
> >> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> pc_cpu_unplug_request_cb(hotplug_dev, dev, errp);
> >> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
> >> + pc_pci_unplug_request(hotplug_dev, dev, errp);
> >> } else {
> >> error_setg(errp, "acpi: device unplug request for not supported device"
> >> " type: %s", object_get_typename(OBJECT(dev)));
> >> @@ -2264,6 +2349,8 @@ static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev,
> >> pc_memory_unplug(hotplug_dev, dev, errp);
> >> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> pc_cpu_unplug_cb(hotplug_dev, dev, errp);
> >> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
> >> + pc_pci_device_unplug(hotplug_dev, dev, errp);
> >> } else {
> >> error_setg(errp, "acpi: device unplug for not supported device"
> >> " type: %s", object_get_typename(OBJECT(dev)));
> >> @@ -2274,7 +2361,8 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
> >> DeviceState *dev)
> >> {
> >> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
> >> - object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> + object_dynamic_cast(OBJECT(dev), TYPE_CPU) ||
> >> + object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
> > why all PCI devices instead of virtio-pmem-pci one?
> >
>
> Last time I tried to include "hw/virtio/virtio-pci.h" in pc.c it
> resulted in an inclusion error madness. But this should be easy to fix I
> guess. (the basic idea of this patch is the important bit)
>
> And I just tried to include and it seems to result in no errors right now
I'd prefer override for concrete devices only and the rest PCI devices
handled as they used to. That also should simplify hotplug handlers you
are adding here.
>
> >> return HOTPLUG_HANDLER(machine);
> >> }
> >>
> >
>
>
next prev parent reply other threads:[~2019-01-18 14:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 11:35 [Qemu-devel] [PATCH RFC 00/10] qdev: Hotplug handler chaining + virtio-pmem David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 01/10] qdev: Let the hotplug_handler_unplug() caller delete the device David Hildenbrand
2019-01-18 9:58 ` Igor Mammedov
2019-01-18 12:41 ` David Hildenbrand
2019-01-18 15:05 ` Igor Mammedov
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 02/10] qdev: Let machine hotplug handler to override bus hotplug handler David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 03/10] qdev: Provide qdev_get_bus_hotplug_handler() David Hildenbrand
2019-01-16 18:41 ` [Qemu-devel] [Qemu-ppc] " Murilo Opsfelder Araujo
2019-01-17 12:16 ` David Hildenbrand
2019-01-18 10:07 ` [Qemu-devel] " Igor Mammedov
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 04/10] virtio-pmem: Prototype David Hildenbrand
2019-01-16 14:46 ` Eric Blake
2019-01-17 12:18 ` David Hildenbrand
2019-01-21 11:52 ` David Hildenbrand
2019-01-21 12:02 ` Dr. David Alan Gilbert
2019-01-21 13:31 ` David Hildenbrand
2019-01-21 17:15 ` Eric Blake
2019-01-16 19:20 ` [Qemu-devel] [Qemu-ppc] " Murilo Opsfelder Araujo
2019-01-17 12:23 ` David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 05/10] virtio-pci: Allow to specify additional interfaces for the base type David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 06/10] virtio-pci: Proxy for virtio-pmem David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 07/10] hmp: Handle virtio-pmem when printing memory device infos David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 08/10] numa: Handle virtio-pmem in NUMA stats David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 09/10] pc: Support for PCI based memory devices David Hildenbrand
2019-01-18 10:20 ` Igor Mammedov
2019-01-18 12:53 ` David Hildenbrand
2019-01-18 14:37 ` Igor Mammedov [this message]
2019-01-21 10:31 ` David Hildenbrand
2019-01-16 11:35 ` [Qemu-devel] [PATCH RFC 10/10] pc: Enable support for virtio-pmem David Hildenbrand
2019-01-16 11:41 ` [Qemu-devel] [PATCH RFC 00/10] qdev: Hotplug handler chaining + virtio-pmem David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190118153758.2c45a31a@redhat.com \
--to=imammedo@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
--cc=walling@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).