WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [rfc 2/4] ioemu: Do slot parsing inside of next_bdf

To: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [rfc 2/4] ioemu: Do slot parsing inside of next_bdf
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Mon, 23 Mar 2009 20:54:46 +1100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 23 Mar 2009 02:55:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090320222816.506523838@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090320222435.469444366@xxxxxxxxxxxx> <20090320222816.506523838@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.18 (2008-05-17)
Currently only hotplug provides vslot information from xend.
A subsequent patch will have xend provide this information
for boot-time inserted pass-through devices too.

With this in mind, this patch makes some infrastructure
to parse bdf + slot information.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

* Sat, 21 Mar 2009 09:24:37 +1100
  Initial Public Release

* Mon, 23 Mar 2009 20:38:40 +1100
  Remove a bogus second assignment of *vslot* inside next_bdf().
  Unfortunately this crept into the version I posted while
  my testing was against a versino without it.

Index: ioemu-remote/hw/pass-through.c
===================================================================
--- ioemu-remote.orig/hw/pass-through.c 2009-03-23 20:32:31.000000000 +1100
+++ ioemu-remote/hw/pass-through.c      2009-03-23 20:37:17.000000000 +1100
@@ -770,9 +770,10 @@ static int token_value(char *token)
     return strtol(token, NULL, 16);
 }
 
-static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func, char 
**opt)
+static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func,
+                    char **opt, int *vslot)
 {
-    char *token;
+    char *token, *endptr;
     const char *delim = ":.-";
 
     if ( !(*str) ||
@@ -789,7 +790,20 @@ static int next_bdf(char **str, int *seg
     *dev  = token_value(token);
 
     token  = strsep(str, delim);
-    *opt = strchr(token, ',');
+
+    *opt = strchr(token, '@');
+    if (*opt)
+    {
+        *(*opt)++ = '\0';
+        *vslot = token_value(*opt);
+    }
+    else
+    {
+        *vslot = AUTO_PHP_SLOT;
+        *opt = token;
+    }
+
+    *opt = strchr(*opt, ',');
     if (*opt)
         *(*opt)++ = '\0';
 
@@ -862,14 +876,9 @@ found:
 int insert_to_pci_slot(char *bdf_slt)
 {
     int seg, bus, dev, func, slot;
-    char *bdf_str, *slt_str, *opt, *endptr;
-    const char *delim="@";
-
-    bdf_str = strsep(&bdf_slt, delim);
-    slt_str = bdf_slt;
-    slot = token_value(slt_str);
+    char *opt;
 
-    if ( !next_bdf(&bdf_str, &seg, &bus, &dev, &func, &opt))
+    if ( !next_bdf(&bdf_slt, &seg, &bus, &dev, &func, &opt, &slot) )
     {
         return -1;
     }
@@ -897,10 +906,10 @@ int test_pci_slot(int slot)
 /* find the pci slot for pass-through dev with specified BDF */
 int bdf_to_slot(char *bdf_str)
 {
-    int seg, bus, dev, func, i;
+    int seg, bus, dev, func, slot, i;
     char *opt;
 
-    if ( !next_bdf(&bdf_str, &seg, &bus, &dev, &func, &opt))
+    if ( !next_bdf(&bdf_str, &seg, &bus, &dev, &func, &opt, &slot))
     {
         return -1;
     }
@@ -3619,7 +3628,7 @@ struct pt_dev * register_real_device(PCI
         return NULL;
     }
 
-    dpci_infos.php_devs[PCI_SLOT(e_devfn, 0)].pt_dev = assigned_device;
+    dpci_infos.php_devs[PCI_SLOT(e_devfn)].pt_dev = assigned_device;
 
     assigned_device->pci_dev = pci_dev;
     assigned_device->msi_trans_cap = msi_translate;
@@ -3801,7 +3810,7 @@ int power_off_php_slot(int slot)
 
 int pt_init(PCIBus *e_bus, const char *direct_pci)
 {
-    int seg, b, d, f, status = -1;
+    int seg, b, d, f, s, status = -1;
     struct pt_dev *pt_dev;
     struct pci_access *pci_access;
     char *vslots;
@@ -3837,7 +3846,7 @@ int pt_init(PCIBus *e_bus, const char *d
     vslots = qemu_mallocz ( strlen(direct_pci) / 3 );
 
     /* Assign given devices to guest */
-    while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt) )
+    while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt, &s) )
     {
         /* Register real device with the emulated bus */
         pt_dev = register_real_device(e_bus, "DIRECT PCI", PT_VIRT_DEVFN_AUTO,

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel