qdev: Fix bus dependency of DeviceState::hotpluggable getter

Commit 1a37eca107 (qdev: add
"hotpluggable" property to Device) added a property "hotpluggable" to
each device, with its getter accessing parent_bus->allow_hotplug.

Add a NULL check.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2014-03-07 19:04:13 +01:00
parent 750036a848
commit 2b81b35f8f
1 changed files with 2 additions and 1 deletions

View File

@ -735,7 +735,8 @@ static bool device_get_hotpluggable(Object *obj, Error **err)
DeviceClass *dc = DEVICE_GET_CLASS(obj);
DeviceState *dev = DEVICE(obj);
return dc->hotpluggable && dev->parent_bus->allow_hotplug;
return dc->hotpluggable && (dev->parent_bus == NULL ||
dev->parent_bus->allow_hotplug);
}
static void device_initfn(Object *obj)