From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlySX-0004v3-CX for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:13:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlyST-0004By-Sf for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:13:37 -0400 Received: from [59.151.112.132] (port=25807 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlyST-0004Ay-3t for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:13:33 -0400 References: <1444725695-27517-1-git-send-email-caoj.fnst@cn.fujitsu.com> <1444725695-27517-3-git-send-email-caoj.fnst@cn.fujitsu.com> <20151013114654-mutt-send-email-mst@redhat.com> From: Cao jin Message-ID: <561CF6C1.3030008@cn.fujitsu.com> Date: Tue, 13 Oct 2015 20:19:13 +0800 MIME-Version: 1.0 In-Reply-To: <20151013114654-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC] hw/virtio: Add PCIe capability to virtio devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: pbonzini@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org, izumi.taku@jp.fujitsu.com Hi, Michael Thanks for your quick response:) On 10/13/2015 04:48 PM, Michael S. Tsirkin wrote: > On Tue, Oct 13, 2015 at 04:41:35PM +0800, Cao jin wrote: >> In case user regret when hot-adding multi-function, should roll back, >> device_del the function added but not exposed to the guest. >> >> Signed-off-by: Cao jin >> --- >> hw/pci/pci_host.c | 6 +++++- >> hw/pci/pcie.c | 22 +++++++++++++++++----- >> 2 files changed, 22 insertions(+), 6 deletions(-) >> >> diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c >> index 3e26f92..35e5cf3 100644 >> --- a/hw/pci/pci_host.c >> +++ b/hw/pci/pci_host.c >> @@ -20,6 +20,7 @@ >> >> #include "hw/pci/pci.h" >> #include "hw/pci/pci_host.h" >> +#include "hw/pci/pci_bus.h" >> #include "trace.h" >> >> /* debug PCI */ >> @@ -88,10 +89,13 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) >> uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len) >> { >> PCIDevice *pci_dev = pci_dev_find_by_addr(s, addr); >> + PCIDevice *f0 = NULL; >> uint32_t config_addr = addr & (PCI_CONFIG_SPACE_SIZE - 1); >> uint32_t val; >> + uint8_t slot = (addr >> 11) & 0x1F; >> >> - if (!pci_dev) { >> + f0 = s->devices[PCI_DEVFN(slot, 0)]; >> + if (!pci_dev || (!f0 && pci_dev)) { >> return ~0x0; >> } >> > > This seems to belong to the previous patch? > Strictly speaking, yes, will move it in next version. >> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c >> index 89bf61b..58d2153 100644 >> --- a/hw/pci/pcie.c >> +++ b/hw/pci/pcie.c >> @@ -261,13 +261,30 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, >> } >> } >> >> +static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) >> +{ >> + object_unparent(OBJECT(dev)); >> +} >> + >> void pcie_cap_slot_hot_unplug_request_cb(HotplugHandler *hotplug_dev, >> DeviceState *dev, Error **errp) >> { >> uint8_t *exp_cap; >> + PCIDevice *pci_dev = PCI_DEVICE(dev); >> + PCIBus *bus = pci_dev->bus; >> >> pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp); >> >> + /* In case user regret when hot-adding multi function, remove the function >> + * that is unexposed to guest individually, without interaction with guest. >> + */ >> + if (PCI_FUNC(pci_dev->devfn) > 0 && >> + bus->devices[PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 0)] == NULL) { > > Shorter: PCI_FUNC(pci_dev->devfn) && > !bus->devices[PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 0)] > Ok, will fix it in next vertion > >> + pcie_unplug_device(bus, pci_dev, NULL); >> + >> + return; >> + } >> + >> pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev)); >> } >> >> @@ -378,11 +395,6 @@ void pcie_cap_slot_reset(PCIDevice *dev) >> hotplug_event_update_event_status(dev); >> } >> >> -static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) >> -{ >> - object_unparent(OBJECT(dev)); >> -} >> - >> void pcie_cap_slot_write_config(PCIDevice *dev, >> uint32_t addr, uint32_t val, int len) >> { >> -- >> 2.1.0 > . > -- Yours Sincerely, Cao Jin