If the device can't be created, don't leak the QemuOpts and release the id of
the device that should have been added by the failed device_add.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
opts = qemu_opts_parse(&qemu_device_opts,
qdict_get_str(qdict, "config"), "driver");
- if (opts && !qdev_device_help(opts))
- qdev_device_add(opts);
+ if (opts) {
+ if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) {
+ qemu_opts_del(opts);
+ }
+ }
}
void do_device_del(Monitor *mon, const QDict *qdict)