From: Alex Williamson <alex.williamson@redhat.com>
To: Ethan Zhao <ethan.zhao@oracle.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
ethan kernel <ethan.kernel@gmail.com>
Subject: Re: [PATCH] PCI: export pci device assignment info as read only via sysfs
Date: Tue, 30 Dec 2014 08:51:14 -0500 (EST) [thread overview]
Message-ID: <1897331044.2487289.1419947474236.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1419927707-14462-1-git-send-email-ethan.zhao@oracle.com>
----- Original Message -----
> This patch exports assignment flag of PCI device via sysfs, so user
> space application could know if PCI device was assigned to guest OS
> or not via interface as following from viewpoint of host device
> management:
>
> PCI device was assigned to guest OS
> $cat /sys/devices/pci0000:00/0000:00:1f.3/assigned
> 1
>
> PCI device isn't assigned to guest OS
> $cat /sys/devices/pci0000:00/0000:00:1f.3/assigned
> 0
>
> Compiled and tested with v3.18.1
>
> Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
> ---
> drivers/pci/pci-sysfs.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 2c6643f..0ac3780 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -547,6 +547,15 @@ static ssize_t driver_override_show(struct device *dev,
> }
> static DEVICE_ATTR_RW(driver_override);
>
> +static ssize_t assigned_show(struct device *dev, struct device_attribute
> *attr,
> + char *buf)
> +{
> + struct pci_dev *pdev = to_pci_dev(dev);
> +
> + return sprintf(buf, "%d\n", pci_is_dev_assigned(pdev) ? 1 : 0);
> +}
> +static DEVICE_ATTR_RO(assigned);
> +
> static struct attribute *pci_dev_attrs[] = {
> &dev_attr_resource.attr,
> &dev_attr_vendor.attr,
> @@ -573,6 +582,7 @@ static struct attribute *pci_dev_attrs[] = {
> &dev_attr_devspec.attr,
> #endif
> &dev_attr_driver_override.attr,
> + &dev_attr_assigned.attr,
> NULL,
> };
>
NAK. The assigned attribute of a device is already in contention, it's racy and not universally used. If we can't even make it a consistent and reliable internal interface, we certainly shouldn't be exposing it to userspace. Thanks,
Alex
prev parent reply other threads:[~2014-12-30 13:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-30 8:21 [PATCH] PCI: export pci device assignment info as read only via sysfs Ethan Zhao
2014-12-30 9:20 ` Andreas Mohr
2014-12-30 13:51 ` Alex Williamson [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=1897331044.2487289.1419947474236.JavaMail.zimbra@redhat.com \
--to=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=ethan.kernel@gmail.com \
--cc=ethan.zhao@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.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).