Received: from eggs.gnu.org ([2001:4830:134:3::10]:39816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Baf-0000wL-KM for qemu-devel@nongnu.org; Thu, 26 Jun 2014 11:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0BaW-0007Yp-KK for qemu-devel@nongnu.org; Thu, 26 Jun 2014 11:27:57 -0400 Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:56274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0BaW-0007Yg-B9 for qemu-devel@nongnu.org; Thu, 26 Jun 2014 11:27:48 -0400 Received: by mail-we0-f174.google.com with SMTP id u57so3991978wes.33 for ; Thu, 26 Jun 2014 08:27:45 -0700 (PDT) Date: Thu, 26 Jun 2014 17:27:35 +0200 From: Marc =?UTF-8?B?TWFyw60=?= Message-ID: <20140626172735.61327704@crunchbang> In-Reply-To: <53AC3798.50302@redhat.com> References: <1403793280-4353-1-git-send-email-marc.mari.barcelo@gmail.com> <53AC3798.50302@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Functions bus_foreach and device_find from libqos virtio API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Stefan Hajnoczi El Thu, 26 Jun 2014 17:09:12 +0200 Paolo Bonzini escribi=C3=B3: > Il 26/06/2014 16:34, Marc Mar=C3=AD ha scritto: > > +static void qvirtio_pci_foreach(uint16_t device_type, > > + void (*func)(QVirtioDevice *d, void *data), void > > *data) +{ > > + QVirtioPCIForeachData d =3D { .func =3D func, > > + .device_type =3D device_type, > > + .user_data =3D data }; > > + > > + if (!bus) { > > + bus =3D qpci_init_pc(); >=20 > Why not pass this as an argument? .bus_foreach and .device_find need=20 > not be part of QVirtioBus. If these functions are just Virtio PCI specific, it makes sense to take them out. If they are common to other transports, in my opinion is better to leave them there. Of course, a good solution has to be found to just having a global bus variable. It is also interesting to see that the current implementation of qpci_device_foreach does only work in one bus, so probably is not so terrible to have it as global and unique. After reading Virtio specs about MMIO and CCW transports, I understand that in MMIO you somehow choose an address to map the device, and in CCW there is a device discovery mechanism, so probably in CCW is interesting to have those functions. Marc