|
|
26ba25 |
From 0e3b855ea8223c8150192820cde86def8142de29 Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
26ba25 |
Date: Tue, 5 Feb 2019 11:25:50 +0000
|
|
|
26ba25 |
Subject: [PATCH 1/2] qemu-ga: make get-fsinfo work over pci bridges
|
|
|
26ba25 |
MIME-Version: 1.0
|
|
|
26ba25 |
Content-Type: text/plain; charset=UTF-8
|
|
|
26ba25 |
Content-Transfer-Encoding: 8bit
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
26ba25 |
Message-id: <20190205112551.14763-2-marcandre.lureau@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 84241
|
|
|
26ba25 |
O-Subject: [RHEL8/rhel qemu-kvm PATCH 1/2] qemu-ga: make get-fsinfo work over pci bridges
|
|
|
26ba25 |
Bugzilla: 1666952
|
|
|
26ba25 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
Iterate over the PCI bridges to lookup the PCI device associated with
|
|
|
26ba25 |
the block device.
|
|
|
26ba25 |
|
|
|
26ba25 |
This allows to lookup the driver under the following syspath:
|
|
|
26ba25 |
/sys/devices/pci0000:00/0000:00:02.2/0000:03:00.0/virtio2/block/vda/vda3
|
|
|
26ba25 |
|
|
|
26ba25 |
It also works with an "old-style" Q35 libvirt hierarchy: root complex
|
|
|
26ba25 |
-> DMI-PCI bridge -> PCI-PCI bridge -> virtio controller, ex:
|
|
|
26ba25 |
/sys/devices/pci0000:00/0000:00:03.0/0000:01:01.0/0000:02:01.0/virtio1/block/vda/vda3
|
|
|
26ba25 |
|
|
|
26ba25 |
The setup can be reproduced with the following qemu command line
|
|
|
26ba25 |
(Thanks Marcel for help):
|
|
|
26ba25 |
|
|
|
26ba25 |
qemu-system-x86_64 -M q35 \
|
|
|
26ba25 |
-device i82801b11-bridge,id=dmi2pci_bridge,bus=pcie.0
|
|
|
26ba25 |
-device pci-bridge,id=pci_bridge,bus=dmi2pci_bridge,addr=0x1,chassis_nr=1
|
|
|
26ba25 |
-device virtio-blk-pci,scsi=off,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,bus=pci_bridge,addr=0x1
|
|
|
26ba25 |
|
|
|
26ba25 |
For consistency with other syspath-related debug messages, replace a
|
|
|
26ba25 |
\"%s\" in the message with '%s'.
|
|
|
26ba25 |
|
|
|
26ba25 |
Fixes:
|
|
|
26ba25 |
https://bugzilla.redhat.com/show_bug.cgi?id=1567041
|
|
|
26ba25 |
|
|
|
26ba25 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
(cherry picked from commit 743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6)
|
|
|
26ba25 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
qga/commands-posix.c | 23 +++++++++++++++++++----
|
|
|
26ba25 |
1 file changed, 19 insertions(+), 4 deletions(-)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
|
|
|
26ba25 |
index 82cb120..71cb644 100644
|
|
|
26ba25 |
--- a/qga/commands-posix.c
|
|
|
26ba25 |
+++ b/qga/commands-posix.c
|
|
|
26ba25 |
@@ -883,13 +883,28 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
|
|
26ba25 |
p = strstr(syspath, "/devices/pci");
|
|
|
26ba25 |
if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n",
|
|
|
26ba25 |
pci, pci + 1, pci + 2, pci + 3, &pcilen) < 4) {
|
|
|
26ba25 |
- g_debug("only pci device is supported: sysfs path \"%s\"", syspath);
|
|
|
26ba25 |
+ g_debug("only pci device is supported: sysfs path '%s'", syspath);
|
|
|
26ba25 |
return;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
- driver = get_pci_driver(syspath, (p + 12 + pcilen) - syspath, errp);
|
|
|
26ba25 |
- if (!driver) {
|
|
|
26ba25 |
- goto cleanup;
|
|
|
26ba25 |
+ p += 12 + pcilen;
|
|
|
26ba25 |
+ while (true) {
|
|
|
26ba25 |
+ driver = get_pci_driver(syspath, p - syspath, errp);
|
|
|
26ba25 |
+ if (driver && (g_str_equal(driver, "ata_piix") ||
|
|
|
26ba25 |
+ g_str_equal(driver, "sym53c8xx") ||
|
|
|
26ba25 |
+ g_str_equal(driver, "virtio-pci") ||
|
|
|
26ba25 |
+ g_str_equal(driver, "ahci"))) {
|
|
|
26ba25 |
+ break;
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ if (sscanf(p, "/%x:%x:%x.%x%n",
|
|
|
26ba25 |
+ pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
|
|
|
26ba25 |
+ p += pcilen;
|
|
|
26ba25 |
+ continue;
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ g_debug("unsupported driver or sysfs path '%s'", syspath);
|
|
|
26ba25 |
+ return;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
p = strstr(syspath, "/target");
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|