dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame qemu-virtio-console-Rename-virtio-serial.c-back-to-virti.patch

amitshah 99a9ef
From 9c7f6b094950f7772068b957c795d76463cdeba0 Mon Sep 17 00:00:00 2001
amitshah 99a9ef
From: Amit Shah <amit.shah@redhat.com>
amitshah 99a9ef
Date: Thu, 21 Jan 2010 15:43:26 +0530
amitshah 99a9ef
Subject: [PATCH 9/9] virtio-console: Rename virtio-serial.c back to virtio-console.c
amitshah 99a9ef
amitshah 99a9ef
This file was renamed to ease the reviews of the recent changes
amitshah 99a9ef
that went in.
amitshah 99a9ef
amitshah 99a9ef
Now that the changes are done, rename the file back to its original
amitshah 99a9ef
name.
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
 Makefile.hw         |    2 +-
amitshah 99a9ef
 hw/virtio-console.c |  146 +++++++++++++++++++++++++++++++++++++++++++++++++++
amitshah 99a9ef
 hw/virtio-serial.c  |  146 ---------------------------------------------------
amitshah 99a9ef
 3 files changed, 147 insertions(+), 147 deletions(-)
amitshah 99a9ef
 create mode 100644 hw/virtio-console.c
amitshah 99a9ef
 delete mode 100644 hw/virtio-serial.c
amitshah 99a9ef
amitshah 99a9ef
diff --git a/Makefile.hw b/Makefile.hw
amitshah 99a9ef
index de8a0c5..43ca541 100644
amitshah 99a9ef
--- a/Makefile.hw
amitshah 99a9ef
+++ b/Makefile.hw
amitshah 99a9ef
@@ -13,7 +13,7 @@ QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu
amitshah 99a9ef
 
amitshah 99a9ef
 obj-y =
amitshah 99a9ef
 obj-y += loader.o
amitshah 99a9ef
-obj-y += virtio.o virtio-serial.o
amitshah 99a9ef
+obj-y += virtio.o virtio-console.o
amitshah 99a9ef
 obj-y += fw_cfg.o
amitshah 99a9ef
 obj-y += watchdog.o
amitshah 99a9ef
 obj-$(CONFIG_ECC) += ecc.o
amitshah 99a9ef
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
amitshah 99a9ef
new file mode 100644
amitshah 99a9ef
index 0000000..bd44ec6
amitshah 99a9ef
--- /dev/null
amitshah 99a9ef
+++ b/hw/virtio-console.c
amitshah 99a9ef
@@ -0,0 +1,146 @@
amitshah 99a9ef
+/*
amitshah 99a9ef
+ * Virtio Console and Generic Serial Port Devices
amitshah 99a9ef
+ *
amitshah 99a9ef
+ * Copyright Red Hat, Inc. 2009
amitshah 99a9ef
+ *
amitshah 99a9ef
+ * Authors:
amitshah 99a9ef
+ *  Amit Shah <amit.shah@redhat.com>
amitshah 99a9ef
+ *
amitshah 99a9ef
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
amitshah 99a9ef
+ * the COPYING file in the top-level directory.
amitshah 99a9ef
+ */
amitshah 99a9ef
+
amitshah 99a9ef
+#include "qemu-char.h"
amitshah 99a9ef
+#include "virtio-serial.h"
amitshah 99a9ef
+
amitshah 99a9ef
+typedef struct VirtConsole {
amitshah 99a9ef
+    VirtIOSerialPort port;
amitshah 99a9ef
+    CharDriverState *chr;
amitshah 99a9ef
+} VirtConsole;
amitshah 99a9ef
+
amitshah 99a9ef
+
amitshah 99a9ef
+/* Callback function that's called when the guest sends us data */
amitshah 99a9ef
+static size_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
amitshah 99a9ef
+{
amitshah 99a9ef
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
amitshah 99a9ef
+    ssize_t ret;
amitshah 99a9ef
+
amitshah 99a9ef
+    ret = qemu_chr_write(vcon->chr, buf, len);
amitshah 99a9ef
+
amitshah 99a9ef
+    return ret < 0 ? 0 : ret;
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+/* Readiness of the guest to accept data on a port */
amitshah 99a9ef
+static int chr_can_read(void *opaque)
amitshah 99a9ef
+{
amitshah 99a9ef
+    VirtConsole *vcon = opaque;
amitshah 99a9ef
+
amitshah 99a9ef
+    return virtio_serial_guest_ready(&vcon->port);
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+/* Send data from a char device over to the guest */
amitshah 99a9ef
+static void chr_read(void *opaque, const uint8_t *buf, int size)
amitshah 99a9ef
+{
amitshah 99a9ef
+    VirtConsole *vcon = opaque;
amitshah 99a9ef
+
amitshah 99a9ef
+    virtio_serial_write(&vcon->port, buf, size);
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+static void chr_event(void *opaque, int event)
amitshah 99a9ef
+{
amitshah 99a9ef
+    VirtConsole *vcon = opaque;
amitshah 99a9ef
+
amitshah 99a9ef
+    switch (event) {
amitshah 99a9ef
+    case CHR_EVENT_OPENED: {
amitshah 99a9ef
+        virtio_serial_open(&vcon->port);
amitshah 99a9ef
+        break;
amitshah 99a9ef
+    }
amitshah 99a9ef
+    case CHR_EVENT_CLOSED:
amitshah 99a9ef
+        virtio_serial_close(&vcon->port);
amitshah 99a9ef
+        break;
amitshah 99a9ef
+    }
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+/* Virtio Console Ports */
amitshah 99a9ef
+static int virtconsole_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
+    port->is_console = true;
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 int virtconsole_exitfn(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
+    if (vcon->chr) {
amitshah 99a9ef
+        port->info->have_data = NULL;
amitshah 99a9ef
+        qemu_chr_close(vcon->chr);
amitshah 99a9ef
+    }
amitshah 99a9ef
+
amitshah 99a9ef
+    return 0;
amitshah 99a9ef
+}
amitshah 99a9ef
+
amitshah 99a9ef
+static VirtIOSerialPortInfo virtconsole_info = {
amitshah 99a9ef
+    .qdev.name     = "virtconsole",
amitshah 99a9ef
+    .qdev.size     = sizeof(VirtConsole),
amitshah 99a9ef
+    .init          = virtconsole_initfn,
amitshah 99a9ef
+    .exit          = virtconsole_exitfn,
amitshah 99a9ef
+    .qdev.props = (Property[]) {
amitshah 99a9ef
+        DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1),
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 virtconsole_register(void)
amitshah 99a9ef
+{
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
diff --git a/hw/virtio-serial.c b/hw/virtio-serial.c
amitshah 99a9ef
deleted file mode 100644
amitshah 99a9ef
index bd44ec6..0000000
amitshah 99a9ef
--- a/hw/virtio-serial.c
amitshah 99a9ef
+++ /dev/null
amitshah 99a9ef
@@ -1,146 +0,0 @@
amitshah 99a9ef
-/*
amitshah 99a9ef
- * Virtio Console and Generic Serial Port Devices
amitshah 99a9ef
- *
amitshah 99a9ef
- * Copyright Red Hat, Inc. 2009
amitshah 99a9ef
- *
amitshah 99a9ef
- * Authors:
amitshah 99a9ef
- *  Amit Shah <amit.shah@redhat.com>
amitshah 99a9ef
- *
amitshah 99a9ef
- * This work is licensed under the terms of the GNU GPL, version 2.  See
amitshah 99a9ef
- * the COPYING file in the top-level directory.
amitshah 99a9ef
- */
amitshah 99a9ef
-
amitshah 99a9ef
-#include "qemu-char.h"
amitshah 99a9ef
-#include "virtio-serial.h"
amitshah 99a9ef
-
amitshah 99a9ef
-typedef struct VirtConsole {
amitshah 99a9ef
-    VirtIOSerialPort port;
amitshah 99a9ef
-    CharDriverState *chr;
amitshah 99a9ef
-} VirtConsole;
amitshah 99a9ef
-
amitshah 99a9ef
-
amitshah 99a9ef
-/* Callback function that's called when the guest sends us data */
amitshah 99a9ef
-static size_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
amitshah 99a9ef
-{
amitshah 99a9ef
-    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
amitshah 99a9ef
-    ssize_t ret;
amitshah 99a9ef
-
amitshah 99a9ef
-    ret = qemu_chr_write(vcon->chr, buf, len);
amitshah 99a9ef
-
amitshah 99a9ef
-    return ret < 0 ? 0 : ret;
amitshah 99a9ef
-}
amitshah 99a9ef
-
amitshah 99a9ef
-/* Readiness of the guest to accept data on a port */
amitshah 99a9ef
-static int chr_can_read(void *opaque)
amitshah 99a9ef
-{
amitshah 99a9ef
-    VirtConsole *vcon = opaque;
amitshah 99a9ef
-
amitshah 99a9ef
-    return virtio_serial_guest_ready(&vcon->port);
amitshah 99a9ef
-}
amitshah 99a9ef
-
amitshah 99a9ef
-/* Send data from a char device over to the guest */
amitshah 99a9ef
-static void chr_read(void *opaque, const uint8_t *buf, int size)
amitshah 99a9ef
-{
amitshah 99a9ef
-    VirtConsole *vcon = opaque;
amitshah 99a9ef
-
amitshah 99a9ef
-    virtio_serial_write(&vcon->port, buf, size);
amitshah 99a9ef
-}
amitshah 99a9ef
-
amitshah 99a9ef
-static void chr_event(void *opaque, int event)
amitshah 99a9ef
-{
amitshah 99a9ef
-    VirtConsole *vcon = opaque;
amitshah 99a9ef
-
amitshah 99a9ef
-    switch (event) {
amitshah 99a9ef
-    case CHR_EVENT_OPENED: {
amitshah 99a9ef
-        virtio_serial_open(&vcon->port);
amitshah 99a9ef
-        break;
amitshah 99a9ef
-    }
amitshah 99a9ef
-    case CHR_EVENT_CLOSED:
amitshah 99a9ef
-        virtio_serial_close(&vcon->port);
amitshah 99a9ef
-        break;
amitshah 99a9ef
-    }
amitshah 99a9ef
-}
amitshah 99a9ef
-
amitshah 99a9ef
-/* Virtio Console Ports */
amitshah 99a9ef
-static int virtconsole_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
-    port->is_console = true;
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 int virtconsole_exitfn(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
-    if (vcon->chr) {
amitshah 99a9ef
-        port->info->have_data = NULL;
amitshah 99a9ef
-        qemu_chr_close(vcon->chr);
amitshah 99a9ef
-    }
amitshah 99a9ef
-
amitshah 99a9ef
-    return 0;
amitshah 99a9ef
-}
amitshah 99a9ef
-
amitshah 99a9ef
-static VirtIOSerialPortInfo virtconsole_info = {
amitshah 99a9ef
-    .qdev.name     = "virtconsole",
amitshah 99a9ef
-    .qdev.size     = sizeof(VirtConsole),
amitshah 99a9ef
-    .init          = virtconsole_initfn,
amitshah 99a9ef
-    .exit          = virtconsole_exitfn,
amitshah 99a9ef
-    .qdev.props = (Property[]) {
amitshah 99a9ef
-        DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1),
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 virtconsole_register(void)
amitshah 99a9ef
-{
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