/* This actually sends the interrupt for this virtqueue, if we've used a buffer.  */
static void trigger_irq(struct virtqueue *vq)
/* This actually sends the interrupt for this virtqueue, if we've used a buffer.  */
static void trigger_irq(struct virtqueue *vq)
{
	unsigned long buf[] = { LHREQ_IRQ, vq->config.irq };
	if (!vq->pending_used)
		return;
	vq->pending_used = 0;
	if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) {
		if (!vq->dev->irq_on_empty
		    || lg_last_avail(vq) != vq->vring.avail->idx)
			return;
	}
	if (write(lguest_fd, buf, sizeof(buf)) != 0)
		err(1, "Triggering irq %i", vq->config.irq);
}