From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDmX-0007PX-Jb for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:47:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMDmU-0005pT-E4 for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:47:33 -0500 Received: from mail-bl2on0111.outbound.protection.outlook.com ([65.55.169.111]:14253 helo=na01-bl2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDmU-0005pN-8v for qemu-devel@nongnu.org; Fri, 13 Feb 2015 05:47:30 -0500 Message-ID: <54DDD637.808@freescale.com> Date: Fri, 13 Feb 2015 12:47:19 +0200 From: Vasile Catalin-B50542 MIME-Version: 1.0 References: <54DCB016.8030509@freescale.com> In-Reply-To: <54DCB016.8030509@freescale.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [virtio] virtqueue request size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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;