All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xl, fix for short BDF (without domain specified)
@ 2010-07-07  8:27 Sergey Tovpeko
  2010-07-07 11:07 ` Stefano Stabellini
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Tovpeko @ 2010-07-07  8:27 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Hi,

this patch fixes cases where an user sets pci device not mentioning its 
domain, ex.
pci = ['01:00.0']

At now, xl recognizes this string as
domain = 1,
bus = 0,
device = 0
func = 0


[-- Attachment #2: bdf_parse.diff --]
[-- Type: text/x-patch, Size: 836 bytes --]

commit a5ed8a3a59d5abeb9dabfdf2d31fa524cf304dee
Author: Sergey Tovpeko <tovpeko@altell.ru>
Date:   Tue Jul 6 23:31:50 2010 +0400

    Check that BDF have been parsed correctly.
    
    Before that fix, BDF could be parsed incorrectly if user omitted domain in it.

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 208ecd6..9be1cbb 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -827,7 +827,7 @@ skip_vfb:
             p = strtok(buf2, ",");
             if (!p)
                 goto skip_pci;
-            if (!sscanf(p, PCI_BDF_VDEVFN, &domain, &bus, &dev, &func, &vdevfn)) {
+            if (sscanf(p, PCI_BDF_VDEVFN, &domain, &bus, &dev, &func, &vdevfn) < 4) {
                 sscanf(p, "%02x:%02x.%01x@%02x", &bus, &dev, &func, &vdevfn);
                 domain = 0;
             }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xl, fix for short BDF (without domain specified)
  2010-07-07  8:27 [PATCH] xl, fix for short BDF (without domain specified) Sergey Tovpeko
@ 2010-07-07 11:07 ` Stefano Stabellini
  2010-07-07 12:43   ` Sergey Tovpeko
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2010-07-07 11:07 UTC (permalink / raw)
  To: Sergey Tovpeko; +Cc: xen-devel

On Wed, 7 Jul 2010, Sergey Tovpeko wrote:
> Hi,
> 
> this patch fixes cases where an user sets pci device not mentioning its 
> domain, ex.
> pci = ['01:00.0']
> 
> At now, xl recognizes this string as
> domain = 1,
> bus = 0,
> device = 0
> func = 0
> 
> 

the test on the return value should be "< 5", otherwise it wouldn't work
if you use

pci = ['01:00.0@0']

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xl, fix for short BDF (without domain specified)
  2010-07-07 11:07 ` Stefano Stabellini
@ 2010-07-07 12:43   ` Sergey Tovpeko
  2010-07-07 17:02     ` Stefano Stabellini
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Tovpeko @ 2010-07-07 12:43 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

Oh, too many input cases.

Below patch tries to recognize the following input:
pci = ['0001:02:03.4@5']
pci = ['0001:02:03.4']
pci = ['02:03.4@5']
pci = ['02:03.4']

Hope so.

Stefano Stabellini wrote:
>
> the test on the return value should be "< 5", otherwise it wouldn't work
> if you use
>
> pci = ['01:00.0@0']
>
>   


[-- Attachment #2: bdf_parse.diff --]
[-- Type: text/x-patch, Size: 1223 bytes --]

commit db423431f8b8b2a773df105e407372118cc12a27
Author: Sergey Tovpeko <tovpeko@altell.ru>
Date:   Tue Jul 6 23:31:50 2010 +0400

    Check that BDF have been parsed correctly.
    
    Before that fix, BDF could be parsed incorrectly if user omitted domain in it.

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 208ecd6..fe2408c 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -827,9 +827,12 @@ skip_vfb:
             p = strtok(buf2, ",");
             if (!p)
                 goto skip_pci;
-            if (!sscanf(p, PCI_BDF_VDEVFN, &domain, &bus, &dev, &func, &vdevfn)) {
-                sscanf(p, "%02x:%02x.%01x@%02x", &bus, &dev, &func, &vdevfn);
+            if (sscanf(p, PCI_BDF_VDEVFN, &domain, &bus, &dev, &func, &vdevfn) < 4) {
                 domain = 0;
+                if (sscanf(p, "%02x:%02x.%01x@%02x", &bus, &dev, &func, &vdevfn) < 3) {
+                    fprintf(stderr,"xl: Unable to parse pci bdf (%s)\n", p);
+                    goto skip_pci;
+                }
             }
             libxl_device_pci_init(*pcidevs + *num_pcidevs, domain, bus, dev, func, vdevfn);
             (*pcidevs)[*num_pcidevs].msitranslate = pci_msitranslate;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xl, fix for short BDF (without domain specified)
  2010-07-07 12:43   ` Sergey Tovpeko
@ 2010-07-07 17:02     ` Stefano Stabellini
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2010-07-07 17:02 UTC (permalink / raw)
  To: Sergey Tovpeko; +Cc: xen-devel, Stefano Stabellini

On Wed, 7 Jul 2010, Sergey Tovpeko wrote:
> Oh, too many input cases.
> 
> Below patch tries to recognize the following input:
> pci = ['0001:02:03.4@5']
> pci = ['0001:02:03.4']
> pci = ['02:03.4@5']
> pci = ['02:03.4']
> 
> Hope so.
> 

this one looks good, thanks.


Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-07 17:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07  8:27 [PATCH] xl, fix for short BDF (without domain specified) Sergey Tovpeko
2010-07-07 11:07 ` Stefano Stabellini
2010-07-07 12:43   ` Sergey Tovpeko
2010-07-07 17:02     ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.