[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] python/xc: reinstate original implementation of next_bdf



commit ec55a3ae01a5be34d9a753781fba41d5930569f0
Author:     Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Mon Jul 27 18:45:08 2015 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Jul 28 11:53:29 2015 +0100

    python/xc: reinstate original implementation of next_bdf
    
    I missed the fact that next_bdf is used to parsed user supplied
    strings when reviewing. The user supplied string is a NULL-terminated
    string separated by comma. User can supply several PCI devices in that
    string. There is, however, no delimiter for different devices, hence
    we can't change the syntax of that string.
    
    This patch reinstate the original implementation of next_bdf to
    preserve the original syntax. The last argument for xc_assign_device
    is always 0.
    
    Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/python/xen/lowlevel/xc/xc.c |   30 ++++++++++--------------------
 1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
index c8380d1..2c36eb2 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -592,8 +592,7 @@ 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,
-                    int *flag)
+static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
 {
     char *token;
 
@@ -608,17 +607,8 @@ static int next_bdf(char **str, int *seg, int *bus, int 
*dev, int *func,
     *dev  = token_value(token);
     token = strchr(token, ',') + 1;
     *func  = token_value(token);
-    token = strchr(token, ',') + 1;
-    if ( token ) {
-        *flag = token_value(token);
-        *str = token + 1;
-    }
-    else
-    {
-        /* O means we take "strict" as our default policy. */
-        *flag = 0;
-        *str = NULL;
-    }
+    token = strchr(token, ',');
+    *str = token ? token + 1 : NULL;
 
     return 1;
 }
@@ -630,14 +620,14 @@ static PyObject *pyxc_test_assign_device(XcObject *self,
     uint32_t dom;
     char *pci_str;
     int32_t sbdf = 0;
-    int seg, bus, dev, func, flag;
+    int seg, bus, dev, func;
 
     static char *kwd_list[] = { "domid", "pci", NULL };
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
                                       &dom, &pci_str) )
         return NULL;
 
-    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
+    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
     {
         sbdf = seg << 16;
         sbdf |= (bus & 0xff) << 8;
@@ -663,21 +653,21 @@ static PyObject *pyxc_assign_device(XcObject *self,
     uint32_t dom;
     char *pci_str;
     int32_t sbdf = 0;
-    int seg, bus, dev, func, flag;
+    int seg, bus, dev, func;
 
     static char *kwd_list[] = { "domid", "pci", NULL };
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
                                       &dom, &pci_str) )
         return NULL;
 
-    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
+    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
     {
         sbdf = seg << 16;
         sbdf |= (bus & 0xff) << 8;
         sbdf |= (dev & 0x1f) << 3;
         sbdf |= (func & 0x7);
 
-        if ( xc_assign_device(self->xc_handle, dom, sbdf, flag) != 0 )
+        if ( xc_assign_device(self->xc_handle, dom, sbdf, 0) != 0 )
         {
             if (errno == ENOSYS)
                 sbdf = -1;
@@ -696,14 +686,14 @@ static PyObject *pyxc_deassign_device(XcObject *self,
     uint32_t dom;
     char *pci_str;
     int32_t sbdf = 0;
-    int seg, bus, dev, func, flag;
+    int seg, bus, dev, func;
 
     static char *kwd_list[] = { "domid", "pci", NULL };
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
                                       &dom, &pci_str) )
         return NULL;
 
-    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func, &flag) )
+    while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
     {
         sbdf = seg << 16;
         sbdf |= (bus & 0xff) << 8;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.