From: Anthony Liguori <anthony@codemonkey.ws>
To: john cooper <john.cooper@third-harmonic.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
john cooper <john.cooper@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>,
qemu-devel@nongnu.org, Avi Kivity <avi@redhat.com>,
jens.axboe@oracle.com, Vadim Rozenfeld <vrozenfe@redhat.com>
Subject: [Qemu-devel] Re: [PATCH] fix virtio_blk serial pci config breakage, v2
Date: Tue, 06 Oct 2009 09:23:51 -0500 [thread overview]
Message-ID: <4ACB52F7.80803@codemonkey.ws> (raw)
In-Reply-To: <4ACA1527.9050305@third-harmonic.com>
john cooper wrote:
> This is a re-work of the previous version where the
> associated data was being funneled through a free
> PCI BAR mapping. Here a request for the identify
> information results in a virtqueue command utilizing
> the scaffolding introduced by Rusty's recent patch.
>
> Signed-off-by: john cooper <john.cooper@redhat.com>
> ---
>
>
> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index dad4ef0..e754277 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -25,6 +25,7 @@ typedef struct VirtIOBlock
> BlockDriverState *bs;
> VirtQueue *vq;
> void *rq;
> + uint16_t identify[VIRTIO_BLK_ID_LEN];
> } VirtIOBlock;
>
> static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
> @@ -32,6 +33,48 @@ static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
> return (VirtIOBlock *)vdev;
> }
>
> +/* store identify data in little endian format
> + */
> +static inline void put_le16(uint16_t *p, unsigned int v)
> +{
> + *p = cpu_to_le16(v);
> +}
> +
> +/* copy to *dst from *src, nul pad dst tail as needed to len bytes
> + */
> +static inline void padstr(char *dst, const char *src, int len)
> +{
> + while (len--)
> + *dst++ = *src ? *src++ : '\0';
> +}
> +
> +/* setup simulated identify data as appropriate for virtio block device
> + *
> + * ref: AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
> + */
> +static inline void virtio_identify_template(VirtIOBlock *s)
> +{
> + uint16_t *p = s->identify;
> + uint64_t lba_sectors;
> +
> + memset(p, 0, sizeof(uint16_t) * VIRTIO_BLK_ID_LEN);
> + put_le16(p + 0, 0x0); /* ATA device */
> + padstr((char *)(p + 23), QEMU_VERSION, 8); /* firmware
> revision */
> + padstr((char *)(p + 27), "QEMU VIRT_BLK", 40); /* model# */
> + put_le16(p + 47, 0x80ff); /* max xfer 255
> sectors */
> + put_le16(p + 49, 0x0b00); /* support
> IORDY/LBA/DMA */
> + put_le16(p + 59, 0x1ff); /* cur xfer 255
> sectors */
> + put_le16(p + 80, 0x1f0); /* support
> ATA8/7/6/5/4 */
> + put_le16(p + 81, 0x16);
> + put_le16(p + 82, 0x400);
> + put_le16(p + 83, 0x400);
> + bdrv_get_geometry(s->bs, &lba_sectors);
> + put_le16(p + 100, lba_sectors);
> + put_le16(p + 101, lba_sectors >> 16);
> + put_le16(p + 102, lba_sectors >> 32);
> + put_le16(p + 103, lba_sectors >> 48);
> +}
> +
> typedef struct VirtIOBlockReq
> {
> VirtIOBlock *dev;
> @@ -243,6 +286,11 @@ static void virtio_blk_handle_output(VirtIODevice
> *vdev, VirtQueue *vq)
>
> if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) {
> virtio_blk_handle_scsi(req);
> + }
> + else if (req->out->type & VIRTIO_BLK_T_GET_ID) {
CodingStyle.
> + memcpy(req->elem.in_sg[0].iov_base, s->identify,
> + req->elem.in_sg[0].iov_len);
> + virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
Weird indentation.
Regards,
Anthony Liguori
next prev parent reply other threads:[~2009-10-06 14:24 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-07 18:14 [Qemu-devel] [PATCH] qemu: make virtio-blk PCI compliant by default Michael S. Tsirkin
2009-09-08 7:40 ` [Qemu-devel] " john cooper
2009-09-08 7:58 ` Michael S. Tsirkin
2009-09-21 11:09 ` Rusty Russell
2009-09-21 15:47 ` john cooper
2009-09-22 9:30 ` Avi Kivity
2009-09-22 14:21 ` john cooper
2009-09-22 14:27 ` Avi Kivity
2009-09-22 14:41 ` Michael S. Tsirkin
2009-09-22 14:45 ` Avi Kivity
2009-09-22 15:09 ` john cooper
2009-09-23 1:59 ` Anthony Liguori
2009-09-23 4:56 ` john cooper
2009-09-29 6:09 ` [Qemu-devel] [PATCH 0/2] fix virtio_blk serial pci config breakage john cooper
2009-09-29 6:58 ` [Qemu-devel] " Michael S. Tsirkin
2009-09-29 7:22 ` Avi Kivity
2009-09-29 8:54 ` Michael S. Tsirkin
2009-09-29 9:16 ` Avi Kivity
2009-09-29 13:55 ` Anthony Liguori
2009-09-29 14:06 ` Michael S. Tsirkin
2009-09-29 14:14 ` Anthony Liguori
2009-09-29 16:24 ` Avi Kivity
2009-09-29 16:30 ` Michael S. Tsirkin
2009-09-29 17:26 ` Anthony Liguori
2009-09-29 17:31 ` Michael S. Tsirkin
2009-09-29 17:28 ` Rusty Russell
2009-09-29 17:31 ` Anthony Liguori
2009-09-30 1:12 ` Rusty Russell
2009-09-30 1:22 ` Jamie Lokier
2009-10-05 15:44 ` john cooper
2009-09-29 18:44 ` john cooper
2009-09-29 20:55 ` Anthony Liguori
2009-09-30 1:19 ` Rusty Russell
2009-09-30 2:17 ` Anthony Liguori
2009-09-30 12:00 ` Rusty Russell
2009-09-30 18:04 ` Jamie Lokier
2009-10-05 15:41 ` john cooper
2009-09-30 11:47 ` Paul Brook
2009-10-05 15:40 ` john cooper
2009-09-29 13:51 ` Anthony Liguori
2009-09-29 16:22 ` Avi Kivity
2009-09-29 17:24 ` Anthony Liguori
2009-09-29 6:09 ` [Qemu-devel] [PATCH 1/2] " john cooper
2009-09-29 9:01 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-05 15:47 ` [Qemu-devel] [PATCH] fix virtio_blk serial pci config breakage, v2 john cooper
2009-10-05 19:54 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 5:49 ` john cooper
2009-10-07 13:48 ` Anthony Liguori
2009-10-07 13:52 ` Michael S. Tsirkin
2009-10-07 13:55 ` Anthony Liguori
2009-10-07 15:38 ` john cooper
2009-10-05 20:15 ` Michael S. Tsirkin
2009-10-06 14:23 ` Anthony Liguori [this message]
2009-09-29 6:10 ` [Qemu-devel] [PATCH 2/2] fix virtio_blk serial pci config breakage john cooper
2009-09-29 6:57 ` [Qemu-devel] " Michael S. Tsirkin
2009-09-29 17:14 ` Rusty Russell
2009-09-14 11:39 ` [Qemu-devel] Re: [PATCH] qemu: make virtio-blk PCI compliant by default Michael S. Tsirkin
2009-09-15 7:29 ` john cooper
2009-09-22 5:06 ` Rusty Russell
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=4ACB52F7.80803@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=jens.axboe@oracle.com \
--cc=john.cooper@redhat.com \
--cc=john.cooper@third-harmonic.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--cc=vrozenfe@redhat.com \
/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 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.