From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arAMk-0004hb-Sh for qemu-devel@nongnu.org; Fri, 15 Apr 2016 16:29:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1arAMf-0004rL-Rm for qemu-devel@nongnu.org; Fri, 15 Apr 2016 16:29:22 -0400 Received: from e18.ny.us.ibm.com ([129.33.205.208]:45625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arAMf-0004qQ-Nn for qemu-devel@nongnu.org; Fri, 15 Apr 2016 16:29:17 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Apr 2016 16:29:16 -0400 References: <1460750413-7963-1-git-send-email-duanj@linux.vnet.ibm.com> From: Jianjun Duan Message-ID: <57114F16.7020101@linux.vnet.ibm.com> Date: Fri, 15 Apr 2016 13:29:10 -0700 MIME-Version: 1.0 In-Reply-To: <1460750413-7963-1-git-send-email-duanj@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] spapr: ensure device trees are always associated with DRC List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Please disregard this patch. It should be part of a sequence. Thanks, Jianjun On 04/15/2016 01:00 PM, Jianjun Duan wrote: > There are possible racing situations involving hotplug events and > guest migration. For cases where a hotplug event is migrated, or > the guest is in the process of fetching device tree at the time of > migration, we need to ensure the device tree is created and > associated with the corresponding DRC for devices that were > hotplugged on the source, but 'coldplugged' on the target. > > Signed-off-by: Jianjun Duan > --- > hw/ppc/spapr.c | 16 ++++++---------- > hw/ppc/spapr_pci.c | 12 +++++------- > 2 files changed, 11 insertions(+), 17 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index feaab08..af4745c 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2132,15 +2132,6 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr, uint64_t size, > int i, fdt_offset, fdt_size; > void *fdt; > > - /* > - * Check for DRC connectors and send hotplug notification to the > - * guest only in case of hotplugged memory. This allows cold plugged > - * memory to be specified at boot time. > - */ > - if (!dev->hotplugged) { > - return; > - } > - > for (i = 0; i < nr_lmbs; i++) { > drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, > addr/SPAPR_MEMORY_BLOCK_SIZE); > @@ -2154,7 +2145,12 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr, uint64_t size, > drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp); > addr += SPAPR_MEMORY_BLOCK_SIZE; > } > - spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs); > + /* send hotplug notification to the > + * guest only in case of hotplugged memory > + */ > + if (dev->hotplugged) { > + spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs); > + } > } > > static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > index 8c20d34..b179e42 100644 > --- a/hw/ppc/spapr_pci.c > +++ b/hw/ppc/spapr_pci.c > @@ -1092,13 +1092,11 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, > spapr_tce_set_need_vfio(tcet, true); > } > > - if (dev->hotplugged) { > - fdt = create_device_tree(&fdt_size); > - fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0); > - if (!fdt_start_offset) { > - error_setg(errp, "Failed to create pci child device tree node"); > - goto out; > - } > + fdt = create_device_tree(&fdt_size); > + fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0); > + if (!fdt_start_offset) { > + error_setg(errp, "Failed to create pci child device tree node"); > + goto out; > } > > drck->attach(drc, DEVICE(pdev),