Reproducible crash on PCIe hotplug
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)
It crashes at:
#7 0x000055555598d7dc in do_pci_register_device (errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983
983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
(gdb) l
978 PCI_SLOT(devfn), PCI_FUNC(devfn), name,
979 bus->devices[devfn]->name);
980 return NULL;
981 } else if (dev->hotplugged &&
982 pci_get_function_0(pci_dev)) {
983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
984 " new func %s cannot be exposed to guest.",
985 PCI_SLOT(devfn),
986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name,
987 name);Signature · 1 line
Eduardo
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)
Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983
983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
(gdb) l
978 PCI_SLOT(devfn), PCI_FUNC(devfn), name,
979 bus->devices[devfn]->name);
980 return NULL;
981 } else if (dev->hotplugged &&
982 pci_get_function_0(pci_dev)) {
983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
984 " new func %s cannot be exposed to guest.",
985 PCI_SLOT(devfn),
986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name,
987 name);Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Signature · 2 lines
Sincerely, Cao jin
Markus Armbruster
Reviewed-by Michael S. TsirkinQuoted 7 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)
Bisected to
commit 3f1e1478db2d67098d98f2c3acf5a4946b7fb643
Author: Cao jin <[email protected]> Date: Wed Oct 28 14:20:31 2015 +0800
enable multi-function hot-add
Enable PCIe device multi-function hot-add, just ensure function 0 is added last, then driver will get the notification to scan the slot.
It's in v2.5.0, probably no need to hold the release for a fix.
Quoted 29 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);
Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 25 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);
Quoted 6 lines
Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
The bug went undetected since QEMU 2.5, and the crash happens only on cases where hotplug was already going to return an error. I don't think it should be a release blocker.
Signature · 1 line
Eduardo
Quoted 34 lines · Eduardo Habkost
Quoted 33 lines · Stefan Hajnoczi
Quoted 31 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Quoted 7 lines
Quoted 3 lines
Please let me know if this should be considered a release blocker.
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
The bug went undetected since QEMU 2.5, and the crash happens only on cases where hotplug was already going to return an error. I don't think it should be a release blocker.
Excellent, thanks for clarifying.
Stefan
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 25 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);
Quoted 8 lines
Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
I don't see how it's a blocker, it's an illegal configuration. Here's the fix. It's a rather obvious one.
I'll target the fix for 2.9.
Eduardo, I'd appreciate a tested-by tag.
-->
pci: fix error message for express slots
PCI Express downstream slot has a single PCI slot
behind it, using PCI_DEVFN(PCI_SLOT(devfn), 0)
does not give you function 0 in cases such as ARI
as well as some error cases.
This is exactly what we are hitting:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)
The fix is to use the pci_get_function_0 API.
---
hw/pci/pci.c +1 -1
@@ -983,7 +983,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." ,PCI_SLOT (devfn), - bus->devices[PCI_DEVFN (PCI_SLOT (devfn),0 )]->name, +pci_get_function_0 (pci_dev)->name, name);return NULL ;
Signature · 1 line
MST
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
Quoted 8 lines
Quoted 3 lines
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
I don't see how it's a blocker, it's an illegal configuration. Here's the fix. It's a rather obvious one.
I'll target the fix for 2.9.
Eduardo, I'd appreciate a tested-by tag.
I confirm the patch fixes the crash, but the error message seems
incorrect: the existing e1000e device is on slot 0 function 0, not slot 8.
$ ./x86-kvm-build/x86_64-softmmu/qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio
QEMU 2.7.93 monitor - type 'help' for more information
(qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00
(qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08
PCI: slot 8 function 0 already ocuppied by e1000e, new func e1000e cannot be exposed to guest.
^^^Quoted 39 lines
-->
pci: fix error message for express slots
PCI Express downstream slot has a single PCI slot
behind it, usingPCI_DEVFN(PCI_SLOT(devfn), 0)
does not give you function 0 in cases such as ARI
as well as some error cases.This is exactly what we are hitting:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)The fix is to use the
pci_get_function_0API.Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by Eduardo Habkost <[email protected]>---
hw/pci/pci.c +1
-1@@ -983,7 +983,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." ,PCI_SLOT (devfn), - bus->devices[PCI_DEVFN (PCI_SLOT (devfn),0 )]->name, +pci_get_function_0 (pci_dev)->name, name);return NULL ;Signature · 2 lines
-- MST
Signature · 1 line
Eduardo
Quoted 93 lines · Eduardo Habkost
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
Quoted 8 lines
Quoted 3 lines
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
I don't see how it's a blocker, it's an illegal configuration. Here's the fix. It's a rather obvious one.
I'll target the fix for 2.9.
Eduardo, I'd appreciate a tested-by tag.I confirm the patch fixes the crash, but the error message seems
incorrect: the existing e1000e device is on slot 0 function 0, not slot 8.$ ./x86-kvm-build/x86_64-softmmu/qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 PCI: slot 8 function 0 already ocuppied by e1000e, new func e1000e cannot be exposed to guest. ^^^Quoted 35 lines
-->
pci: fix error message for express slots
PCI Express downstream slot has a single PCI slot
behind it, usingPCI_DEVFN(PCI_SLOT(devfn), 0)
does not give you function 0 in cases such as ARI
as well as some error cases.This is exactly what we are hitting:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)The fix is to use the
pci_get_function_0API.Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by Eduardo Habkost <[email protected]>---
hw/pci/pci.c +1
-1@@ -983,7 +983,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." ,PCI_SLOT (devfn), - bus->devices[PCI_DEVFN (PCI_SLOT (devfn),0 )]->name, +pci_get_function_0 (pci_dev)->name, name);
Quoted 6 lines
Quoted 4 lines
hw/pci/pci.c +0
-0return NULL ;Signature · 2 lines
-- MST
this then?
hw/pci/pci.c +1 -1
@@ -982,7 +982,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_get_function_0(pci_dev)) {error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." , -PCI_SLOT (devfn), +PCI_SLOT (pci_get_function_0 (pci_dev)->devfn),pci_get_function_0 (pci_dev)->name, name);
Cao jin
Tested-byQuoted 111 lines · Michael S. Tsirkin
Quoted 93 lines · Eduardo Habkost
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
Quoted 8 lines
Quoted 3 lines
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
I don't see how it's a blocker, it's an illegal configuration. Here's the fix. It's a rather obvious one.
I'll target the fix for 2.9.
Eduardo, I'd appreciate a tested-by tag.I confirm the patch fixes the crash, but the error message seems
incorrect: the existing e1000e device is on slot 0 function 0, not slot 8.$ ./x86-kvm-build/x86_64-softmmu/qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 PCI: slot 8 function 0 already ocuppied by e1000e, new func e1000e cannot be exposed to guest. ^^^Quoted 35 lines
-->
pci: fix error message for express slots
PCI Express downstream slot has a single PCI slot
behind it, usingPCI_DEVFN(PCI_SLOT(devfn), 0)
does not give you function 0 in cases such as ARI
as well as some error cases.This is exactly what we are hitting:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)The fix is to use the
pci_get_function_0API.Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by Eduardo Habkost <[email protected]>---
hw/pci/pci.c +1
-1@@ -983,7 +983,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." ,PCI_SLOT (devfn), - bus->devices[PCI_DEVFN (PCI_SLOT (devfn),0 )]->name, +pci_get_function_0 (pci_dev)->name, name);Quoted 6 lines
Quoted 4 lines
hw/pci/pci.c +0
-0return NULL ;Signature · 2 lines
-- MSTthis then?
hw/pci/pci.c +0
-0
hw/pci/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 988
Quoted 8 lines
hw/pci/pci.c +1
-1@@ -982,7 +982,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_get_function_0(pci_dev)) {error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." , -PCI_SLOT (devfn), +PCI_SLOT (pci_get_function_0 (pci_dev)->devfn),pci_get_function_0 (pci_dev)->name, name);
./qemu-system-x86_64 -machine q35 -readconfig ../docs/q35-chipset.cfg -monitor stdio
QEMU 2.7.91 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08
PCI: slot 0 function 0 already ocuppied by e1000e, new func e1000e cannot be exposed to guest.
Signature · 2 lines
Sincerely, Cao jin
Quoted 111 lines · Michael S. Tsirkin
Quoted 93 lines · Eduardo Habkost
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Stefan Hajnoczi
Quoted 29 lines · Cao jin
Quoted 11 lines · Eduardo Habkost
Using latest qemu.git master:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)It crashes at:
#7
0x000055555598d7dcindo_pci_register_device(errp=0x7fffffffbfd0, devfn=64, name=0x5555565df340 "e1000e", bus=0x555558487380, pci_dev=0x5555589cd000)Quoted 14 lines
at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," (gdb) l 978 PCI_SLOT(devfn), PCI_FUNC(devfn), name, 979 bus->devices[devfn]->name); 980 return NULL; 981 } else if (dev->hotplugged && 982 pci_get_function_0(pci_dev)) { 983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," 984 " new func %s cannot be exposed to guest.", 985 PCI_SLOT(devfn), 986 bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, 987 name);Quoted 2 lines
Thanks for informing me. I am kind of busy for now, so I suppose I will investigate it after 2.8 release.
Please let me know if this should be considered a release blocker.
Quoted 8 lines
Quoted 3 lines
The proposed QEMU 2.8 release date is tomorrow (December 13th)!
Stefan
I don't see how it's a blocker, it's an illegal configuration. Here's the fix. It's a rather obvious one.
I'll target the fix for 2.9.
Eduardo, I'd appreciate a tested-by tag.I confirm the patch fixes the crash, but the error message seems
incorrect: the existing e1000e device is on slot 0 function 0, not slot 8.$ ./x86-kvm-build/x86_64-softmmu/qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio QEMU 2.7.93 monitor - type 'help' for more information (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 PCI: slot 8 function 0 already ocuppied by e1000e, new func e1000e cannot be exposed to guest. ^^^Quoted 35 lines
-->
pci: fix error message for express slots
PCI Express downstream slot has a single PCI slot
behind it, usingPCI_DEVFN(PCI_SLOT(devfn), 0)
does not give you function 0 in cases such as ARI
as well as some error cases.This is exactly what we are hitting:
$ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor stdio (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00 (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08 Segmentation fault (core dumped)The fix is to use the
pci_get_function_0API.Signed-off-by Michael S. Tsirkin <[email protected]>Reported-by Eduardo Habkost <[email protected]>---
hw/pci/pci.c +1
-1@@ -983,7 +983,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." ,PCI_SLOT (devfn), - bus->devices[PCI_DEVFN (PCI_SLOT (devfn),0 )]->name, +pci_get_function_0 (pci_dev)->name, name);Quoted 6 lines
Quoted 4 lines
hw/pci/pci.c +0
-0return NULL ;Signature · 2 lines
-- MSTthis then?
hw/pci/pci.c +0
-0
hw/pci/pci.c static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, · line 987
Quoted 7 lines
hw/pci/pci.c +1
-1@@ -982,7 +982,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_get_function_0(pci_dev)) {error_setg (errp,"PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest." , -PCI_SLOT (devfn), +PCI_SLOT (pci_get_function_0 (pci_dev)->devfn),pci_get_function_0 (pci_dev)->name, name);
Works for me. Thanks!
Signature · 1 line
Eduardo