diff options
author | Amit Shah <amit.shah@redhat.com> | 2012-01-13 15:29:47 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-13 10:21:03 -0600 |
commit | a87f3e8b080205879232f34ff6977cb225b70e05 (patch) | |
tree | 48286f5ab9312d3bc618d4119297a9f8c30e4ede /hw | |
parent | 8600361542d64572ad24e04bc25c1ac42000d6d6 (diff) | |
download | qemu-a87f3e8b080205879232f34ff6977cb225b70e05.zip qemu-a87f3e8b080205879232f34ff6977cb225b70e05.tar.gz qemu-a87f3e8b080205879232f34ff6977cb225b70e05.tar.bz2 |
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: Qunfang Zhang <qzhang@redhat.com>
Fix-suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/qdev-properties.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 663c2a0..02f0dae 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -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 --- */ |