* [Qemu-devel] [virtio] virtqueue request size
@ 2015-02-12 13:52 Vasile Catalin-B50542
2015-02-13 10:45 ` Vasile Catalin-B50542
2015-02-13 10:47 ` Vasile Catalin-B50542
0 siblings, 2 replies; 3+ messages in thread
From: Vasile Catalin-B50542 @ 2015-02-12 13:52 UTC (permalink / raw)
To: qemu-devel
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [virtio] virtqueue request size
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
1 sibling, 0 replies; 3+ messages in thread
From: Vasile Catalin-B50542 @ 2015-02-13 10:45 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]
I found what was the problem.
virtqueue_get_avail_bytes() must be called before 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;
[-- Attachment #2: Type: text/html, Size: 2385 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [virtio] virtqueue request size
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
1 sibling, 0 replies; 3+ messages in thread
From: Vasile Catalin-B50542 @ 2015-02-13 10:47 UTC (permalink / raw)
To: qemu-devel
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-13 10:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).