From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOIzG-0008LN-2K for qemu-devel@nongnu.org; Thu, 31 May 2018 04:31:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOIzC-0007iI-V0 for qemu-devel@nongnu.org; Thu, 31 May 2018 04:31:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54116 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 1fOIzC-0007iC-Q4 for qemu-devel@nongnu.org; Thu, 31 May 2018 04:31:06 -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 4CAE376F91 for ; Thu, 31 May 2018 08:31:06 +0000 (UTC) Date: Thu, 31 May 2018 16:30:55 +0800 From: Peter Xu Message-ID: <20180531083055.GB14867@xz-mi> References: <20180529055755.12404-1-peterx@redhat.com> <20180529055755.12404-6-peterx@redhat.com> <20180530163552.GG5973@stefanha-x1.localdomain> <20180531041147.GK27442@xz-mi> <20180531082324.GB26429@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180531082324.GB26429@stefanha-x1.localdomain> 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: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Eric Blake , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Markus Armbruster , "Dr . David Alan Gilbert" On Thu, May 31, 2018 at 09:23:24AM +0100, Stefan Hajnoczi wrote: > On Thu, May 31, 2018 at 12:11:47PM +0800, Peter Xu wrote: > > On Wed, May 30, 2018 at 05:35:52PM +0100, Stefan Hajnoczi wrote: > > > On Tue, May 29, 2018 at 01:57:53PM +0800, Peter Xu wrote: > > > > 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. > > > > > > There is a hidden dependency: > > > > > > monitor_get_clock() returns the wrong value before main() has > > > processed command-line arguments. > > > > To be more explicit: > > > > monitor_get_clock() returns the wrong value before accelerator is > > correctly setup (in configure_accelerator()). > > > > Since the only thing that matters here is whether we're using the > > qtest accelerator. > > > > > > > > Where is the guarantee that monitor_get_clock() is never called too > > > early? > > > > You are right, there is no guarantee except from programming POV. > > It's only used in: > > > > monitor_qapi_event_queue > > monitor_qapi_event_handler > > > > These two functions will never be called until accelerator is setup. > > > > > > > > At the least, monitor_get_clock() should call abort(3) if invoked too > > > early. Even better would be an interface that cannot be used > > > incorrectly. > > > > Maybe then I should export the accel_initialised variable in > > configure_accelerator() and then I assert with that. But that'll > > further expand the series a bit. > > > > Or, I can also mention above in the commit message to explain that a > > bit. > > Documentation is okay, but please do it in the code, not the commit > message. That way anyone looking at monitor_get_clock() will be aware > of the constraint. Sure. -- Peter Xu