Skip to contentSkip to conversation

input: add trace events for full queues

PATCH New Gerd Hoffmann 1 participant 1 message Jun 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: add trace events for full queues

It isn't unusual to happen, for example during reboot when the guest doesn't reveice events for a while. So better don't flood stderr with alarming messages. Turn them into tracepoints instead so they can be enabled in case they are needed for trouble-shooting.

---
 hw/input/hid.c          | 3 ++-
 hw/input/trace-events   | 6 ++++++
 hw/input/virtio-input.c | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)
hw/input/hid.c +2 -1
index d92c746..5e2850e 100644
@@ -27,6 +27,7 @@
 #include "ui/console.h"
 #include "qemu/timer.h"
 #include "hw/input/hid.h"
+#include "trace.h"
 
 #define HID_USAGE_ERROR_ROLLOVER        0x01
 #define HID_USAGE_POSTFAIL              0x02
@@ -234,7 +235,7 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
                                              key->down,
                                              scancodes);
     if (hs->n + count > QUEUE_LENGTH) {
-        fprintf(stderr, "usb-kbd: warning: key event queue full\n");
+        trace_hid_kbd_queue_full();
         return;
     }
     for (i = 0; i < count; i++) {
hw/input/trace-events +6 -0
index 00fcec1..f24dff2 100644
@@ -23,3 +23,9 @@ milkymist_softusb_memory_write(uint32_t addr, uint32_t value) "addr %08x value %
 milkymist_softusb_mevt(uint8_t m) "m %d"
 milkymist_softusb_kevt(uint8_t m) "m %d"
 milkymist_softusb_pulse_irq(void) "Pulse IRQ"
+
+# hw/input/hid.c
+hid_kbd_queue_full(void) "queue full"
+
+# hw/input/virtio
+virtio_input_queue_full(void) "queue full"
hw/input/virtio-input.c +2 -1
index f59749a..edf6990 100644
@@ -7,6 +7,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/iov.h"
+#include "trace.h"
 
 #include "hw/qdev.h"
 #include "hw/virtio/virtio.h"
@@ -47,7 +48,7 @@ void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event)
     virtqueue_get_avail_bytes(vinput->evt, &have, NULL, need, 0);
     if (have < need) {
         vinput->qindex = 0;
-        fprintf(stderr, "%s: ENOSPC in vq, dropping events\n", __func__);
+        trace_virtio_input_queue_full();
         return;
     }
 
Signature · 1 line
1.8.3.1