summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-08-01 18:18:36 +0300
committerAlon Levy <alevy@redhat.com>2010-08-01 18:18:36 +0300
commitcaed03a3621c91aa69c79bf44b162cb443fc299d (patch)
tree36cbc8abe1a9ceb018a801a9d5929945e246e884
parent095e72a8d3b3601123d149beef750ffe3147a478 (diff)
virtio-console: add IOCTL's for guest_{ready,open,close}testpatch
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.c31
-rw-r--r--qemu-char.h4
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