/* This handles packets coming in from the tun device to our Guest. Like all service routines, it gets called again as soon as it returns, so you don't see a while(1) loop here.  */
static void net_input(struct virtqueue *vq)
/* This handles packets coming in from the tun device to our Guest. Like all service routines, it gets called again as soon as it returns, so you don't see a while(1) loop here.  */
static void net_input(struct virtqueue *vq)
{
	int len;
	unsigned int head, out, in;
	struct iovec iov[vq->vring.num];
	struct net_info *net_info = vq->dev->priv;
	head = wait_for_vq_desc(vq, iov, &out, &in);
	if (out)
		errx(1, "Output buffers in net input queue?");
	if (vq->pending_used && will_block(net_info->tunfd))
		trigger_irq(vq);
	len = readv(net_info->tunfd, iov, in);
	if (len <= 0)
		err(1, "Failed to read from tun.");
	add_used(vq, head, len);
}