From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fR8Tf-0002f7-Dt for qemu-devel@nongnu.org; Thu, 07 Jun 2018 23:54:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fR8Ta-0006Sj-HC for qemu-devel@nongnu.org; Thu, 07 Jun 2018 23:54:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53960 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fR8Ta-0006SS-Ch for qemu-devel@nongnu.org; Thu, 07 Jun 2018 23:54:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC5F44023156 for ; Fri, 8 Jun 2018 03:54:09 +0000 (UTC) Date: Fri, 8 Jun 2018 11:54:04 +0800 From: Peter Xu Message-ID: <20180608035404.GV750@xz-mi> References: <20180529055755.12404-1-peterx@redhat.com> <20180529055755.12404-6-peterx@redhat.com> <878t7qu0o9.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <878t7qu0o9.fsf@dusky.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH v9 5/7] monitor: remove event_clock_type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau On Thu, Jun 07, 2018 at 04:32:54PM +0200, Markus Armbruster wrote: > Peter Xu 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 > > Signed-off-by: Peter Xu > > --- > > 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