From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMglz-0008BP-1W for qemu-devel@nongnu.org; Sun, 09 Mar 2014 12:40:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMglu-0004KT-65 for qemu-devel@nongnu.org; Sun, 09 Mar 2014 12:40:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMglt-0004KL-UG for qemu-devel@nongnu.org; Sun, 09 Mar 2014 12:40:18 -0400 Date: Sun, 9 Mar 2014 18:40:18 +0200 From: "Michael S. Tsirkin" Message-ID: <20140309164018.GB8717@redhat.com> References: <1394215998-10830-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1394215998-10830-1-git-send-email-afaerber@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev: Fix bus dependency of DeviceState::hotpluggable getter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Igor Mammedov , qemu-devel@nongnu.org On Fri, Mar 07, 2014 at 07:13:18PM +0100, Andreas F=E4rber wrote: > Commit 1a37eca107cece3ed454bae29eef0bd1fac4a244 (qdev: add > "hotpluggable" property to Device) added a property "hotpluggable" to > each device, with its getter accessing parent_bus->allow_hotplug. >=20 > Add a NULL check. >=20 > Cc: Igor Mammedov > Signed-off-by: Andreas F=E4rber Fair enough but I'm guessing we should assume devices without a parent are not hotpluggable, should we not? Without a bus what handles hotplug? > --- > hw/core/qdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 749c83a..cb07863 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -735,7 +735,8 @@ static bool device_get_hotpluggable(Object *obj, Er= ror **err) > DeviceClass *dc =3D DEVICE_GET_CLASS(obj); > DeviceState *dev =3D DEVICE(obj); > =20 > - return dc->hotpluggable && dev->parent_bus->allow_hotplug; > + return dc->hotpluggable && (dev->parent_bus =3D=3D NULL || > + dev->parent_bus->allow_hotplug); So maybe this should be: > return dc->hotpluggable && dev->parent_bus && > dev->parent_bus->allow_hotplug; ? > } > =20 > static void device_initfn(Object *obj) > --=20 > 1.8.4.5