Received: from eggs.gnu.org ([208.118.235.92]:40957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tdgdl-0008SY-P9 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:21:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tdgdk-0007ik-I4 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:21:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tdgdk-0007ie-8q for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:21:20 -0500 Date: Wed, 28 Nov 2012 10:21:19 -0200 From: Luiz Capitulino Message-ID: <20121128102119.5de147f2@doriath.home> In-Reply-To: <50B60158.2000205@suse.de> References: <1354092873-11954-1-git-send-email-alevy@redhat.com> <20121128095456.1d032f4b@doriath.home> <50B5FD52.40209@redhat.com> <20121128101413.3530cf08@doriath.home> <50B60158.2000205@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?ISO-8859-1?B?RuRyYmVy?= Cc: Paolo Bonzini , Alon Levy , qemu-devel@nongnu.org, armbru@redhat.com On Wed, 28 Nov 2012 13:19:36 +0100 Andreas F=E4rber wrote: > Am 28.11.2012 13:14, schrieb Luiz Capitulino: > > On Wed, 28 Nov 2012 13:02:26 +0100 > > Paolo Bonzini wrote: > >=20 > >> Il 28/11/2012 12:54, Luiz Capitulino ha scritto: > >>> On Wed, 28 Nov 2012 10:54:33 +0200 > >>> Alon Levy wrote: > >>> > >>>> Instead of aborting immediately after at DEVICE_CLASS(obj) > >>>> > >>>> Signed-off-by: Alon Levy > >>>> --- > >>>> hw/qdev-monitor.c | 5 +++++ > >>>> 1 file changed, 5 insertions(+) > >>>> > >>>> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c > >>>> index 479eecd..3b70cdb 100644 > >>>> --- a/hw/qdev-monitor.c > >>>> +++ b/hw/qdev-monitor.c > >>>> @@ -426,6 +426,11 @@ DeviceState *qdev_device_add(QemuOpts *opts) > >>>> return NULL; > >>>> } > >>>> =20 > >>>> + if (!object_class_dynamic_cast(obj, "device")) { > >>>> + qerror_report(QERR_INVALID_PARAMETER_TYPE, "driver", "devic= e type"); > >>>> + return NULL; > >>>> + } > >>> > >>> Gives me the impression that something is wrong before this, but it's > >>> better to ask a QOM guy (CC'ing them). > >> > >> I would reuse the same error message as for "if (!obj)", and also use > >> TYPE_DEVICE instead of the hardcoded string, but the patch is ok. > >=20 > > It's a bit weird to me that you check for a condition and right next > > you also assert it (it's what DEVICE_CLASS() will do). But I'm not fami= liar > > with QOM, so I'll just trust you. >=20 > We could just as well do: >=20 > k =3D object_class_dynamic_cast(obj, TYPE_DEVICE); > if (k =3D=3D NULL) { > // do the error reporting > return ...; > } Yeah, was reaching this solution after some code reading :) >=20 > /* find bus */ > ... >=20 > Andreas >=20