diff options
author | Alon Levy <alevy@redhat.com> | 2010-08-01 18:18:36 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2010-08-25 14:37:15 +0300 |
commit | d148477b87200c4ea719f18d962ee880b4c123e3 (patch) | |
tree | d61e795f6d71559c48cf2ad185eada1acc98dd35 | |
parent | 6dd647ad45474ca98b62c1180abaf43d91a42e9b (diff) |
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.
-rw-r--r-- | hw/virtio-console.c | 31 | ||||
-rw-r--r-- | qemu-char.h | 4 |
2 files changed, 35 insertions, 0 deletions
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 |