qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-ga: make get-fsinfo work over pci bridges
@ 2018-04-20 15:25 Marc-André Lureau
  2018-04-20 23:40 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Marc-André Lureau @ 2018-04-20 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: lersek, mdroth, 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=1567041

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qga/commands-posix.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 0dc219dbcf..5d4e5f627f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -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");
-- 
2.17.0.253.g3dd125b46d

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-20 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-20 15:25 [Qemu-devel] [PATCH] qemu-ga: make get-fsinfo work over pci bridges Marc-André Lureau
2018-04-20 23:40 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).