diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2011-02-05 14:34:25 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2011-02-12 08:27:55 +0000 |
commit | 0bcdeda7e478f1ce1345585d8240e8d5a9b274d5 (patch) | |
tree | 473aa9888c343a78772c02e1cab27f47329a989b /hw/qdev.c | |
parent | 5c81e4ca9e5c11239a9db12f0f57c6c1e24b6760 (diff) | |
download | qemu-0bcdeda7e478f1ce1345585d8240e8d5a9b274d5.tar.gz qemu-0bcdeda7e478f1ce1345585d8240e8d5a9b274d5.tar.bz2 qemu-0bcdeda7e478f1ce1345585d8240e8d5a9b274d5.zip |
qdev: add creation function that may fail
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -106,6 +106,18 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) initialize the actual device emulation. */ DeviceState *qdev_create(BusState *bus, const char *name) { + DeviceState *dev; + + dev = qdev_try_create(bus, name); + if (!dev) { + hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); + } + + return dev; +} + +DeviceState *qdev_try_create(BusState *bus, const char *name) +{ DeviceInfo *info; if (!bus) { @@ -114,7 +126,7 @@ DeviceState *qdev_create(BusState *bus, const char *name) info = qdev_find_info(bus->info, name); if (!info) { - hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); + return NULL; } return qdev_create_from_info(bus, info); |