qemu-ga: make get-fsinfo work over pci bridges
PATCH 1/1 qemu-ga: make get-fsinfo work over pci bridges
Iterate over the PCI bridges to lookup the PCI device associated with the block device.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1567041
--- qga/commands-posix.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
qga/commands-posix.c +18 -3
@@ -879,9 +879,24 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,return ; } - driver =get_pci_driver (syspath, (p +12 + pcilen) - syspath, errp); -if (!driver) { - goto cleanup; + p +=12 + pcilen; +while (true) { + driver =get_pci_driver (syspath, p - syspath, errp); +if (!driver) { + goto cleanup; + } + +if (g_str_equal (driver,"pcieport" )) { +if (sscanf (p,"/%x:%x:%x.%x%n" , + pci, pci +1 , pci +2 , pci +3 , &pcilen) <4 ) { +g_debug ("only pci device is supported: sysfs path \"%s\"" , + syspath); +return ; + } + p += pcilen; +continue ; + } +break ; } p =strstr (syspath,"/target" );
Signature · 1 line
2.17.0.253.g3dd125b46d
Hi Marc-André,
Quoted 34 lines · Marc-André Lureau
Iterate over the PCI bridges to lookup the PCI device associated with the block device.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1567041Signed-off-by Marc-André Lureau <[email protected]>--- qga/commands-posix.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)qga/commands-posix.c +11
-3@@ -879,9 +879,24 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,return ; } - driver =get_pci_driver (syspath, (p +12 + pcilen) - syspath, errp); -if (!driver) { - goto cleanup; + p +=12 + pcilen; +while (true) { + driver =get_pci_driver (syspath, p - syspath, errp); +if (!driver) { + goto cleanup; + } + +if (g_str_equal (driver,"pcieport" )) { +if (sscanf (p,"/%x:%x:%x.%x%n" , + pci, pci +1 , pci +2 , pci +3 , &pcilen) <4 ) { + g_debug("only pci device is supported: sysfs path \"%s\"",
qga/commands-posix.c static void build_guest_fsinfo_for_real_device(char const *syspath, · line 902
Quoted 10 lines
qga/commands-posix.c +7
-0+ syspath); +return ; + } + p += pcilen; +continue ; + } +break ; } p =strstr (syspath,"/target" );
this patch looked like suitable chewing gum for my brain before I turn off my work laptop (Saturday 01:36AM, me at work, what else is new), so here goes:
- Please consider adding a few example pathnames to the commit message or even the code (as comments). Up to you.
- More importantly, I think this will only work if you use PCIe root ports and maybe PCIe switches. The original environment where at least I reproduced it was the "old-style" Q35 libvirt hierarchy: root complex -> DMI-PCI bridge -> PCI-PCI bridge -> virtio-scsi controller. And, in that case, the DMI-PCI bridge had no associated driver with it at all in the guest -- meaning that get_pci_driver() in your patch would return NULL just the same.
So, I think you should continue scanning as long as:
- driver is either missing or not on the list of desired drivers, AND
- the next pathname component looks PCI-like, and can be parsed.
If the first sub-condition fails, then you found a driver that we can report about. If the second sub-condition fails, then we give up.
My understanding anyway.
Thanks
Laszlo