From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdgXl-00041Z-N6 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:15:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdgXj-00068S-8J for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:15:09 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39967 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdgXi-00066w-VB for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:15:07 -0500 Message-ID: <50B60046.1090308@suse.de> Date: Wed, 28 Nov 2012 13:15:02 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1354092873-11954-1-git-send-email-alevy@redhat.com> <20121128095456.1d032f4b@doriath.home> In-Reply-To: <20121128095456.1d032f4b@doriath.home> 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: Luiz Capitulino Cc: pbonzini@redhat.com, Alon Levy , qemu-devel@nongnu.org, armbru@redhat.com Am 28.11.2012 12:54, schrieb Luiz Capitulino: > On Wed, 28 Nov 2012 10:54:33 +0200 > Alon Levy wrote: >=20 >> 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")) { "device" should be TYPE_DEVICE. >> + qerror_report(QERR_INVALID_PARAMETER_TYPE, "driver", "device = type"); >> + return NULL; >> + } >=20 > Gives me the impression that something is wrong before this, but it's > better to ask a QOM guy (CC'ing them). What is definitely wrong here is the naming: "obj" is used for ObjectClass rather than Object. Therefore the use of object_class_dynamic_cast() is correct. I don't see an earlier place to error out. >=20 > How do you reproduce it btw? My guess is that trying to instantiate a non-device type needs to be caught before using the mentioned asserting DEVICE_CLASS() macro below. I.e. something like -device x86_64-cpu (non-abstract non-device type currently) on qemu-system-x86_64, or easier -device container. Regards, Andreas >=20 >> + >> k =3D DEVICE_CLASS(obj); >> =20 >> /* find bus */ >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg