render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame qemu-virtio-serial-Add-a-virtserialport-device-for-gen.patch

amitshah 99a9ef
From fcb66d7ac2271bcf0b46d6b1ae2d3db38e78bf2b Mon Sep 17 00:00:00 2001
amitshah 99a9ef
From: Amit Shah <amit.shah@redhat.com>
amitshah 99a9ef
Date: Wed, 20 Jan 2010 00:36:56 +0530
amitshah 99a9ef
Subject: [PATCH 6/9] virtio-serial: Add a 'virtserialport' device for generic serial port support
amitshah 99a9ef
amitshah 99a9ef
This commit adds a simple chardev-based serial port. Any data the guest
amitshah 99a9ef
sends is forwarded to the chardev and vice-versa.
amitshah 99a9ef
amitshah 99a9ef
Sample uses for such a device can be obtaining info from the guest like
amitshah 99a9ef
the file systems used, apps installed, etc. for offline usage and
amitshah 99a9ef
logged-in users, clipboard copy-paste, etc. for online usage.
amitshah 99a9ef
amitshah 99a9ef
Signed-off-by: Amit Shah <amit.shah@redhat.com>
amitshah 99a9ef
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
amitshah 99a9ef
---
amitshah 99a9ef
 hw/virtio-serial.c |   34 ++++++++++++++++++++++++++++++++++
amitshah 99a9ef
 1 files changed, 34 insertions(+), 0 deletions(-)
amitshah 99a9ef
amitshah 99a9ef
diff --git a/hw/virtio-serial.c b/hw/virtio-serial.c
amitshah 99a9ef
index 9c2c93c..bd44ec6 100644
amitshah 99a9ef
--- a/hw/virtio-serial.c
amitshah 99a9ef
+++ b/hw/virtio-serial.c
amitshah 99a9ef
@@ -110,3 +110,37 @@ static void virtconsole_register(void)
amitshah 99a9ef
     virtio_serial_port_qdev_register(&virtconsole_info);
amitshah 99a9ef
 }
amitshah 99a9ef
 device_init(virtconsole_register)
amitshah 99a9ef
+
amitshah 99a9ef
+/* Generic Virtio Serial Ports */
amitshah 99a9ef
+static int virtserialport_initfn(VirtIOSerialDevice *dev)
amitshah 99a9ef
+{
amitshah 99a9ef
+    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
amitshah 99a9ef
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
amitshah 99a9ef
+
amitshah 99a9ef
+    port->info = dev->info;
amitshah 99a9ef
+
amitshah 99a9ef
+    if (vcon->chr) {
amitshah 99a9ef
+        qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
amitshah 99a9ef
+                              vcon);
amitshah 99a9ef
+        port->info->have_data = flush_buf;
amitshah 99a9ef
+    }
amitshah 99a9ef
+    return 0;
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+static VirtIOSerialPortInfo virtserialport_info = {
amitshah 99a9ef
+    .qdev.name     = "virtserialport",
amitshah 99a9ef
+    .qdev.size     = sizeof(VirtConsole),
amitshah 99a9ef
+    .init          = virtserialport_initfn,
amitshah 99a9ef
+    .exit          = virtconsole_exitfn,
amitshah 99a9ef
+    .qdev.props = (Property[]) {
amitshah 99a9ef
+        DEFINE_PROP_CHR("chardev", VirtConsole, chr),
amitshah 99a9ef
+        DEFINE_PROP_STRING("name", VirtConsole, port.name),
amitshah 99a9ef
+        DEFINE_PROP_END_OF_LIST(),
amitshah 99a9ef
+    },
amitshah 99a9ef
+};
amitshah 99a9ef
+
amitshah 99a9ef
+static void virtserialport_register(void)
amitshah 99a9ef
+{
amitshah 99a9ef
+    virtio_serial_port_qdev_register(&virtserialport_info);
amitshah 99a9ef
+}
amitshah 99a9ef
+device_init(virtserialport_register)
amitshah 99a9ef
-- 
amitshah 99a9ef
1.6.2.5
amitshah 99a9ef