From: Ian Campbell Subject: Re: [PATCH 6/7] libxl_qmp, Introduce libxl__qmp_pci_add. Date: Fri, 7 Oct 2011 19:29:03 +0100 Message-ID: <1318012143.13747.3.camel@dagon.hellion.org.uk> References: <1317989418-25463-1-git-send-email-anthony.perard@citrix.com> <1317989418-25463-7-git-send-email-anthony.perard@citrix.com> <1317991406.21903.343.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Anthony PERARD Cc: Xen Devel , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Fri, 2011-10-07 at 17:01 +0100, Anthony PERARD wrote: > On Fri, Oct 7, 2011 at 13:43, Ian Campbell wrote: > > On Fri, 2011-10-07 at 13:10 +0100, Anthony PERARD wrote: > >> This function insert a PCI passthrough device in qemu. > >> > >> Signed-off-by: Anthony PERARD > >> --- > >> tools/libxl/libxl_internal.h | 2 + > >> tools/libxl/libxl_qmp.c | 89 ++++++++++++++++++++++++++++++++++++++++++ > >> 2 files changed, 91 insertions(+), 0 deletions(-) > >> > >> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > >> index 4dd0f91..78e1be2 100644 > >> --- a/tools/libxl/libxl_internal.h > >> +++ b/tools/libxl/libxl_internal.h > >> @@ -119,6 +119,7 @@ typedef struct { > >> } libxl__device; > >> > >> #define XC_PCI_BDF "0x%x, 0x%x, 0x%x, 0x%x" > >> +#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) > > > > No need to include the domain or dev in this? The name is pretty weird > > if you don't include the dev portion. Looks like this is actually a > > vdevfn? xl has an open coded instance of this pattern for that -- worth > > adding a public macro? > > I have actual copy the macro from qemu, and I think "slot === dev". It appears to yes. > I > think the macro come from linux/pci.h. > But yes, I use it to store the vdevfn. > > > FWIW pcidev_encode_bdf() exists which encodes the whole lot from a > > libxl_device_pci, if that what you end up needing. > > If the vdefvn should contain the virtual bus and domain number, so > yes, that will be the function I need. I don't think it does in the old qemu stuff, but I don't know about upstream, I suspect not. >