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