Skip to contentSkip to conversation

Clarify error message when a PCI slot is already in use

PATCH In review Daniel P. Berrange 2 participants 3 messages Jun 8, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clarify error message when a PCI slot is already in use

When mistakenly configuring two devices in the same PCI slot, QEMU gives a not entirely obvious message about a 'devfn' being in use:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139

The user does not configure 'devfn' numbers, they use slot+function. Thus the error messages should be reported back to the user with that same terminology rather than the internal QEMU terminology. This patch makes it report:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/pci.c +3 -3
index cbbd1dd..2347708 100644
@@ -609,12 +609,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
             if (!bus->devices[devfn])
                 goto found;
         }
-        error_report("PCI: no devfn available for %s, all in use", name);
+        error_report("PCI: no slot/function available for %s, all in use", name);
         return NULL;
     found: ;
     } else if (bus->devices[devfn]) {
-        error_report("PCI: devfn %d not available for %s, in use by %s",
-                     devfn, name, bus->devices[devfn]->name);
+        error_report("PCI: slot %d function %d not available for %s, in use by %s",
+                     (devfn >> 3), (devfn % 8), name, bus->devices[devfn]->name);
         return NULL;
     }
     pci_dev->bus = bus;
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 27 lines · Daniel P. Berrange

When mistakenly configuring two devices in the same PCI slot, QEMU gives a not entirely obvious message about a 'devfn' being in use:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139

The user does not configure 'devfn' numbers, they use slot+function. Thus the error messages should be reported back to the user with that same terminology rather than the internal QEMU terminology. This patch makes it report:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/pci.c +0 -0
index cbbd1dd..2347708 100644
@@ -609,12 +609,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
             if (!bus->devices[devfn])
                 goto found;

hw/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 617

Quoted 10 lines
hw/pci.c +3 -3
         }
-        error_report("PCI: no devfn available for %s, all in use", name);
+        error_report("PCI: no slot/function available for %s, all in use", name);
         return NULL;
     found: ;
     } else if (bus->devices[devfn]) {
-        error_report("PCI: devfn %d not available for %s, in use by %s",
-                     devfn, name, bus->devices[devfn]->name);
+        error_report("PCI: slot %d function %d not available for %s, in use by %s",
+                     (devfn >> 3), (devfn % 8), name, bus->devices[devfn]->name);

Please use PCI_SLOT() and PCI_FUNC().

Quoted 7 lines
hw/pci.c +0 -0
         return NULL;
     }
     pci_dev->bus = bus;
Signature · 1 line
1.6.6.1
Signature · 1 line
yamahata
#2 lore raw
Quoted 32 lines · Isaku Yamahata
Quoted 31 lines · Daniel P. Berrange

When mistakenly configuring two devices in the same PCI slot, QEMU gives a not entirely obvious message about a 'devfn' being in use:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139

The user does not configure 'devfn' numbers, they use slot+function. Thus the error messages should be reported back to the user with that same terminology rather than the internal QEMU terminology. This patch makes it report:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/pci.c +1 -1
index cbbd1dd..2347708 100644
@@ -609,12 +609,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
             if (!bus->devices[devfn])
                 goto found;
         }
-        error_report("PCI: no devfn available for %s, all in use", name);
+        error_report("PCI: no slot/function available for %s, all in use", name);
         return NULL;
Quoted 8 lines

hw/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 617

Quoted 6 lines
hw/pci.c +2 -2
     found: ;
     } else if (bus->devices[devfn]) {
-        error_report("PCI: devfn %d not available for %s, in use by %s",
-                     devfn, name, bus->devices[devfn]->name);
+        error_report("PCI: slot %d function %d not available for %s, in use by %s",
+                     (devfn >> 3), (devfn % 8), name, bus->devices[devfn]->name);

Please use PCI_SLOT() and PCI_FUNC().

Thanks for the pointer. I've resent the patch with that change

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|