Received: from eggs.gnu.org ([2001:4830:134:3::10]:46719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUg7K-00085v-60 for qemu-devel@nongnu.org; Wed, 26 Aug 2015 15:12:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUg7F-0004DL-3v for qemu-devel@nongnu.org; Wed, 26 Aug 2015 15:12:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUg7E-0004D1-Uc for qemu-devel@nongnu.org; Wed, 26 Aug 2015 15:12:09 -0400 Date: Wed, 26 Aug 2015 16:12:04 -0300 From: Eduardo Habkost Message-ID: <20150826191204.GB12753@thinpad.lan.raisama.net> References: <1440407824-30037-1-git-send-email-pl@kamp.de> <20150826155404.GH4230@thinpad.lan.raisama.net> <55DE07AB.9040401@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55DE07AB.9040401@kamp.de> Subject: Re: [Qemu-devel] [PATCH] target-i386: add a list of enforceable CPU models to the help output List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Michael Mueller , qemu-devel@nongnu.org, David Hildenbrand , pbonzini@redhat.com, afaerber@suse.de, rth@twiddle.net On Wed, Aug 26, 2015 at 08:38:35PM +0200, Peter Lieven wrote: > Am 26.08.2015 um 17:54 schrieb Eduardo Habkost: > > On Mon, Aug 24, 2015 at 11:17:04AM +0200, Peter Lieven wrote: > >> this patch adds a probe that lists all enforceable and migrateable > >> CPU models to the -cpu help output. The idea is to know a priory > >> which CPU modules can be exposed to the user without loosing any > >> feature flags. > >> > >> Signed-off-by: Peter Lieven > > [...] > >> +/* > >> + * Check if the CPU Definition is enforcable on the current host CPU > >> + * and contains no unmigratable flags. > >> + * > >> + * Returns: true if the CPU can be enforced and migrated. > >> + */ > >> +static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def) > >> +{ > >> + int i; > >> + for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) { > >> + FeatureWordInfo *fw = &feature_word_info[i]; > >> + uint32_t eax, ebx, ecx, edx, host; > >> + host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx); > > This isn't how you check if the CPU model can run in "enforce" mode. > > Please read x86_cpu_filter_features(). > > I did, but will do again. The problem is that x86_cpu_filter_features > requires enabled KVM to run. You don't have any choice: you need to initialize KVM to be able to report correct results. See this: http://article.gmane.org/gmane.comp.emulators.kvm.devel/133288 and the rest of the "s390x cpu model implementation" threads for some information about accel object creation, and what's needed. > I believed internally it does something > similar to what I do here. It doesn't. Please read the code. > > > > > Also, you can't tell if a CPU model is runnable in enforce mode unless > > you know what's the accelerator being used (see > > x86_cpu_filter_features()). How do you suggest we show > > accelerator-specific information in help output? > > > > The subject was missing that the goal was to list enforceable models > in KVM mode. The output of the help page mentions this. There are zero mentions to KVM in x86_cpu_enforce_and_migratable(). If the code is KVM-specific, please name functions and comment the code accordingly. > > Andreas suggested to make annotations to the list of CPU models. > In theory it would be possible to have different annotations for different > accelerators. That's one possible way to implement it, but maybe there's no need to make the code more complex for that. We can't check if the CPU model is runnable at class_init time, anyway, and re-running the runnability-check code in case the query is made multiple times won't be be a problem. -- Eduardo