Received: from eggs.gnu.org ([2001:4830:134:3::10]:38239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brSMK-0005rn-UZ for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:14:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brSMI-0006yZ-3R for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:14:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brSMH-0006yG-TC for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:14:22 -0400 Date: Tue, 4 Oct 2016 13:14:18 -0300 From: Eduardo Habkost Message-ID: <20161004161417.GG3877@thinpad.lan.raisama.net> References: <20160930161013.9832-1-rkrcmar@redhat.com> <20160930161013.9832-2-rkrcmar@redhat.com> <20161003160333.GD3877@thinpad.lan.raisama.net> <20161004133801.GA23539@potion> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161004133801.GA23539@potion> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 1/8] apic: add global apic_get_class() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Peter Xu , Paolo Bonzini , Igor Mammedov , Richard Henderson On Tue, Oct 04, 2016 at 03:38:01PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: > 2016-10-03 13:03-0300, Eduardo Habkost: > > On Fri, Sep 30, 2016 at 06:10:06PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99= wrote: [...] > >> +static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) > >> +{ > >> + APICCommonState *apic; > >> + ObjectClass *apic_object_class =3D OBJECT_CLASS(apic_get_class(= )); > >> + > >> + assert(apic_object_class); > >> + cpu->apic_state =3D DEVICE(object_new_with_type(apic_object_cla= ss->type)); > >=20 > > ObjectClass::type is private. I believe the common idiom is > > object_new(object_class_get_name(c)). >=20 > Will fix in v4. >=20 > object_class_get_name() loses information about the type, so > object_new() has to look it up from the name, which is unnecessary. True. >=20 > Should I follow with a patch/series that adds >=20 > Object *object_new_with_class(ObjectClass *class) > { > return object_new_with_type(class->type); > } >=20 > into qom/object.[ch] and replaces occurrences of > object_new_with_type(object_class_get_name()) with it? I think that would be welcome. I don't know why it doesn't exist yet. --=20 Eduardo