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

[Xen-devel] [rfc 18/18] ioemu: Allow virtual function to be speficied fo

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc 18/18] ioemu: Allow virtual function to be speficied for PCI pass-through
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Tue, 17 Feb 2009 20:08:06 +1100
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Delivery-date: Tue, 17 Feb 2009 01:36:01 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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: <20090217090748.580007796@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 
Fri, 13 Feb 2009 13:45:22 +1100
* Fix parsing of vslot - the regex was incorrect
* Allow 0x to prefix hex values that are parsed

Index: ioemu-remote/hw/pass-through.c
===================================================================
--- ioemu-remote.orig/hw/pass-through.c 2009-02-17 17:52:08.000000000 +0900
+++ ioemu-remote/hw/pass-through.c      2009-02-17 17:52:13.000000000 +0900
@@ -866,14 +866,15 @@ err:
 #define RE_BDF_OPT RE_BDF RE_OPT "\\?"
 
 #define RE_VDEV  "\\(0x\\)\\?\\([01]\\?[0-9a-fA-F]\\)"
-#define RE_BDF_OPT_SLOT RE_BDF_OPT "\\(@" RE_VDEV "\\)\\?"
+#define RE_VDEVFN RE_VDEV "\\(\\." RE_FUNC "\\)\\?"
+#define RE_BDF_OPT_SLOT RE_BDF_OPT "\\(@" RE_VDEVFN "\\)\\?"
 
 static struct php_dev *parse_bdf(const char *str)
 {
     struct php_dev *list = NULL, *e;
     regex_t preg;
-    regmatch_t pmatch[14];
-    int err, nmemb = 0;
+    regmatch_t pmatch[17];
+    int err, nmemb = 0, v_func = 0;
     char *err_str;
 
     if ((err = regcomp(&preg, RE_BDF_OPT_SLOT, 0)))
@@ -891,7 +892,7 @@ static struct php_dev *parse_bdf(const c
 
     while (1)
     {
-        if ((err = regexec(&preg, str, 14, pmatch, 0)))
+        if ((err = regexec(&preg, str, 17, pmatch, 0)))
         {
             PT_LOG("Error: invalid PCI assignment \"%s\"\n", str);
             goto err;
@@ -917,7 +918,12 @@ static struct php_dev *parse_bdf(const c
 
         if (pmatch[12].rm_so >= 0)
         {
-            e->v_devfn = PCI_DEVFN(strtol(str + pmatch[12].rm_so, NULL, 16), 
0);
+            if (pmatch[15].rm_so >= 0)
+            {
+                v_func = strtol(str + pmatch[15].rm_so, NULL, 16);
+            }
+            e->v_devfn = PCI_DEVFN(strtol(str + pmatch[12].rm_so, NULL, 16),
+                                   v_func);
         }
 
         e->valid = 1;
Index: ioemu-remote/xenstore.c
===================================================================
--- ioemu-remote.orig/xenstore.c        2009-02-17 17:28:06.000000000 +0900
+++ ioemu-remote/xenstore.c     2009-02-17 17:52:13.000000000 +0900
@@ -582,6 +582,24 @@ void xenstore_parse_domain_config(int hv
 
             strcat(direct_pci_str, dev);
 
+            if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/vdevfn-%d",
+                          hvm_domid, pci_devid, i) != -1) {
+                free(dev);
+                dev = xs_read(xsh, XBT_NULL, buf, &len);
+            }
+            if ( dev ) {
+                if (strlen(dev) + strlen(direct_pci_str) >
+                    DIRECT_PCI_STR_LEN - 2) {
+                    fprintf(stderr, "qemu: too many pci pass-through "
+                            "devices\n");
+                    memset(direct_pci_str, 0, DIRECT_PCI_STR_LEN);
+                    goto out;
+                }
+                strcat(direct_pci_str, "@");
+                strcat(direct_pci_str, dev);
+            }
+
+
             if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/opts-%d",
                           hvm_domid, pci_devid, i) != -1) {
                 free(dev);

-- 

-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en


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

<Prev in Thread] Current Thread [Next in Thread>