> From: Paolo Bonzini [mailto:paolo.bonz...@gmail.com] On Behalf Of Paolo > Bonzini > On 22/01/2015 09:53, Pavel Dovgalyuk wrote: > > + if (replay_mode != REPLAY_MODE_PLAY) { > > + evt = qemu_input_event_new_key(key, down); > > + if (QTAILQ_EMPTY(&kbd_queue)) { > > + qemu_input_event_send(src, evt); > > + qemu_input_event_sync(); > > + if (replay_mode != REPLAY_MODE_RECORD) { > > + qapi_free_InputEvent(evt); > > + } > > This is wrong. You have different lifetimes for different modes. Please > make a copy of the event in the implementation of record mode.
What is the correct way for cloning the QAPI type? I should invent the cloning visitor or just create a switch for correct cloning of the InputEvent union? Pavel Dovgalyuk