* [Qemu-devel] [PATCH v3] qemu-ga: make get-fsinfo work over pci bridges
@ 2018-05-14 12:38 Marc-André Lureau
2018-06-11 13:28 ` Marc-André Lureau
0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2018-05-14 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mdroth, Marc-André Lureau
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>
---
v3:
- replace \"%s\" in the debug message with '%s'
- simplify the code by getting rid of an "else if"
qga/commands-posix.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 0dc219dbcf..624b0dc0c3 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -875,13 +875,28 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
p = strstr(syspath, "/devices/pci");
if (!p || sscanf(p + 12, "%*x:%*x/%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);
+ g_debug("only pci device is supported: sysfs path '%s'", 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 && (g_str_equal(driver, "ata_piix") ||
+ g_str_equal(driver, "sym53c8xx") ||
+ g_str_equal(driver, "virtio-pci") ||
+ g_str_equal(driver, "ahci"))) {
+ break;
+ }
+
+ if (sscanf(p, "/%x:%x:%x.%x%n",
+ pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
+ p += pcilen;
+ continue;
+ }
+
+ g_debug("unsupported driver or sysfs path '%s'", syspath);
+ return;
}
p = strstr(syspath, "/target");
--
2.17.0.253.g3dd125b46d
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qemu-ga: make get-fsinfo work over pci bridges
2018-05-14 12:38 [Qemu-devel] [PATCH v3] qemu-ga: make get-fsinfo work over pci bridges Marc-André Lureau
@ 2018-06-11 13:28 ` Marc-André Lureau
2018-07-02 16:45 ` Marc-André Lureau
0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2018-06-11 13:28 UTC (permalink / raw)
To: QEMU; +Cc: Marc-André Lureau, Michael Roth
Hi Michael
On Mon, May 14, 2018 at 2:38 PM, Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
> 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>
> ---
ping,
are you planning to send a pull request for qga patches
>
> v3:
> - replace \"%s\" in the debug message with '%s'
> - simplify the code by getting rid of an "else if"
>
> qga/commands-posix.c | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 0dc219dbcf..624b0dc0c3 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -875,13 +875,28 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
> p = strstr(syspath, "/devices/pci");
> if (!p || sscanf(p + 12, "%*x:%*x/%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);
> + g_debug("only pci device is supported: sysfs path '%s'", 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 && (g_str_equal(driver, "ata_piix") ||
> + g_str_equal(driver, "sym53c8xx") ||
> + g_str_equal(driver, "virtio-pci") ||
> + g_str_equal(driver, "ahci"))) {
> + break;
> + }
> +
> + if (sscanf(p, "/%x:%x:%x.%x%n",
> + pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
> + p += pcilen;
> + continue;
> + }
> +
> + g_debug("unsupported driver or sysfs path '%s'", syspath);
> + return;
> }
>
> p = strstr(syspath, "/target");
> --
> 2.17.0.253.g3dd125b46d
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qemu-ga: make get-fsinfo work over pci bridges
2018-06-11 13:28 ` Marc-André Lureau
@ 2018-07-02 16:45 ` Marc-André Lureau
0 siblings, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2018-07-02 16:45 UTC (permalink / raw)
To: QEMU, Michael Roth; +Cc: Marc-André Lureau
Hi Michael
On Mon, Jun 11, 2018 at 3:28 PM, Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
> Hi Michael
>
> On Mon, May 14, 2018 at 2:38 PM, Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
>> 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>
>> ---
>
> ping,
>
> are you planning to send a pull request for qga patches
ping
>
>>
>> v3:
>> - replace \"%s\" in the debug message with '%s'
>> - simplify the code by getting rid of an "else if"
>>
>> qga/commands-posix.c | 23 +++++++++++++++++++----
>> 1 file changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>> index 0dc219dbcf..624b0dc0c3 100644
>> --- a/qga/commands-posix.c
>> +++ b/qga/commands-posix.c
>> @@ -875,13 +875,28 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
>> p = strstr(syspath, "/devices/pci");
>> if (!p || sscanf(p + 12, "%*x:%*x/%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);
>> + g_debug("only pci device is supported: sysfs path '%s'", 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 && (g_str_equal(driver, "ata_piix") ||
>> + g_str_equal(driver, "sym53c8xx") ||
>> + g_str_equal(driver, "virtio-pci") ||
>> + g_str_equal(driver, "ahci"))) {
>> + break;
>> + }
>> +
>> + if (sscanf(p, "/%x:%x:%x.%x%n",
>> + pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) {
>> + p += pcilen;
>> + continue;
>> + }
>> +
>> + g_debug("unsupported driver or sysfs path '%s'", syspath);
>> + return;
>> }
>>
>> p = strstr(syspath, "/target");
>> --
>> 2.17.0.253.g3dd125b46d
>>
>>
>
>
>
> --
> Marc-André Lureau
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-02 16:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 12:38 [Qemu-devel] [PATCH v3] qemu-ga: make get-fsinfo work over pci bridges Marc-André Lureau
2018-06-11 13:28 ` Marc-André Lureau
2018-07-02 16:45 ` Marc-André Lureau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.