From: David Hildenbrand <david@redhat.com>
To: Igor Mammedov <imammedo@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>,
Murilo Opsfelder Araujo <muriloo@linux.ibm.com>,
qemu-ppc@nongnu.org, qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFCv2 9/9] pc: Support for virtio-pmem-pci
Date: Wed, 6 Feb 2019 14:10:04 +0100 [thread overview]
Message-ID: <964a0adf-ea69-4057-4283-171b5cdb3640@redhat.com> (raw)
In-Reply-To: <20190206140145.5f98dff9@Igors-MacBook-Pro.local>
On 06.02.19 14:01, Igor Mammedov wrote:
> On Wed, 23 Jan 2019 20:55:27 +0100
> David Hildenbrand <david@redhat.com> wrote:
>
>> Override the device hotplug handler to properly handle the memory device
>> part via virtio-pmem-pci callbacks 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 PCI host
>> buses don't have a PCI hotplug handler at all yet, just to be sure that
>> we alway have a hotplug handler on x86, add a simple error check.
>>
>> Unlocking virtio-pmem will unlock virtio-pmem-pci.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>> default-configs/i386-softmmu.mak | 1 +
>> hw/i386/pc.c | 70 +++++++++++++++++++++++++++++++-
>> 2 files changed, 70 insertions(+), 1 deletion(-)
>>
>> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
>> index 64c998c4c8..3f63e95a55 100644
>> --- a/default-configs/i386-softmmu.mak
>> +++ b/default-configs/i386-softmmu.mak
>> @@ -52,6 +52,7 @@ CONFIG_APIC=y
>> CONFIG_IOAPIC=y
>> CONFIG_PVPANIC=y
>> CONFIG_MEM_DEVICE=y
>> +CONFIG_VIRTIO_PMEM=y
>> CONFIG_DIMM=y
>> CONFIG_NVDIMM=y
>> CONFIG_ACPI_NVDIMM=y
>> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
>> index fd0cb29ba9..6a176caeb9 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/virtio/virtio-pmem-pci.h"
>>
>> /* debug PC/ISA interrupts */
>> //#define DEBUG_IRQ
>> @@ -2224,6 +2225,64 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
>> numa_cpu_pre_plug(cpu_slot, dev, errp);
>> }
>>
>> +static void pc_virtio_pmem_pci_pre_plug(HotplugHandler *hotplug_dev,
>> + DeviceState *dev, Error **errp)
>> +{
>> + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
>> + Error *local_err = NULL;
>> +
>> + if (!hotplug_dev2) {
>> + /*
>> + * Without a bus hotplug handler, we cannot control the plug/unplug
>> + * order. This should never be the case on x86, however better add
>> + * a safety net.
>> + */
>> + error_setg(errp, "virtio-pmem-pci not supported on this bus.");
>> + return;
>> + }
>> + virtio_pmem_pci_pre_plug(VIRTIO_PMEM_PCI(dev), MACHINE(hotplug_dev),
> ^^^
> doesn't do anything beside being dumb proxy to memory_device_pre_plug()
> I'd just use memory_device_pre_plug() here and avoid so far needles wrappers
Had that initially but considered it cleaner. But I can change that back.
>
>> + &local_err);
>> + if (!local_err) {
> since logic is not trivial I'd add comment somewhere in this function
> explaining why handlers are called in this particular order.
Good idea, will do that.
Thanks!
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-02-06 13:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 19:55 [Qemu-devel] [PATCH RFCv2 0/9] qdev: Hotplug handler chaining + virtio-pmem David Hildenbrand
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 1/9] qdev: Let the hotplug_handler_unplug() caller delete the device David Hildenbrand
2019-01-28 14:07 ` Cornelia Huck
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 2/9] qdev: Let machine hotplug handler to override bus hotplug handler David Hildenbrand
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 3/9] qdev: Provide qdev_get_bus_hotplug_handler() David Hildenbrand
2019-01-28 14:01 ` Igor Mammedov
2019-01-28 14:02 ` David Hildenbrand
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 4/9] virtio-pmem: Prototype David Hildenbrand
2019-01-31 18:19 ` Markus Armbruster
2019-01-31 18:54 ` David Hildenbrand
2019-02-01 7:08 ` Markus Armbruster
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 5/9] virtio-pci: Allow to specify additional interfaces for the base type David Hildenbrand
2019-01-28 14:09 ` Cornelia Huck
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 6/9] virtio-pci: Proxy for virtio-pmem David Hildenbrand
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 7/9] hmp: Handle virtio-pmem when printing memory device infos David Hildenbrand
2019-01-25 17:58 ` Dr. David Alan Gilbert
2019-01-31 18:23 ` Markus Armbruster
2019-02-01 10:49 ` Dr. David Alan Gilbert
2019-02-01 14:11 ` Markus Armbruster
2019-02-01 15:15 ` Dr. David Alan Gilbert
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 8/9] numa: Handle virtio-pmem in NUMA stats David Hildenbrand
2019-01-23 19:55 ` [Qemu-devel] [PATCH RFCv2 9/9] pc: Support for virtio-pmem-pci David Hildenbrand
2019-02-06 13:01 ` Igor Mammedov
2019-02-06 13:10 ` David Hildenbrand [this message]
2019-01-28 14:18 ` [Qemu-devel] [PATCH RFCv2 0/9] qdev: Hotplug handler chaining + virtio-pmem Igor Mammedov
2019-01-28 14:22 ` David Hildenbrand
2019-01-31 14:52 ` David Hildenbrand
2019-02-06 13:18 ` Igor Mammedov
2019-02-06 13:26 ` 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=964a0adf-ea69-4057-4283-171b5cdb3640@redhat.com \
--to=david@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=muriloo@linux.ibm.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).