From: Stefan Hajnoczi <stefanha@gmail.com>
To: Changpeng Liu <changpeng.liu@intel.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, mst@redhat.com,
marcandre.lureau@redhat.com, felipe@nutanix.com,
james.r.harris@intel.com
Subject: Re: [Qemu-devel] [PATCH v6 4/4] contrib/vhost-user-blk: introduce a vhost-user-blk sample application
Date: Mon, 11 Dec 2017 14:33:10 +0000 [thread overview]
Message-ID: <20171211143310.GD5962@stefanha-x1.localdomain> (raw)
In-Reply-To: <1512455239-8296-5-git-send-email-changpeng.liu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2273 bytes --]
> +static int vub_virtio_process_req(VubDev *vdev_blk,
> + VuVirtq *vq)
> +{
> + VugDev *gdev = &vdev_blk->parent;
> + VuDev *vu_dev = &gdev->parent;
> + VuVirtqElement *elem;
> + uint32_t type;
> + unsigned in_num;
> + unsigned out_num;
> + VubReq *req;
> +
> + elem = vu_queue_pop(vu_dev, vq, sizeof(VuVirtqElement));
> + if (!elem) {
> + return -1;
> + }
> +
> + /* refer to hw/block/virtio_blk.c */
> + if (elem->out_num < 1 || elem->in_num < 1) {
> + fprintf(stderr, "virtio-blk request missing headers\n");
> + free(elem);
> + return -1;
> + }
> +
> + req = g_new0(VubReq, 1);
> + req->vdev_blk = vdev_blk;
> + req->vq = vq;
> + req->elem = elem;
> +
> + in_num = elem->in_num;
> + out_num = elem->out_num;
> +
> + /* don't support VIRTIO_F_ANY_LAYOUT and virtio 1.0 only */
> + if (elem->out_sg[0].iov_len < sizeof(struct virtio_blk_outhdr)) {
> + fprintf(stderr, "Invalid outhdr size\n");
> + goto err;
> + }
QEMU has iov_discard_front() and iov_discard_back(). They make it
pretty easy to support VIRTIO_F_ANY_LAYOUT. If you have time, please
consider adding it to libvhost-user, but it's not a requirement for this
patch series.
> + req->out = (struct virtio_blk_outhdr *)elem->out_sg[0].iov_base;
> + out_num--;
> +
> + if (elem->in_sg[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
> + fprintf(stderr, "Invalid inhdr size\n");
> + goto err;
> + }
> + req->in = (struct virtio_blk_inhdr *)elem->in_sg[in_num - 1].iov_base;
> + in_num--;
> +
> + type = le32toh(req->out->type);
Endianness is more complicated if you want to support both VIRTIO 1.0
and Legacy (0.9.7). I guess it's okay to make libvhost-user code only
support VIRTIO 1.0.
> +static void vub_queue_set_started(VuDev *vu_dev, int idx, bool started)
> +{
> + VuVirtq *vq;
> +
> + assert(vu_dev);
> +
> + if ((idx < 0) || (idx >= VHOST_MAX_NR_VIRTQUEUE)) {
> + fprintf(stderr, "VQ Index out of range: %d\n", idx);
> + vub_panic_cb(vu_dev, NULL);
> + return;
> + }
Is it necessary to check num_queues? The vhost-user master should not
be able to enable idx >= num_queues.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-12-11 14:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 6:27 [Qemu-devel] [PATCH v6 0/4] Introduce a new vhost-user-blk host device to QEMU Changpeng Liu
2017-12-05 6:27 ` [Qemu-devel] [PATCH v6 1/4] vhost-user: add new vhost user messages to support virtio config space Changpeng Liu
2017-12-11 13:39 ` Stefan Hajnoczi
2017-12-12 1:25 ` Liu, Changpeng
2017-12-12 10:20 ` Stefan Hajnoczi
2017-12-05 6:27 ` [Qemu-devel] [PATCH v6 2/4] vhost-user-blk: introduce a new vhost-user-blk host device Changpeng Liu
2017-12-11 13:54 ` Stefan Hajnoczi
2017-12-05 6:27 ` [Qemu-devel] [PATCH v6 3/4] contrib/libvhost-user: enable virtio config space messages Changpeng Liu
2017-12-11 13:59 ` Stefan Hajnoczi
2017-12-12 1:26 ` Liu, Changpeng
2017-12-05 6:27 ` [Qemu-devel] [PATCH v6 4/4] contrib/vhost-user-blk: introduce a vhost-user-blk sample application Changpeng Liu
2017-12-11 14:33 ` Stefan Hajnoczi [this message]
2017-12-12 1:36 ` Liu, Changpeng
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=20171211143310.GD5962@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=changpeng.liu@intel.com \
--cc=felipe@nutanix.com \
--cc=james.r.harris@intel.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.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).