From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8PSd-0005cT-V4 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 06:02:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8PSc-0000uL-VT for qemu-devel@nongnu.org; Thu, 02 Jun 2016 06:02:43 -0400 Date: Thu, 2 Jun 2016 12:02:29 +0200 From: Igor Mammedov Message-ID: <20160602120229.240bb47f@igors-macbook-pro.local> In-Reply-To: <20160601174651.GB13503@thinpad.lan.raisama.net> References: <1464799050-11002-1-git-send-email-imammedo@redhat.com> <1464799050-11002-3-git-send-email-imammedo@redhat.com> <20160601174651.GB13503@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 2/8] target-i386: cpu: move xcc->kvm_required check to reaize time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, rth@twiddle.net, blauwirbel@gmail.com, mark.cave-ayland@ilande.co.uk, qemu-arm@nongnu.org On Wed, 1 Jun 2016 14:46:51 -0300 Eduardo Habkost wrote: > On Wed, Jun 01, 2016 at 06:37:24PM +0200, Igor Mammedov wrote: > > it will allow to drop custom cpu_x86_init() and use > > cpu_generic_init() instead reducing cpu_x86_create() > > to a simple 3-liner. > > > > Signed-off-by: Igor Mammedov > > Nice, it also gets us closer to finally making X86CPU > qmp_device_list_properties()-safe. Only one request: > > > --- > > target-i386/cpu.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index 6159a7f..c31afc7 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -2200,7 +2200,6 @@ static void x86_cpu_load_def(X86CPU *cpu, > > X86CPUDefinition *def, Error **errp) X86CPU *cpu_x86_create(const > > char *cpu_model, Error **errp) { > > X86CPU *cpu = NULL; > > - X86CPUClass *xcc; > > ObjectClass *oc; > > gchar **model_pieces; > > char *name, *features; > > @@ -2219,12 +2218,6 @@ X86CPU *cpu_x86_create(const char > > *cpu_model, Error **errp) error_setg(&error, "Unable to find CPU > > definition: %s", name); goto out; > > } > > - xcc = X86_CPU_CLASS(oc); > > - > > - if (xcc->kvm_required && !kvm_enabled()) { > > - error_setg(&error, "CPU model '%s' requires KVM", name); > > - goto out; > > - } > > > > cpu = X86_CPU(object_new(object_class_get_name(oc))); > > > > @@ -2901,6 +2894,13 @@ static void x86_cpu_realizefn(DeviceState > > *dev, Error **errp) static bool ht_warned; > > FeatureWord w; > > > > + if (xcc->kvm_required && !kvm_enabled()) { > > + char *name = g_strdup(object_get_typename(OBJECT(dev))); > > + *strstr(name, X86_CPU_TYPE_SUFFIX) = 0; > > I am not sure if I actually like this trick, but in either case > please use x86_cpu_class_get_model_name(). thanks for pointing out that x86_cpu_class_get_model_name() exists. > > > + error_setg(&local_err, "CPU model '%s' requires KVM", > > name); > > + goto out; > > + } > > + > > if (cpu->apic_id < 0) { > > error_setg(errp, "apic-id property was not initialized > > properly"); return; > > -- > > 1.8.3.1 > > >