From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH9g0-0005UL-LK for qemu-devel@nongnu.org; Fri, 30 Jan 2015 06:23:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH9fw-0003nv-PB for qemu-devel@nongnu.org; Fri, 30 Jan 2015 06:23:52 -0500 Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]:61007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH9fw-0003nl-Ih for qemu-devel@nongnu.org; Fri, 30 Jan 2015 06:23:48 -0500 Received: by mail-we0-f177.google.com with SMTP id l61so26500828wev.8 for ; Fri, 30 Jan 2015 03:23:48 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54CB69BE.20803@redhat.com> Date: Fri, 30 Jan 2015 12:23:42 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150122085127.5276.53895.stgit@PASHA-ISP.def.inno> <20150122085328.5276.86561.stgit@PASHA-ISP.def.inno> In-Reply-To: <20150122085328.5276.86561.stgit@PASHA-ISP.def.inno> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC PATCH v8 21/21] replay: recording of the user input List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgalyuk , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com On 22/01/2015 09:53, Pavel Dovgalyuk wrote: > +void replay_input_event(QemuConsole *src, InputEvent *evt) > +{ > + if (replay_mode == REPLAY_MODE_PLAY) { > + /* Nothing */ > + } else if (replay_mode == REPLAY_MODE_RECORD) { > + replay_add_input_event(evt); Does replay_add_input_event ultimately call qemu_input_event_send_impl? > + } else { > + qemu_input_event_send_impl(src, evt); > + } > +} > + Perhaps make this and replay_input_sync_event return a bool and in the caller do: if (replay_input_event(src, evt)) { qemu_input_event_send_impl(src, evt): } > + 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. Also, you do not need the "if" for replay mode. The functions would just do nothing. > + } else { > + if (replay_mode != REPLAY_MODE_NONE) { > + fprintf(stderr, "Input queue is not supported " > + "in record/replay mode\n"); > + exit(1); Why? For record mode should just work since qemu_input_event_send is called in qemu_input_queue_process. Replay mode can just do nothing, by returning early from qemu_input_queue_event/qemu_input_queue_sync. Paolo > + } > + qemu_input_queue_event(&kbd_queue, src, evt); > + qemu_input_queue_sync(&kbd_queue); > + } > }