On Thu, Jun 07, 2018 at 04:32:54PM +0200, Markus Armbruster wrote: > Peter Xu <pet...@redhat.com> writes: > > > Instead, use a dynamic function to detect which clock we'll use. The > > problem is that the old code will let monitor initialization depends on > > qtest_enabled(). After this change, we don't have such a dependency any > > more. > > > > Suggested-by: Markus Armbruster <arm...@redhat.com> > > Signed-off-by: Peter Xu <pet...@redhat.com> > > --- > > monitor.c | 21 ++++++++++++--------- > > 1 file changed, 12 insertions(+), 9 deletions(-) > > > > diff --git a/monitor.c b/monitor.c > > index 2504696d76..bd9ab5597f 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -282,8 +282,6 @@ QmpCommandList qmp_commands, > > qmp_cap_negotiation_commands; > > > > Monitor *cur_mon; > > > > -static QEMUClockType event_clock_type = QEMU_CLOCK_REALTIME; > > - > > static void monitor_command_cb(void *opaque, const char *cmdline, > > void *readline_opaque); > > > > @@ -310,6 +308,15 @@ static inline bool > > monitor_is_hmp_non_interactive(const Monitor *mon) > > return !monitor_is_qmp(mon) && !monitor_uses_readline(mon); > > } > > > > +static inline QEMUClockType monitor_get_clock(void) > > +{ > > + if (qtest_enabled()) { > > + return QEMU_CLOCK_VIRTUAL; > > + } else { > > + return QEMU_CLOCK_REALTIME; > > + } > > Suggest the more laconic > > return qtest_enabled() ? QEMU_CLOCK_VIRTUAL : QEMU_CLOCK_REALTIME; > > A comment explaining why we want QEMU_CLOCK_VIRTUAL would be nice.
Will do. -- Peter Xu