mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdev: Fix qdev_try_create() semantics
Since QOM'ification, qdev_try_create() uses object_new() internally, which asserts "type != NULL" when the type is not registered. This was revealed by the combination of kvmclock's kvm_enabled() check and early QOM type registration. Check whether the class exists before calling object_new(), so that the caller (e.g., qdev_create) can fail gracefully, telling us which device could not be created. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <aliguori@codemonkey.ws> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
438e1c79f1
commit
4ed658ca92
1 changed files with 3 additions and 0 deletions
|
@ -117,6 +117,9 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)
|
|||
{
|
||||
DeviceState *dev;
|
||||
|
||||
if (object_class_by_name(name) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
dev = DEVICE(object_new(name));
|
||||
if (!dev) {
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue