1From f7a6df5f5bf3acc219352a1b25573ae2082d7e42 Mon Sep 17 00:00:00 2001 2From: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3Date: Thu, 3 Dec 2020 20:58:19 +0100 4Subject: [PATCH] Fix build with 64 bits time_t 5 6time element is deprecated on new input_event structure in kernel's 7input.h [1] 8 9This will avoid the following build failure: 10 11hw/input/virtio-input-host.c: In function 'virtio_input_host_handle_status': 12hw/input/virtio-input-host.c:198:28: error: 'struct input_event' has no member named 'time' 13 198 | if (gettimeofday(&evdev.time, NULL)) { 14 | ^ 15 16Fixes: 17 - http://autobuild.buildroot.org/results/a538167e288c14208d557cd45446df86d3d599d5 18 - http://autobuild.buildroot.org/results/efd4474fb4b6c0ce0ab3838ce130429c51e43bbb 19 20[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f 21 22Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 23Message-Id: <20201203195819.583626-1-fontaine.fabrice@gmail.com> 24Fixes: https://gitlab.com/qemu-project/qemu/-/issues/246 25Reviewed-by: Michael S. Tsirkin <mst@redhat.com> 26Signed-off-by: Michael S. Tsirkin <mst@redhat.com> 27 28[Retrieved (and updated for qemu-xen) from: 29https://github.com/qemu/qemu/commit/f7a6df5f5bf3acc219352a1b25573ae2082d7e42] 30Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 31--- 32 contrib/vhost-user-input/main.c | 8 ++++++-- 33 hw/input/virtio-input-host.c | 5 ++++- 34 2 files changed, 10 insertions(+), 3 deletions(-) 35 36diff --git a/tools/qemu-xen/contrib/vhost-user-input/main.c b/tools/qemu-xen/contrib/vhost-user-input/main.c 37index c15d18c33f0c..081230da548a 100644 38--- a/tools/qemu-xen/contrib/vhost-user-input/main.c 39+++ b/tools/qemu-xen/contrib/vhost-user-input/main.c 40@@ -6,13 +6,14 @@ 41 #include "qemu/osdep.h" 42 43 #include <glib.h> 44-#include <linux/input.h> 45+#include <sys/ioctl.h> 46 47 #include "qemu/iov.h" 48 #include "qemu/bswap.h" 49 #include "qemu/sockets.h" 50 #include "contrib/libvhost-user/libvhost-user.h" 51 #include "contrib/libvhost-user/libvhost-user-glib.h" 52+#include "standard-headers/linux/input.h" 53 #include "standard-headers/linux/virtio_input.h" 54 #include "qapi/error.h" 55 56@@ -113,13 +114,16 @@ vi_evdev_watch(VuDev *dev, int condition, void *data) 57 static void vi_handle_status(VuInput *vi, virtio_input_event *event) 58 { 59 struct input_event evdev; 60+ struct timeval tval; 61 int rc; 62 63- if (gettimeofday(&evdev.time, NULL)) { 64+ if (gettimeofday(&tval, NULL)) { 65 perror("vi_handle_status: gettimeofday"); 66 return; 67 } 68 69+ evdev.input_event_sec = tval.tv_sec; 70+ evdev.input_event_usec = tval.tv_usec; 71 evdev.type = le16toh(event->type); 72 evdev.code = le16toh(event->code); 73 evdev.value = le32toh(event->value); 74diff --git a/tools/qemu-xen/hw/input/virtio-input-host.c b/tools/qemu-xen/hw/input/virtio-input-host.c 75index 85daf73f1a80..137efba57b0f 100644 76--- a/tools/qemu-xen/hw/input/virtio-input-host.c 77+++ b/tools/qemu-xen/hw/input/virtio-input-host.c 78@@ -193,13 +193,16 @@ static void virtio_input_host_handle_status(VirtIOInput *vinput, 79 { 80 VirtIOInputHost *vih = VIRTIO_INPUT_HOST(vinput); 81 struct input_event evdev; 82+ struct timeval tval; 83 int rc; 84 85- if (gettimeofday(&evdev.time, NULL)) { 86+ if (gettimeofday(&tval, NULL)) { 87 perror("virtio_input_host_handle_status: gettimeofday"); 88 return; 89 } 90 91+ evdev.input_event_sec = tval.tv_sec; 92+ evdev.input_event_usec = tval.tv_usec; 93 evdev.type = le16_to_cpu(event->type); 94 evdev.code = le16_to_cpu(event->code); 95 evdev.value = le32_to_cpu(event->value); 96