From 7c44a2a9d178118193febd71cfc6943dd21bdde9 Mon Sep 17 00:00:00 2001 From: Anton Nefedov Date: Thu, 6 Jul 2017 15:08:51 +0300 Subject: char: forbid direct chardevice access for hotswap devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qemu_chr_fe_get_driver() is unsafe, frontends with hotswap support should not access CharDriver ptr directly as CharDriver might change. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Marc-André Lureau Message-Id: <1499342940-56739-5-git-send-email-anton.nefedov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- include/chardev/char-fe.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/chardev/char-fe.h') diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 9f38060c7e..588abed606 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -46,9 +46,19 @@ void qemu_chr_fe_deinit(CharBackend *b, bool del); * * Returns the driver associated with a CharBackend or NULL if no * associated Chardev. + * Note: avoid this function as the driver should never be accessed directly, + * especially by the frontends that support chardevice hotswap. + * Consider qemu_chr_fe_backend_connected() to check for driver existence */ Chardev *qemu_chr_fe_get_driver(CharBackend *be); +/** + * @qemu_chr_fe_backend_connected: + * + * Returns true if there is a chardevice associated with @be. + */ +bool qemu_chr_fe_backend_connected(CharBackend *be); + /** * @qemu_chr_fe_set_handlers: * @b: a CharBackend -- cgit v1.2.3