From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnMcJ-0008RL-7K for qemu-devel@nongnu.org; Fri, 23 Sep 2016 05:18:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnMcE-0001Kw-PI for qemu-devel@nongnu.org; Fri, 23 Sep 2016 05:17:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnMcE-0001Kb-IF for qemu-devel@nongnu.org; Fri, 23 Sep 2016 05:17:54 -0400 Date: Fri, 23 Sep 2016 17:17:49 +0800 From: Peter Xu Message-ID: <20160923091749.GA29144@pxdev.xzpeter.org> References: <20160922210432.18680-1-rkrcmar@redhat.com> <20160922210432.18680-2-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160922210432.18680-2-rkrcmar@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/5] 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: qemu-devel@nongnu.org, Igor Mammedov , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" On Thu, Sep 22, 2016 at 11:04:28PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: > Every configuration has only up to one APIC class and we'll be extendin= g > the class with a function that can be called without an instanced > object, so a direct access to the class is convenient. >=20 > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > hw/intc/apic_common.c | 14 ++++++++++++++ > include/hw/i386/apic_internal.h | 3 +++ > 2 files changed, 17 insertions(+) >=20 > diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c > index 14ac43c18666..86ef9c43e6df 100644 > --- a/hw/intc/apic_common.c > +++ b/hw/intc/apic_common.c > @@ -18,6 +18,7 @@ > * License along with this library; if not, see > */ > #include "qemu/osdep.h" > +#include "qemu/error-report.h" > #include "qapi/error.h" > #include "qemu-common.h" > #include "cpu.h" > @@ -296,6 +297,13 @@ static int apic_load_old(QEMUFile *f, void *opaque= , int version_id) > =20 > static const VMStateDescription vmstate_apic_common; > =20 > +APICCommonClass *apic_class; > + > +APICCommonClass *apic_get_class(void) > +{ > + return apic_class; > +} > + > static void apic_common_realize(DeviceState *dev, Error **errp) > { > APICCommonState *s =3D APIC_COMMON(dev); > @@ -306,6 +314,12 @@ static void apic_common_realize(DeviceState *dev, = Error **errp) > info =3D APIC_COMMON_GET_CLASS(s); > info->realize(dev, errp); > =20 > + if (apic_class && apic_class !=3D info) { > + error_report("All APICs must be of the same class."); > + exit(1); > + } Can user trigger this error? If not, I'd prefer: assert(!apic_class || apic_class =3D=3D info); Thanks, -- peterx