From: "Michael S. Tsirkin" <mst@redhat.com>
To: Amerigo Wang <amwang@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Stephen Hemminger <shemminger@vyatta.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Anthony Liguori <aliguori@us.ibm.com>,
Jamie Lokier <jamie@shareable.org>, Thomas Weber <swirl@gmx.li>,
Ben Hutchings <ben@decadent.org.uk>,
David Woodhouse <David.Woodhouse@intel.com>,
Andy Fleming <afleming@freescale.com>,
"David S. Miller" <davem@davemloft.net>,
axboe@kernel.dk, hch@lst.de
Subject: Re: [RFC Patch] virtio: export model and type in /sys
Date: Mon, 31 Jan 2011 11:52:30 +0200 [thread overview]
Message-ID: <20110131095230.GA31089@redhat.com> (raw)
In-Reply-To: <1296442381-21652-1-git-send-email-amwang@redhat.com>
On Mon, Jan 31, 2011 at 10:53:00AM +0800, Amerigo Wang wrote:
> Our kdump script needs /sys/block/X/device/{vendor, model, type},
BTW, it's sys/class/block now? One is new, one is legacy and
deprecated, I am not sure which is which ...
> but virtio devices don't have {model, type}, this patch adds them.
> Actually, I don't know how to fill the model field, other block devices
> seem read it from SCSI. Any comments?
>
> Signed-off-by: WANG Cong <amwang@redhat.com>
For model, I am guessing "virtio-blk" would be a good value. But I
think this attribute is specific to block so should be added only for
virito-blk.
As far as I can tell, type is from scsi/scsi.h,
so we can just stick TYPE_DISK (0) there.
BTW, I note that other devices in drivers/block might not
have these either. Does your script work for xen-blkfront?
If we want this to work for all block devices maybe these
attributes should go into block core? model could
default to the driver name, type could default to 0...
> ---
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index efb35aa..5ce70b7 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -17,6 +17,18 @@ static ssize_t vendor_show(struct device *_d,
> struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
> return sprintf(buf, "0x%04x\n", dev->id.vendor);
> }
> +static ssize_t model_show(struct device *_d,
> + struct device_attribute *attr, char *buf)
> +{
> + struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
> + return sprintf(buf, "0x%04x\n", dev->id.model);
> +}
> +static ssize_t type_show(struct device *_d,
> + struct device_attribute *attr, char *buf)
> +{
> + struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
> + return sprintf(buf, "0x%04x\n", dev->id.type);
> +}
> static ssize_t status_show(struct device *_d,
> struct device_attribute *attr, char *buf)
> {
> @@ -49,6 +61,8 @@ static ssize_t features_show(struct device *_d,
> static struct device_attribute virtio_dev_attrs[] = {
> __ATTR_RO(device),
> __ATTR_RO(vendor),
> + __ATTR_RO(model),
> + __ATTR_RO(type),
> __ATTR_RO(status),
> __ATTR_RO(modalias),
> __ATTR_RO(features),
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index 4fb5b2b..3bde99d 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -656,6 +656,7 @@ static int __devinit virtio_pci_probe(struct pci_dev *pci_dev,
> * the subsystem ids */
> vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor;
> vp_dev->vdev.id.device = pci_dev->subsystem_device;
> + vp_dev->vdev.id.type = pci_dev->pcie_type;
>
> /* finally register the virtio device */
> err = register_virtio_device(&vp_dev->vdev);
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 48c007d..b72cd50 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -385,6 +385,8 @@ struct ssb_device_id {
> struct virtio_device_id {
> __u32 device;
> __u32 vendor;
> + __u32 model;
> + __u32 type;
> };
> #define VIRTIO_DEV_ANY_ID 0xffffffff
>
next prev parent reply other threads:[~2011-01-31 9:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 2:53 [RFC Patch] virtio: export model and type in /sys Amerigo Wang
2011-01-31 4:05 ` Rusty Russell
2011-01-31 5:45 ` Cong Wang
2011-01-31 14:02 ` Anthony Liguori
2011-02-01 17:41 ` Christoph Hellwig
2011-01-31 9:52 ` Michael S. Tsirkin [this message]
2011-02-01 17:37 ` Christoph Hellwig
2011-02-01 17:46 ` Michael S. Tsirkin
2011-02-01 17:56 ` Christoph Hellwig
2011-02-04 6:29 ` Cong Wang
2011-02-12 7:17 ` Christoph Hellwig
2011-02-12 9:56 ` Cong Wang
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=20110131095230.GA31089@redhat.com \
--to=mst@redhat.com \
--cc=David.Woodhouse@intel.com \
--cc=afleming@freescale.com \
--cc=aliguori@us.ibm.com \
--cc=amwang@redhat.com \
--cc=axboe@kernel.dk \
--cc=ben@decadent.org.uk \
--cc=davem@davemloft.net \
--cc=hch@lst.de \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=shemminger@vyatta.com \
--cc=swirl@gmx.li \
/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