From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLuC6-0002rs-JM for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:52:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLuC2-0000Gy-Bf for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:52:38 -0500 Received: from mail-bn1bbn0108.outbound.protection.outlook.com ([157.56.111.108]:53664 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLuC2-0000Gu-0b for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:52:34 -0500 Message-ID: <54DCB016.8030509@freescale.com> Date: Thu, 12 Feb 2015 15:52:22 +0200 From: Vasile Catalin-B50542 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [virtio] virtqueue request size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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;