> From: Paolo Bonzini [mailto:pbonz...@redhat.com] > On 12/01/2015 13:00, Pavel Dovgalyuk wrote: > > +/*! Reads next clock event from the input. */ > > +int64_t replay_read_clock(unsigned int kind) > > +{ > > + if (kind >= REPLAY_CLOCK_COUNT) { > > + fprintf(stderr, "invalid clock ID %d for replay\n", kind); > > + exit(1); > > + } > > + > > + replay_exec_instructions(); > > + > > + if (replay_file) { > > + if (skip_async_events(EVENT_CLOCK + kind)) { > > + replay_read_next_clock(kind); > > + } > > + int64_t ret = replay_state.cached_clock[kind]; > > + > > + return ret; > > + } > > + > > + fprintf(stderr, "REPLAY INTERNAL ERROR %d\n", __LINE__); > > + exit(1); > > +} > > Is this thread safe?
It is, because order of main_loop and cpu_exec executions is protected by global mutex. > Please introduce the record/replay QemuMutex in > patch 4, and all along the series document which variables it protects. record/replay only uses mutex for events queue, because events may be added to the queue by the different threads. Pavel Dovgalyuk