diff options
author | Hans de Goede <hdegoede@redhat.com> | 2011-03-18 15:30:45 +0100 |
---|---|---|
committer | Doug Goldstein <cardoe@cardoe.com> | 2011-07-21 15:18:45 -0500 |
commit | 909db97aac97750c207c30c3b77e6bb3f9604107 (patch) | |
tree | b30fdc01838b0e0706d73d6a767c13f4e8638230 | |
parent | chardev: Allow frontends to notify backends of guest open / close (diff) | |
download | qemu-kvm-909db97aac97750c207c30c3b77e6bb3f9604107.tar.gz qemu-kvm-909db97aac97750c207c30c3b77e6bb3f9604107.tar.bz2 qemu-kvm-909db97aac97750c207c30c3b77e6bb3f9604107.zip |
virtio-console: notify backend of guest open / close
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | hw/virtio-console.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/virtio-console.c b/hw/virtio-console.c index eecbdf75a..828a1a3ec 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -37,6 +37,22 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) return qemu_chr_write(vcon->chr, buf, len); } +/* Callback function that's called when the guest opens the port */ +static void guest_open(VirtIOSerialPort *port) +{ + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + qemu_chr_guest_open(vcon->chr); +} + +/* Callback function that's called when the guest closes the port */ +static void guest_close(VirtIOSerialPort *port) +{ + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + qemu_chr_guest_close(vcon->chr); +} + /* Readiness of the guest to accept data on a port */ static int chr_can_read(void *opaque) { @@ -81,6 +97,8 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev) if (vcon->chr) { qemu_chr_add_handlers(vcon->chr, &chr_handlers, vcon); vcon->port.info->have_data = flush_buf; + vcon->port.info->guest_open = guest_open; + vcon->port.info->guest_close = guest_close; } return 0; } |