Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164915
b: refs/heads/master
c: ca60a42
h: refs/heads/master
i:
  164913: 922626a
  164911: 5b1fbc2
v: v3
  • Loading branch information
Rusty Russell committed Sep 23, 2009
1 parent c023683 commit 15c3b2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6c189d8312246af776c2587c233d6afcf3714438
refs/heads/master: ca60a42c9be41c07ebcc2ec8c43dd1be53f147bf
25 changes: 21 additions & 4 deletions trunk/Documentation/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ struct device {
/* Is it operational */
bool running;

/* Does Guest want an intrrupt on empty? */
bool irq_on_empty;

/* Device-specific data. */
void *priv;
};
Expand Down Expand Up @@ -624,10 +627,13 @@ static void trigger_irq(struct virtqueue *vq)
return;
vq->pending_used = 0;

/* If they don't want an interrupt, don't send one, unless empty. */
if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
&& lg_last_avail(vq) != vq->vring.avail->idx)
return;
/* If they don't want an interrupt, don't send one... */
if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) {
/* ... unless they've asked us to force one on empty. */
if (!vq->dev->irq_on_empty
|| lg_last_avail(vq) != vq->vring.avail->idx)
return;
}

/* Send the Guest an interrupt tell them we used something up. */
if (write(lguest_fd, buf, sizeof(buf)) != 0)
Expand Down Expand Up @@ -1043,6 +1049,15 @@ static void create_thread(struct virtqueue *vq)
close(vq->eventfd);
}

static bool accepted_feature(struct device *dev, unsigned int bit)
{
const u8 *features = get_feature_bits(dev) + dev->feature_len;

if (dev->feature_len < bit / CHAR_BIT)
return false;
return features[bit / CHAR_BIT] & (1 << (bit % CHAR_BIT));
}

static void start_device(struct device *dev)
{
unsigned int i;
Expand All @@ -1056,6 +1071,8 @@ static void start_device(struct device *dev)
verbose(" %02x", get_feature_bits(dev)
[dev->feature_len+i]);

dev->irq_on_empty = accepted_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);

for (vq = dev->vq; vq; vq = vq->next) {
if (vq->service)
create_thread(vq);
Expand Down

0 comments on commit 15c3b2e

Please sign in to comment.