From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD6ZP-0001kL-GJ for qemu-devel@nongnu.org; Thu, 09 Jul 2015 03:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZD6ZJ-0002O7-1V for qemu-devel@nongnu.org; Thu, 09 Jul 2015 03:48:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD6ZI-0002Nv-SU for qemu-devel@nongnu.org; Thu, 09 Jul 2015 03:48:28 -0400 Date: Thu, 9 Jul 2015 10:48:25 +0300 From: "Michael S. Tsirkin" Message-ID: <20150709074824.GA10208@redhat.com> References: <1436334295-6012-1-git-send-email-zyimin@linux.vnet.ibm.com> <1436334295-6012-2-git-send-email-zyimin@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1436334295-6012-2-git-send-email-zyimin@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v4 1/1] s390 pci infrastructure modelling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yi Min Zhao Cc: cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, qemu-devel@nongnu.org, agraf@suse.de On Wed, Jul 08, 2015 at 01:44:55PM +0800, Yi Min Zhao wrote: > @@ -588,9 +606,172 @@ static const TypeInfo s390_pcihost_info = { > } > }; > > +static void s390_pci_device_hot_plug(HotplugHandler *hotplug_dev, > + DeviceState *dev, Error **errp) > +{ > + S390PCIBusDevice *zpci = S390_PCI_DEVICE(dev); > + S390PCIBusDevice *tmp; > + S390PCIFacility *f = S390_PCI_FACILITY( > + object_resolve_path(TYPE_S390_PCI_FACILITY, NULL)); > + > + QTAILQ_FOREACH(tmp, &f->zpci_list, next) { > + /* for now, we use fid to sort the list, need to use uid instead > + * when uid is ready. What does ready mean in this context? > + */ > + if (tmp->fid > zpci->fid) { > + break; > + } > + } > + > + if (tmp) { > + QTAILQ_INSERT_BEFORE(tmp, zpci, next); > + } else { > + QTAILQ_INSERT_TAIL(&f->zpci_list, zpci, next); > + } > + f->token_valid = false; > +} This still means hotplug will change the index. How about just using an explicit property to set the index? Harder to use but keeps code simple. -- MST