From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 3 of 4 v2] libxl: Introduce pci_assignable_add and pci_assignable_remove Date: Mon, 21 May 2012 10:13:25 -0400 Message-ID: <20120521141324.GJ8119@phenom.dumpdata.com> References: <5e21532dab5b1c31e54e.1336743092@kodo2> <1336987293.31817.41.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1336987293.31817.41.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: George Dunlap , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Mon, May 14, 2012 at 10:21:33AM +0100, Ian Campbell wrote: > > + > > +/* Scan through /sys/.../pciback/slots looking for pcidev's BDF */ > > +static int pciback_dev_has_slot(libxl__gc *gc, libxl_device_pci *pcidev) > > +{ > > + libxl_ctx *ctx = libxl__gc_owner(gc); > > + FILE *f; > > + int rc = 0; > > + unsigned dom, bus, dev, func; > > + > > + f = fopen(SYSFS_PCIBACK_DRIVER"/slots", "r"); > > + > > + if (f == NULL) { > > + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", > > + SYSFS_PCIBACK_DRIVER"/slots"); > > + return ERROR_FAIL; > > + } > > + > > + while(fscanf(f, "%x:%x:%x.%x\n", &dom, &bus, &dev, &func)==3) { And the last one should be %d. > > Shouldn't this 3 be 4 now that you include dom? > > Also ISTR some change to the precise formatting using by the kernel for > BDFs recently (A . became a : or vice versa?). CCing Konrad for input in > case it impacts this too. > > The rest all looked fine. > > > + if(dom == pcidev->domain > > + && bus == pcidev->bus > > + && dev == pcidev->dev > > + && func == pcidev->func) { > > + rc = 1; > > + goto out; > > + } > > + } > > +out: > > + fclose(f); > > + return rc; > > +} > > +