Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libvhost user #1

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions contrib/libvhost-user/libvhost-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ vu_set_vring_addr_exec(VuDev *dev, VhostUserMsg *vmsg)
return false;
}

vq->used_idx = vq->vring.used->idx;

return false;
}

Expand All @@ -528,7 +530,7 @@ vu_set_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)

DPRINT("State.index: %d\n", index);
DPRINT("State.num: %d\n", num);
dev->vq[index].last_avail_idx = num;
dev->vq[index].shadow_avail_idx = dev->vq[index].last_avail_idx = num;

return false;
}
Expand All @@ -542,8 +544,8 @@ vu_get_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)
vmsg->payload.state.num = dev->vq[index].last_avail_idx;
vmsg->size = sizeof(vmsg->payload.state);

dev->vq[index].started = false;
if (dev->iface->queue_set_started) {
dev->vq[index].started = false;
dev->iface->queue_set_started(dev, index, false);
}

Expand Down Expand Up @@ -603,19 +605,6 @@ vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg)
DPRINT("Got kick_fd: %d for vq: %d\n", vmsg->fds[0], index);
}

if (dev->iface->queue_set_started) {
dev->vq[index].started = true;
dev->iface->queue_set_started(dev, index, true);
}

if (dev->vq[index].kick_fd != -1 && dev->vq[index].handler) {
dev->add_watch(dev, dev->vq[index].kick_fd, VU_WATCH_IN,
vu_kick_cb, (void *)(long)index);

DPRINT("Waiting for kicks on fd: %d for vq: %d\n",
dev->vq[index].kick_fd, index);
}

return false;
}

Expand Down Expand Up @@ -657,6 +646,19 @@ vu_set_vring_call_exec(VuDev *dev, VhostUserMsg *vmsg)

DPRINT("Got call_fd: %d for vq: %d\n", vmsg->fds[0], index);

dev->vq[index].started = true;
if (dev->iface->queue_set_started) {
dev->iface->queue_set_started(dev, index, true);
}

if (dev->vq[index].kick_fd != -1 && dev->vq[index].handler) {
dev->add_watch(dev, dev->vq[index].kick_fd, VU_WATCH_IN,
vu_kick_cb, (void *)(long)index);

DPRINT("Waiting for kicks on fd: %d for vq: %d\n",
dev->vq[index].kick_fd, index);
}

return false;
}

Expand Down Expand Up @@ -1215,7 +1217,7 @@ virtqueue_map_desc(VuDev *dev,
assert(num_sg <= max_num_sg);

if (!sz) {
vu_panic("virtio: zero sized buffers are not allowed");
vu_panic(dev, "virtio: zero sized buffers are not allowed");
return;
}

Expand Down Expand Up @@ -1271,8 +1273,8 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz)

max = vq->vring.num;
if (vq->inuse >= vq->vring.num) {
vu_panic("Virtqueue size exceeded");
return;
vu_panic(dev, "Virtqueue size exceeded");
return NULL;
}

i = head = virtqueue_get_head(dev, vq, vq->last_avail_idx++);
Expand Down