From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8PX1-0000cr-09 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 06:07:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8PWy-0002bk-Qd for qemu-devel@nongnu.org; Thu, 02 Jun 2016 06:07:13 -0400 Date: Thu, 2 Jun 2016 12:06:59 +0200 From: Igor Mammedov Message-ID: <20160602120659.13aef452@igors-macbook-pro.local> In-Reply-To: <20160601185450.GG13503@thinpad.lan.raisama.net> References: <1464799050-11002-1-git-send-email-imammedo@redhat.com> <1464799050-11002-7-git-send-email-imammedo@redhat.com> <20160601185450.GG13503@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 6/8] cpu: use CPUClass->parse_features() as convertor to global properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, blauwirbel@gmail.com, qemu-arm@nongnu.org, pbonzini@redhat.com, rth@twiddle.net On Wed, 1 Jun 2016 15:54:50 -0300 Eduardo Habkost wrote: > On Wed, Jun 01, 2016 at 06:37:28PM +0200, Igor Mammedov wrote: > > Currently CPUClass->parse_features() is used to parse > > -cpu features string and set properties on created CPU > > instances. > > > > But considering that features specified -cpu apply to > > every created CPU instance, it doesn't make sence to > > parse the same features string for every CPU created. > > It also makes every target that cares about parsing > > features string explicitly call CPUClass->parse_features() > > parser, which gets in a way if we consider using > > generic device_add for CPU hotplug as device_add > > has not a clue about CPU specific hooks. > > > > Turns out we can use global properties mechanism to set > > properties on every created Device instance for a given > > type. That way it's possible to convert CPU features > > into a set of global properties for specified by > > -cpu cpu_model and common Device.device_post_init() > > will apply them to every cpu model model automaticaaly > > regardless whether it's manually created CPU or CPU > > created with help of device_add. > > > > Signed-off-by: Igor Mammedov > > --- > [...] > > -static void cpu_common_parse_features(CPUState *cpu, char > > *features, +static void cpu_common_parse_features(const char > > *typename, char *features, Error **errp) > > { > > char *featurestr; /* Single "key=value" string being parsed */ > > char *val; > > - Error *err = NULL; > > + static bool cpu_globals_initialized; > > + > > + if (cpu_globals_initialized) { > > + return; > > + } > > Should we replace this with assert(!cpu_globals_initialized) > after applying patch 8/8? assert might potentially break cpu_init() users, so I went safest route here.