From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2nZY-0003n1-Aq for qemu-devel@nongnu.org; Thu, 03 Jul 2014 16:25:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2nZS-0003yE-88 for qemu-devel@nongnu.org; Thu, 03 Jul 2014 16:25:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2nZR-0003y4-RY for qemu-devel@nongnu.org; Thu, 03 Jul 2014 16:25:30 -0400 Message-ID: <53B5BC36.2030507@redhat.com> Date: Thu, 03 Jul 2014 14:25:26 -0600 From: Eric Blake MIME-Version: 1.0 References: <1404416735-22371-1-git-send-email-ehabkost@redhat.com> <1404416735-22371-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1404416735-22371-3-git-send-email-ehabkost@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="N5LhXqBPXo3DwU0l1d84PnHLXDwH9x60g" Subject: Re: [Qemu-devel] [PATCH for-2.1 2/2] qdev: Fix crash when using non-device class name on -global List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org, =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Maydell , "Michael S. Tsirkin" , Markus Armbruster , Don Slutz , Paolo Bonzini , Igor Mammedov This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --N5LhXqBPXo3DwU0l1d84PnHLXDwH9x60g Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/03/2014 01:45 PM, Eduardo Habkost wrote: > This fixes the following crash: >=20 > $ qemu-system-x86_64 -global container.xxx=3Dy > hw/core/qdev-properties-system.c:399:qdev_add_one_global: Object 0x= 7f7eff234100 is not an instance of type device > Aborted (core dumped) >=20 > New behavior will be to just warn, just like when non-existing clas s/clas/class/ > names are used: >=20 > $ qemu-system-x86_64 -global container.xxx=3Dy > qemu-system-x86_64: Warning: "-global container.xxx=3Dy" not used >=20 > Signed-off-by: Eduardo Habkost > --- > hw/core/qdev-properties-system.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties= -system.c > index 8e140af..ae0900f 100644 > --- a/hw/core/qdev-properties-system.c > +++ b/hw/core/qdev-properties-system.c > @@ -394,7 +394,8 @@ static int qdev_add_one_global(QemuOpts *opts, void= *opaque) > g->driver =3D qemu_opt_get(opts, "driver"); > g->property =3D qemu_opt_get(opts, "property"); > g->value =3D qemu_opt_get(opts, "value"); > - oc =3D object_class_by_name(g->driver); > + oc =3D object_class_dynamic_cast(object_class_by_name(g->driver), > + TYPE_DEVICE); > if (oc) { > DeviceClass *dc =3D DEVICE_CLASS(oc); I'm not an expert on the type system, but this one looks simple enough that I don't mind: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --N5LhXqBPXo3DwU0l1d84PnHLXDwH9x60g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTtbw2AAoJEKeha0olJ0NqSgYIAK9OE/vEYL6HJ4W5UYvHyzJG AXmYfxCiQHDyvoHAjUCnTzRwiwUBaohCHqVzibmGEf7Vn/yjwK4Lhu7nVzfbXa1u 8GjdEVA7f0kGf84Sp95V1jrB4UQq3qTqo2TCwyg7gCbtxqnkTpdBVWF9bz9ST/z0 2/4GOiENw1+dQ3kmCtp0MQCAhop7N9q5kVWw6JOC5BesuaA4xc1ChFW3PsQjaRK6 10BfPzWUqkc20qpOgaoAgKJB8p6fcK6fDS+KVRP6yMAMJWDycz+VjABoCp/FBYk+ sYcdPsyapDjM23swqm2PlU8n6BDhNk8H89km8rLHhc7tP36GnHX6cOcYbsS+hF8= =NIAp -----END PGP SIGNATURE----- --N5LhXqBPXo3DwU0l1d84PnHLXDwH9x60g--