#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
.msg_iovlen = num,
.msg_flags = MSG_DONTWAIT,
};
- do {
- ret = recvmsg(vubr->backend_udp_sock, &msg, 0);
- } while (ret == -1 && (errno == EINTR));
+ ret = RETRY_ON_EINTR(recvmsg(vubr->backend_udp_sock, &msg, 0));
if (i == 0) {
iov_restore_front(elem->in_sg, sg, hdrlen);
if (started && vubr->notifier.fd >= 0) {
vu_set_queue_host_notifier(dev, vq, vubr->notifier.fd,
- qemu_real_host_page_size,
- qidx * qemu_real_host_page_size);
+ qemu_real_host_page_size(),
+ qidx * qemu_real_host_page_size());
}
if (qidx % 2 == 1) {
VHOST_USER_BRIDGE_MAX_QUEUES,
conn_fd,
vubr_panic,
+ NULL,
vubr_set_watch,
vubr_remove_watch,
&vuiface)) {
CallbackFunc cb;
size_t len;
+ if (strlen(path) >= sizeof(un.sun_path)) {
+ fprintf(stderr, "unix domain socket path '%s' is too long\n", path);
+ exit(1);
+ }
+
/* Get a UNIX socket. */
dev->sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (dev->sock == -1) {
VHOST_USER_BRIDGE_MAX_QUEUES,
dev->sock,
vubr_panic,
+ NULL,
vubr_set_watch,
vubr_remove_watch,
&vuiface)) {
{
VuDev *dev = (VuDev *)arg;
VubrDev *vubr = container_of(dev, VubrDev, vudev);
- int pagesize = qemu_real_host_page_size;
+ int pagesize = qemu_real_host_page_size();
int qidx;
while (true) {
static void
vubr_host_notifier_setup(VubrDev *dev)
{
- char template[] = "/tmp/vubr-XXXXXX";
pthread_t thread;
size_t length;
void *addr;
int fd;
- length = qemu_real_host_page_size * VHOST_USER_BRIDGE_MAX_QUEUES;
+ length = qemu_real_host_page_size() * VHOST_USER_BRIDGE_MAX_QUEUES;
- fd = mkstemp(template);
+ fd = g_file_open_tmp("vubr-XXXXXX", NULL, NULL);
if (fd < 0) {
vubr_die("mkstemp()");
}
out:
fprintf(stderr, "Usage: %s ", argv[0]);
fprintf(stderr, "[-c] [-H] [-u ud_socket_path] [-l lhost:lport] [-r rhost:rport]\n");
- fprintf(stderr, "\t-u path to unix doman socket. default: %s\n",
+ fprintf(stderr, "\t-u path to unix domain socket. default: %s\n",
DEFAULT_UD_SOCKET);
fprintf(stderr, "\t-l local host and port. default: %s:%s\n",
DEFAULT_LHOST, DEFAULT_LPORT);