mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdev: Make DeviceState.id independent of QemuOpts
DeviceState.id is a pointer to a string that is stored in the QemuOpts object DeviceState.opts and freed together with it. We want to create devices without going through QemuOpts in the future, so make this a separately allocated string. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20211008133442.141332-9-kwolf@redhat.com> Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
c34efecedd
commit
163f384752
7 changed files with 9 additions and 7 deletions
|
@ -592,7 +592,8 @@ static BusState *qbus_find(const char *path, Error **errp)
|
|||
return bus;
|
||||
}
|
||||
|
||||
void qdev_set_id(DeviceState *dev, const char *id)
|
||||
/* Takes ownership of @id, will be freed when deleting the device */
|
||||
void qdev_set_id(DeviceState *dev, char *id)
|
||||
{
|
||||
if (id) {
|
||||
dev->id = id;
|
||||
|
@ -690,7 +691,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
qdev_set_id(dev, qemu_opts_id(opts));
|
||||
qdev_set_id(dev, g_strdup(qemu_opts_id(opts)));
|
||||
|
||||
/* set properties */
|
||||
if (qemu_opt_foreach(opts, set_property, dev, errp)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue