From caed03a3621c91aa69c79bf44b162cb443fc299d Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 1 Aug 2010 18:18:36 +0300 Subject: virtio-console: add IOCTL's for guest_{ready,open,close} Add three IOCTL corresponding to the three control events of: guest_ready -> CHR_IOCTL_VIRT_SERIAL_READY guest_open -> CHR_IOCTL_VIRT_SERIAL_OPEN guest_close -> CHR_IOCTL_VIRT_SERIAL_CLOSE Can be used by a matching backend. --- hw/virtio-console.c | 31 +++++++++++++++++++++++++++++++ qemu-char.h | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index caea11f3a..285e994ab 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -125,11 +125,42 @@ static int virtserialport_initfn(VirtIOSerialDevice *dev) return 0; } +static void virtconsole_guest_open(VirtIOSerialPort *port) +{ + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + if (vcon->chr) { + qemu_chr_ioctl(vcon->chr, CHR_IOCTL_VIRT_SERIAL_OPEN, NULL); + } +} + +static void virtconsole_guest_close(VirtIOSerialPort *port) +{ + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + if (vcon->chr) { + qemu_chr_ioctl(vcon->chr, CHR_IOCTL_VIRT_SERIAL_CLOSE, NULL); + } +} + +static void virtconsole_guest_ready(VirtIOSerialPort *port) +{ + VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); + + if (vcon->chr) { + qemu_chr_ioctl(vcon->chr, CHR_IOCTL_VIRT_SERIAL_READY, NULL); + } +} + + static VirtIOSerialPortInfo virtserialport_info = { .qdev.name = "virtserialport", .qdev.size = sizeof(VirtConsole), .init = virtserialport_initfn, .exit = virtconsole_exitfn, + .guest_open = virtconsole_guest_open, + .guest_close = virtconsole_guest_close, + .guest_ready = virtconsole_guest_ready, .qdev.props = (Property[]) { DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID), DEFINE_PROP_CHR("chardev", VirtConsole, chr), diff --git a/qemu-char.h b/qemu-char.h index e3a07838a..1df53ae4b 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -41,6 +41,10 @@ typedef struct { #define CHR_IOCTL_SERIAL_SET_TIOCM 13 #define CHR_IOCTL_SERIAL_GET_TIOCM 14 +#define CHR_IOCTL_VIRT_SERIAL_OPEN 15 +#define CHR_IOCTL_VIRT_SERIAL_CLOSE 16 +#define CHR_IOCTL_VIRT_SERIAL_READY 17 + #define CHR_TIOCM_CTS 0x020 #define CHR_TIOCM_CAR 0x040 #define CHR_TIOCM_DSR 0x100 -- cgit v1.2.3