qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vasile Catalin-B50542 <catalin.vasile@freescale.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [virtio] virtqueue request size
Date: Fri, 13 Feb 2015 12:47:19 +0200	[thread overview]
Message-ID: <54DDD637.808@freescale.com> (raw)
In-Reply-To: <54DCB016.8030509@freescale.com>

I found out what was the problem.
I was calling virtqueue_get_avail_bytes() after virtqueue_pop().

On 12.02.2015 15:52, Vasile Catalin-B50542 wrote:
> I'm trying to work out virtqueue from the virtio API.
> I've been able to send a message from guest to qemu, but there is 
> something
> strange that I don't understand.
> virtqueue_get_avail_bytes() returns 0 number of "in" bytes, but if I 
> hard code
> iov_to_buf() to get 5 bytes, it actually gets my message.
> What am I missing out?
>
> Here is the essential code so far:
> Guest:
>     probe function:
>         vq = virtio_find_single_vq(vdev, recv_done, "input");
>     triggered send function:
>         sg_init_one(&sg, buf, size);
>         if (virtqueue_add_inbuf(vq, &sg, 1, buf, GFP_KERNEL) < 0)
>             BUG();
>         virtqueue_kick(vq);
>
> Qemu:
>     realize function:
>         vcrypto->vq = virtio_add_queue(vdev, 8, handle_input);
>     handle_input:
>         virtqueue_pop(vcrypto->vq, &elem);
>         eprintf("request size is %u", get_request_size(vcrypto->vq, 
> 100)); // prints size 0
>         iov_to_buf(elem.in_sg, elem.in_num, 0, buffer, 5); // 
> hardcoded to 5 bytes for now
>     get_request_size:
>         virtqueue_get_avail_bytes(vq, &in, &out, quota, quota); // 
> quota = 100
>         return in;

      parent reply	other threads:[~2015-02-13 10:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 13:52 [Qemu-devel] [virtio] virtqueue request size Vasile Catalin-B50542
2015-02-13 10:45 ` Vasile Catalin-B50542
2015-02-13 10:47 ` Vasile Catalin-B50542 [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=54DDD637.808@freescale.com \
    --to=catalin.vasile@freescale.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).