提交 a87f3e8b 编写于 作者: A Amit Shah 提交者: Anthony Liguori

qdev: Add a 'free' method to disassociate chardev from qdev device

When a device is removed, remove the association with a chardev, if any,
so that the chardev can be re-used later for other devices.
Reported-by: NQunfang Zhang <qzhang@redhat.com>
Fix-suggested-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NAmit Shah <amit.shah@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 86003615
......@@ -680,6 +680,16 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str)
return 0;
}
static void free_chr(DeviceState *dev, Property *prop)
{
CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
if (*ptr) {
qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL);
}
}
static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len)
{
CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
......@@ -699,6 +709,7 @@ PropertyInfo qdev_prop_chr = {
.print = print_chr,
.get = get_generic,
.set = set_generic,
.free = free_chr,
};
/* --- netdev device --- */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册