#define _FILE_OFFSET_BITS 64
-#include "qemu/atomic.h"
#include "qemu/osdep.h"
+#include "qemu/atomic.h"
+#include "qemu/ctype.h"
#include "qemu/iov.h"
#include "standard-headers/linux/virtio_net.h"
-#include "contrib/libvhost-user/libvhost-user.h"
+#include "libvhost-user.h"
#define VHOST_USER_BRIDGE_DEBUG 1
} \
} while (0)
+enum {
+ VHOST_USER_BRIDGE_MAX_QUEUES = 8,
+};
+
typedef void (*CallbackFunc)(int sock, void *ctx);
typedef struct Event {
.msg_name = (struct sockaddr *) &vubr->backend_udp_dest,
.msg_namelen = sizeof(struct sockaddr_in),
.msg_iov = sg,
- .msg_iovlen = elem->in_num,
+ .msg_iovlen = num,
.msg_flags = MSG_DONTWAIT,
};
do {
if (started && vubr->notifier.fd >= 0) {
vu_set_queue_host_notifier(dev, vq, vubr->notifier.fd,
- getpagesize(),
- qidx * getpagesize());
+ qemu_real_host_page_size,
+ qidx * qemu_real_host_page_size);
}
if (qidx % 2 == 1) {
}
DPRINT("Got connection from remote peer on sock %d\n", conn_fd);
- vu_init(&dev->vudev,
- conn_fd,
- vubr_panic,
- vubr_set_watch,
- vubr_remove_watch,
- &vuiface);
+ if (!vu_init(&dev->vudev,
+ VHOST_USER_BRIDGE_MAX_QUEUES,
+ conn_fd,
+ vubr_panic,
+ NULL,
+ vubr_set_watch,
+ vubr_remove_watch,
+ &vuiface)) {
+ fprintf(stderr, "Failed to initialize libvhost-user\n");
+ exit(1);
+ }
dispatcher_add(&dev->dispatcher, conn_fd, ctx, vubr_receive_cb);
dispatcher_remove(&dev->dispatcher, sock);
if (connect(dev->sock, (struct sockaddr *)&un, len) == -1) {
vubr_die("connect");
}
- vu_init(&dev->vudev,
- dev->sock,
- vubr_panic,
- vubr_set_watch,
- vubr_remove_watch,
- &vuiface);
+
+ if (!vu_init(&dev->vudev,
+ VHOST_USER_BRIDGE_MAX_QUEUES,
+ dev->sock,
+ vubr_panic,
+ NULL,
+ vubr_set_watch,
+ vubr_remove_watch,
+ &vuiface)) {
+ fprintf(stderr, "Failed to initialize libvhost-user\n");
+ exit(1);
+ }
+
cb = vubr_receive_cb;
}
{
VuDev *dev = (VuDev *)arg;
VubrDev *vubr = container_of(dev, VubrDev, vudev);
- int pagesize = getpagesize();
+ int pagesize = qemu_real_host_page_size;
int qidx;
while (true) {
- for (qidx = 0; qidx < VHOST_MAX_NR_VIRTQUEUE; qidx++) {
+ for (qidx = 0; qidx < VHOST_USER_BRIDGE_MAX_QUEUES; qidx++) {
uint16_t *n = vubr->notifier.addr + pagesize * qidx;
if (*n == qidx) {
void *addr;
int fd;
- length = getpagesize() * VHOST_MAX_NR_VIRTQUEUE;
+ length = qemu_real_host_page_size * VHOST_USER_BRIDGE_MAX_QUEUES;
fd = mkstemp(template);
if (fd < 0) {
static void
vubr_set_host(struct sockaddr_in *saddr, const char *host)
{
- if (isdigit(host[0])) {
+ if (qemu_isdigit(host[0])) {
if (!inet_aton(host, &saddr->sin_addr)) {
fprintf(stderr, "inet_aton() failed.\n");
exit(1);