From 1684907c924140be00950a8a17740377f477a6a6 Mon Sep 17 00:00:00 2001 From: Javier Celaya Date: Mon, 27 Mar 2017 20:26:24 +0200 Subject: Fix input-linux reading from device The evdev devices in input-linux.c are read in blocks of one whole event. If there are not enough bytes available, they are discarded, instead of being kept for the next read operation. This results in lost events, of even non-working devices. This patch keeps track of the number of bytes to be read to fill up a whole event, and then handle it. Changes from v1 to v2: - Fix: Calculate offset on each iteration Changes from v2 to v3: - Fix coding style - Store offset instead of bytes to be read Signed-off-by: Javier Celaya Message-id: 20170327182624.2914-1-jcelaya@gmail.com Signed-off-by: Gerd Hoffmann --- ui/input-linux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/input-linux.c b/ui/input-linux.c index ac31f47..dc0613c 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -169,6 +169,8 @@ struct InputLinux { bool has_abs_x; int num_keys; int num_btns; + struct input_event event; + int read_offset; QTAILQ_ENTRY(InputLinux) next; }; @@ -327,25 +329,30 @@ static void input_linux_handle_mouse(InputLinux *il, struct input_event *event) static void input_linux_event(void *opaque) { InputLinux *il = opaque; - struct input_event event; int rc; + int read_size; + uint8_t *p = (uint8_t *)&il->event; for (;;) { - rc = read(il->fd, &event, sizeof(event)); - if (rc != sizeof(event)) { + read_size = sizeof(il->event) - il->read_offset; + rc = read(il->fd, &p[il->read_offset], read_size); + if (rc != read_size) { if (rc < 0 && errno != EAGAIN) { fprintf(stderr, "%s: read: %s\n", __func__, strerror(errno)); qemu_set_fd_handler(il->fd, NULL, NULL, NULL); close(il->fd); + } else if (rc > 0) { + il->read_offset += rc; } break; } + il->read_offset = 0; if (il->num_keys) { - input_linux_handle_keyboard(il, &event); + input_linux_handle_keyboard(il, &il->event); } if (il->has_rel_x && il->num_btns) { - input_linux_handle_mouse(il, &event); + input_linux_handle_mouse(il, &il->event); } } } -- cgit v1.1 From fa03cb7fd212bc07f0253db9ea436383ddc6c08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 28 Mar 2017 18:06:46 +0200 Subject: vnc: allow to connect with add_client when -vnc none MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not skip VNC initialization, in particular of auth method when vnc is configured without sockets, since we should still allow connections through QMP add_client. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1434551 Signed-off-by: Marc-André Lureau Message-id: 20170328160646.21250-1-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/vnc.c b/ui/vnc.c index 821acdd..243e99b 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3786,10 +3786,6 @@ void vnc_display_open(const char *id, Error **errp) goto fail; } - if (saddr == NULL) { - return; - } - password = qemu_opt_get_bool(opts, "password", false); if (password) { if (fips_get_state()) { @@ -3974,6 +3970,10 @@ void vnc_display_open(const char *id, Error **errp) register_displaychangelistener(&vd->dcl); } + if (saddr == NULL) { + goto cleanup; + } + if (reverse) { if (vnc_display_connect(vd, saddr, nsaddr, wsaddr, nwsaddr, errp) < 0) { goto fail; -- cgit v1.1