Skip to content

Commit

Permalink
virtio-lib: break waiting for reset completion if the device not present
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1924998

If the physical device was removed it is possible that we'll
enter endless loop as the device status will never return 0.
Break the loop if the PCI config space is not readable at
offset 0 (vendor ID).

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
  • Loading branch information
ybendito authored and YanVugenfirer committed Feb 8, 2021
1 parent 60542cf commit 24a06e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions VirtIO/VirtIOPCIModern.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static void vio_modern_reset(VirtIODevice *vdev)
* including MSI-X interrupts, if any.
*/
while (ioread8(vdev, &vdev->common->device_status)) {
u16 val;
if (pci_read_config_word(vdev, 0, &val) || val == 0xffff) {
DPrintf(0, ("PCI config space is not readable, probably the device is removed\n"));
break;
}
vdev_sleep(vdev, 1);
}
}
Expand Down

0 comments on commit 24a06e5

Please sign in to comment.