qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/kraxel/tags/input-20190111-pull-request' into staging

input: avoid malloc for mouse events

# gpg: Signature made Fri 11 Jan 2019 14:26:44 GMT
# gpg: using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/input-20190111-pull-request:
input: avoid malloc for mouse events

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+31 -40
-3
include/ui/input.h
··· 49 49 int *codes); 50 50 int qemu_input_linux_to_qcode(unsigned int lnx); 51 51 52 - InputEvent *qemu_input_event_new_btn(InputButton btn, bool down); 53 52 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down); 54 53 void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, 55 54 uint32_t button_old, uint32_t button_new); ··· 58 57 int qemu_input_scale_axis(int value, 59 58 int min_in, int max_in, 60 59 int min_out, int max_out); 61 - InputEvent *qemu_input_event_new_move(InputEventKind kind, 62 - InputAxis axis, int value); 63 60 void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value); 64 61 void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, 65 62 int min_in, int max_in);
+31 -37
ui/input.c
··· 460 460 } 461 461 } 462 462 463 - InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) 464 - { 465 - InputEvent *evt = g_new0(InputEvent, 1); 466 - evt->u.btn.data = g_new0(InputBtnEvent, 1); 467 - evt->type = INPUT_EVENT_KIND_BTN; 468 - evt->u.btn.data->button = btn; 469 - evt->u.btn.data->down = down; 470 - return evt; 471 - } 472 - 473 463 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down) 474 464 { 475 - InputEvent *evt; 476 - evt = qemu_input_event_new_btn(btn, down); 477 - qemu_input_event_send(src, evt); 478 - qapi_free_InputEvent(evt); 465 + InputBtnEvent bevt = { 466 + .button = btn, 467 + .down = down, 468 + }; 469 + InputEvent evt = { 470 + .type = INPUT_EVENT_KIND_BTN, 471 + .u.btn.data = &bevt, 472 + }; 473 + 474 + qemu_input_event_send(src, &evt); 479 475 } 480 476 481 477 void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, ··· 515 511 return ((int64_t)value - min_in) * range_out / range_in + min_out; 516 512 } 517 513 518 - InputEvent *qemu_input_event_new_move(InputEventKind kind, 519 - InputAxis axis, int value) 520 - { 521 - InputEvent *evt = g_new0(InputEvent, 1); 522 - InputMoveEvent *move = g_new0(InputMoveEvent, 1); 523 - 524 - evt->type = kind; 525 - evt->u.rel.data = move; /* evt->u.rel is the same as evt->u.abs */ 526 - move->axis = axis; 527 - move->value = value; 528 - return evt; 529 - } 530 - 531 514 void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value) 532 515 { 533 - InputEvent *evt; 534 - evt = qemu_input_event_new_move(INPUT_EVENT_KIND_REL, axis, value); 535 - qemu_input_event_send(src, evt); 536 - qapi_free_InputEvent(evt); 516 + InputMoveEvent move = { 517 + .axis = axis, 518 + .value = value, 519 + }; 520 + InputEvent evt = { 521 + .type = INPUT_EVENT_KIND_REL, 522 + .u.rel.data = &move, 523 + }; 524 + 525 + qemu_input_event_send(src, &evt); 537 526 } 538 527 539 528 void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, 540 529 int min_in, int max_in) 541 530 { 542 - InputEvent *evt; 543 - int scaled = qemu_input_scale_axis(value, min_in, max_in, 531 + InputMoveEvent move = { 532 + .axis = axis, 533 + .value = qemu_input_scale_axis(value, min_in, max_in, 544 534 INPUT_EVENT_ABS_MIN, 545 - INPUT_EVENT_ABS_MAX); 546 - evt = qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled); 547 - qemu_input_event_send(src, evt); 548 - qapi_free_InputEvent(evt); 535 + INPUT_EVENT_ABS_MAX), 536 + }; 537 + InputEvent evt = { 538 + .type = INPUT_EVENT_KIND_ABS, 539 + .u.abs.data = &move, 540 + }; 541 + 542 + qemu_input_event_send(src, &evt); 549 543 } 550 544 551 545 void qemu_input_check_mode_change(void)