0002-Fix-build-with-64-bits-time_t.patch 3.5 KB

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