tools/libxl/xl: fix for short BDF (without domain specified)

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

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Contributed-by: Sergey Tovpeko <tsv.devel@gmail.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
This commit is contained in:
Ian Jackson committed 2010-07-08 17:22:18 +01:00
1 parent 28c4011332
commit 84b1ed809c
1 file changed
+5 -2
+5 -2
View File
@@ -833,9 +833,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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.