summaryrefslogtreecommitdiff
path: root/chardev/char-fe.c
diff options
context:
space:
mode:
authorAnton Nefedov <anton.nefedov@virtuozzo.com>2017-07-06 15:08:51 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2017-07-14 11:04:33 +0200
commit7c44a2a9d178118193febd71cfc6943dd21bdde9 (patch)
tree2206791e4494c36a2f70d3a020001910b9a79a9f /chardev/char-fe.c
parent7bb86085e61befc95551055e26645cb23c3f0b86 (diff)
downloadqemu-7c44a2a9d178118193febd71cfc6943dd21bdde9.tar.gz
char: forbid direct chardevice access for hotswap devices
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 <anton.nefedov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <1499342940-56739-5-git-send-email-anton.nefedov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'chardev/char-fe.c')
-rw-r--r--chardev/char-fe.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7054863208..de5ba3c119 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -179,9 +179,16 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
Chardev *qemu_chr_fe_get_driver(CharBackend *be)
{
+ /* this is unsafe for the users that support chardev hotswap */
+ assert(be->chr_be_change == NULL);
return be->chr;
}
+bool qemu_chr_fe_backend_connected(CharBackend *be)
+{
+ return !!be->chr;
+}
+
bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
{
int tag = 0;