From: Laszlo Ersek <lersek@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] qemu-ga: make get-fsinfo work over pci bridges
Date: Sat, 21 Apr 2018 01:40:34 +0200 [thread overview]
Message-ID: <e130d54a-0ea3-f149-e101-0f1ffd1cb60f@redhat.com> (raw)
In-Reply-To: <20180420152511.18878-1-marcandre.lureau@redhat.com>
Hi Marc-André,
On 04/20/18 17:25, Marc-André Lureau wrote:
> 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");
>
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
prev parent reply other threads:[~2018-04-20 23:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e130d54a-0ea3-f149-e101-0f1ffd1cb60f@redhat.com \
--to=lersek@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).