mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
virtio-console: Check if chardev backends available before calling into them
For the callback functions invoked by the virtio-serial-bus code, check if we have chardev backends registered before we call into the chardev functions. Signed-off-by: Amit Shah <amit.shah@redhat.com> Reported-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
3799ce4ab6
commit
6640422c17
1 changed files with 11 additions and 0 deletions
|
@ -27,6 +27,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
|
||||||
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (!vcon->chr) {
|
||||||
|
/* If there's no backend, we can just say we consumed all data. */
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
ret = qemu_chr_fe_write(vcon->chr, buf, len);
|
ret = qemu_chr_fe_write(vcon->chr, buf, len);
|
||||||
trace_virtio_console_flush_buf(port->id, len, ret);
|
trace_virtio_console_flush_buf(port->id, len, ret);
|
||||||
|
|
||||||
|
@ -52,6 +57,9 @@ static void guest_open(VirtIOSerialPort *port)
|
||||||
{
|
{
|
||||||
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
||||||
|
|
||||||
|
if (!vcon->chr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
qemu_chr_fe_open(vcon->chr);
|
qemu_chr_fe_open(vcon->chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +68,9 @@ static void guest_close(VirtIOSerialPort *port)
|
||||||
{
|
{
|
||||||
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
||||||
|
|
||||||
|
if (!vcon->chr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
qemu_chr_fe_close(vcon->chr);
|
qemu_chr_fe_close(vcon->chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue