#include "standard-headers/linux/virtio_input.h"
#include "qapi/error.h"
+enum {
+ VHOST_USER_INPUT_MAX_QUEUES = 2,
+};
+
typedef struct virtio_input_event virtio_input_event;
typedef struct virtio_input_config virtio_input_config;
vi.config = g_array_new(false, false, sizeof(virtio_input_config));
memset(&id, 0, sizeof(id));
- ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1), id.u.string);
+ if (ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1),
+ id.u.string) < 0) {
+ g_printerr("Failed to get evdev name: %s\n", g_strerror(errno));
+ exit(EXIT_FAILURE);
+ }
id.select = VIRTIO_INPUT_CFG_ID_NAME;
id.size = strlen(id.u.string);
g_array_append_val(vi.config, id);
g_printerr("Invalid vhost-user socket.\n");
exit(EXIT_FAILURE);
}
- vug_init(&vi.dev, fd, vi_panic, &vuiface);
+
+ if (!vug_init(&vi.dev, VHOST_USER_INPUT_MAX_QUEUES, fd, vi_panic,
+ &vuiface)) {
+ g_printerr("Failed to initialize libvhost-user-glib.\n");
+ exit(EXIT_FAILURE);
+ }
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);