qemu-ga: make get-fsinfo work over pci bridges
commit743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 14 May 2018 12:38:55 +0000 (14 14:38 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 3 Jul 2018 20:20:51 +0000 (3 15:20 -0500)
tree52e19379a2117ae61d049113702b0e4bd42c3ab4
parenta972304d187b104ebec327bc824b23a5a3589ac3
qemu-ga: make get-fsinfo work over pci bridges

Iterate over the PCI bridges to lookup the PCI device associated with
the block device.

This allows to lookup the driver under the following syspath:
/sys/devices/pci0000:00/0000:00:02.2/0000:03:00.0/virtio2/block/vda/vda3

It also works with an "old-style" Q35 libvirt hierarchy: root complex
-> DMI-PCI bridge -> PCI-PCI bridge -> virtio controller, ex:
/sys/devices/pci0000:00/0000:00:03.0/0000:01:01.0/0000:02:01.0/virtio1/block/vda/vda3

The setup can be reproduced with the following qemu command line
(Thanks Marcel for help):

qemu-system-x86_64 -M q35 \
  -device i82801b11-bridge,id=dmi2pci_bridge,bus=pcie.0
  -device pci-bridge,id=pci_bridge,bus=dmi2pci_bridge,addr=0x1,chassis_nr=1
  -device virtio-blk-pci,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,bus=pci_bridge,addr=0x1

For consistency with other syspath-related debug messages, replace a
\"%s\" in the message with '%s'.

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1567041

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-posix.c