virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
/*
|
|
|
|
* Virtio Serial / Console Support
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2008
|
2010-04-27 16:34:02 +04:00
|
|
|
* Copyright Red Hat, Inc. 2009, 2010
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
|
|
|
|
* Amit Shah <amit.shah@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _QEMU_VIRTIO_SERIAL_H
|
|
|
|
#define _QEMU_VIRTIO_SERIAL_H
|
|
|
|
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/qdev.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/virtio/virtio.h"
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
|
|
|
|
/* == Interface shared between the guest kernel and qemu == */
|
|
|
|
|
|
|
|
/* The Virtio ID for virtio console / serial ports */
|
|
|
|
#define VIRTIO_ID_CONSOLE 3
|
|
|
|
|
|
|
|
/* Features supported */
|
|
|
|
#define VIRTIO_CONSOLE_F_MULTIPORT 1
|
|
|
|
|
2010-04-27 16:33:59 +04:00
|
|
|
#define VIRTIO_CONSOLE_BAD_ID (~(uint32_t)0)
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
struct virtio_console_config {
|
|
|
|
/*
|
|
|
|
* These two fields are used by VIRTIO_CONSOLE_F_SIZE which
|
|
|
|
* isn't implemented here yet
|
|
|
|
*/
|
|
|
|
uint16_t cols;
|
|
|
|
uint16_t rows;
|
|
|
|
|
|
|
|
uint32_t max_nr_ports;
|
2011-08-31 14:38:01 +04:00
|
|
|
} QEMU_PACKED;
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
|
|
|
|
struct virtio_console_control {
|
|
|
|
uint32_t id; /* Port number */
|
|
|
|
uint16_t event; /* The kind of control event (see below) */
|
|
|
|
uint16_t value; /* Extra information for the key */
|
|
|
|
};
|
|
|
|
|
2011-02-03 08:52:32 +03:00
|
|
|
struct virtio_serial_conf {
|
|
|
|
/* Max. number of ports we can have for a virtio-serial device */
|
|
|
|
uint32_t max_virtserial_ports;
|
|
|
|
};
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
/* Some events for the internal messages (control packets) */
|
2010-04-27 16:33:59 +04:00
|
|
|
#define VIRTIO_CONSOLE_DEVICE_READY 0
|
|
|
|
#define VIRTIO_CONSOLE_PORT_ADD 1
|
|
|
|
#define VIRTIO_CONSOLE_PORT_REMOVE 2
|
|
|
|
#define VIRTIO_CONSOLE_PORT_READY 3
|
|
|
|
#define VIRTIO_CONSOLE_CONSOLE_PORT 4
|
|
|
|
#define VIRTIO_CONSOLE_RESIZE 5
|
|
|
|
#define VIRTIO_CONSOLE_PORT_OPEN 6
|
|
|
|
#define VIRTIO_CONSOLE_PORT_NAME 7
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
|
|
|
|
/* == In-qemu interface == */
|
|
|
|
|
2011-12-04 22:38:12 +04:00
|
|
|
#define TYPE_VIRTIO_SERIAL_PORT "virtio-serial-port"
|
|
|
|
#define VIRTIO_SERIAL_PORT(obj) \
|
|
|
|
OBJECT_CHECK(VirtIOSerialPort, (obj), TYPE_VIRTIO_SERIAL_PORT)
|
|
|
|
#define VIRTIO_SERIAL_PORT_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(VirtIOSerialPortClass, (klass), TYPE_VIRTIO_SERIAL_PORT)
|
|
|
|
#define VIRTIO_SERIAL_PORT_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(VirtIOSerialPortClass, (obj), TYPE_VIRTIO_SERIAL_PORT)
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
typedef struct VirtIOSerial VirtIOSerial;
|
|
|
|
typedef struct VirtIOSerialBus VirtIOSerialBus;
|
|
|
|
typedef struct VirtIOSerialPort VirtIOSerialPort;
|
2011-12-04 22:38:12 +04:00
|
|
|
|
|
|
|
typedef struct VirtIOSerialPortClass {
|
|
|
|
DeviceClass parent_class;
|
|
|
|
|
|
|
|
/* Is this a device that binds with hvc in the guest? */
|
|
|
|
bool is_console;
|
|
|
|
|
|
|
|
/*
|
2013-06-07 21:02:12 +04:00
|
|
|
* The per-port (or per-app) realize function that's called when a
|
2011-12-04 22:38:12 +04:00
|
|
|
* new device is found on the bus.
|
|
|
|
*/
|
2013-06-07 21:02:12 +04:00
|
|
|
DeviceRealize realize;
|
2011-12-04 22:38:12 +04:00
|
|
|
/*
|
2013-06-07 21:02:12 +04:00
|
|
|
* Per-port unrealize function that's called when a port gets
|
2011-12-04 22:38:12 +04:00
|
|
|
* hot-unplugged or removed.
|
|
|
|
*/
|
2013-06-07 21:02:12 +04:00
|
|
|
DeviceUnrealize unrealize;
|
2011-12-04 22:38:12 +04:00
|
|
|
|
|
|
|
/* Callbacks for guest events */
|
2013-03-26 14:08:01 +04:00
|
|
|
/* Guest opened/closed device. */
|
|
|
|
void (*set_guest_connected)(VirtIOSerialPort *port, int guest_connected);
|
2011-12-04 22:38:12 +04:00
|
|
|
|
|
|
|
/* Guest is now ready to accept data (virtqueues set up). */
|
|
|
|
void (*guest_ready)(VirtIOSerialPort *port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Guest wrote some data to the port. This data is handed over to
|
|
|
|
* the app via this callback. The app can return a size less than
|
|
|
|
* 'len'. In this case, throttling will be enabled for this port.
|
|
|
|
*/
|
|
|
|
ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf,
|
2013-04-05 13:30:19 +04:00
|
|
|
ssize_t len);
|
2011-12-04 22:38:12 +04:00
|
|
|
} VirtIOSerialPortClass;
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the state that's shared between all the ports. Some of the
|
|
|
|
* state is configurable via command-line options. Some of it can be
|
|
|
|
* set by individual devices in their initfn routines. Some of the
|
|
|
|
* state is set by the generic qdev device init routine.
|
|
|
|
*/
|
|
|
|
struct VirtIOSerialPort {
|
|
|
|
DeviceState dev;
|
|
|
|
|
|
|
|
QTAILQ_ENTRY(VirtIOSerialPort) next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This field gives us the virtio device as well as the qdev bus
|
|
|
|
* that we are associated with
|
|
|
|
*/
|
|
|
|
VirtIOSerial *vser;
|
|
|
|
|
|
|
|
VirtQueue *ivq, *ovq;
|
|
|
|
|
2010-01-19 22:06:54 +03:00
|
|
|
/*
|
|
|
|
* This name is sent to the guest and exported via sysfs.
|
|
|
|
* The guest could create symlinks based on this information.
|
|
|
|
* The name is in the reverse fqdn format, like org.qemu.console.0
|
|
|
|
*/
|
|
|
|
char *name;
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
/*
|
|
|
|
* This id helps identify ports between the guest and the host.
|
|
|
|
* The guest sends a "header" with this id with each data packet
|
|
|
|
* that it sends and the host can then find out which associated
|
|
|
|
* device to send out this data to
|
|
|
|
*/
|
|
|
|
uint32_t id;
|
|
|
|
|
2010-12-10 14:21:14 +03:00
|
|
|
/*
|
|
|
|
* This is the elem that we pop from the virtqueue. A slow
|
|
|
|
* backend that consumes guest data (e.g. the file backend for
|
|
|
|
* qemu chardevs) can cause the guest to block till all the output
|
|
|
|
* is flushed. This isn't desired, so we keep a note of the last
|
|
|
|
* element popped and continue consuming it once the backend
|
|
|
|
* becomes writable again.
|
|
|
|
*/
|
|
|
|
VirtQueueElement elem;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The index and the offset into the iov buffer that was popped in
|
|
|
|
* elem above.
|
|
|
|
*/
|
|
|
|
uint32_t iov_idx;
|
|
|
|
uint64_t iov_offset;
|
|
|
|
|
2011-04-29 15:25:06 +04:00
|
|
|
/*
|
|
|
|
* When unthrottling we use a bottom-half to call flush_queued_data.
|
|
|
|
*/
|
|
|
|
QEMUBH *bh;
|
|
|
|
|
2010-01-19 22:06:53 +03:00
|
|
|
/* Is the corresponding guest device open? */
|
|
|
|
bool guest_connected;
|
|
|
|
/* Is this device open for IO on the host? */
|
|
|
|
bool host_connected;
|
2010-04-27 16:34:11 +04:00
|
|
|
/* Do apps not want to receive data? */
|
|
|
|
bool throttled;
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
};
|
|
|
|
|
2013-03-18 20:37:18 +04:00
|
|
|
/* The virtio-serial bus on top of which the ports will ride as devices */
|
|
|
|
struct VirtIOSerialBus {
|
|
|
|
BusState qbus;
|
|
|
|
|
|
|
|
/* This is the parent device that provides the bus for ports. */
|
|
|
|
VirtIOSerial *vser;
|
|
|
|
|
|
|
|
/* The maximum number of ports that can ride on top of this bus */
|
|
|
|
uint32_t max_nr_ports;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct VirtIOSerialPostLoad {
|
|
|
|
QEMUTimer *timer;
|
|
|
|
uint32_t nr_active_ports;
|
|
|
|
struct {
|
|
|
|
VirtIOSerialPort *port;
|
|
|
|
uint8_t host_connected;
|
|
|
|
} *connected;
|
|
|
|
} VirtIOSerialPostLoad;
|
|
|
|
|
|
|
|
struct VirtIOSerial {
|
2013-04-09 16:53:35 +04:00
|
|
|
VirtIODevice parent_obj;
|
2013-03-18 20:37:18 +04:00
|
|
|
|
|
|
|
VirtQueue *c_ivq, *c_ovq;
|
|
|
|
/* Arrays of ivqs and ovqs: one per port */
|
|
|
|
VirtQueue **ivqs, **ovqs;
|
|
|
|
|
|
|
|
VirtIOSerialBus bus;
|
|
|
|
|
|
|
|
QTAILQ_HEAD(, VirtIOSerialPort) ports;
|
|
|
|
|
|
|
|
/* bitmap for identifying active ports */
|
|
|
|
uint32_t *ports_map;
|
|
|
|
|
|
|
|
struct virtio_console_config config;
|
|
|
|
|
|
|
|
struct VirtIOSerialPostLoad *post_load;
|
2013-04-09 16:53:30 +04:00
|
|
|
|
|
|
|
virtio_serial_conf serial;
|
2013-03-18 20:37:18 +04:00
|
|
|
};
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
/* Interface to the virtio-serial bus */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open a connection to the port
|
|
|
|
* Returns 0 on success (always).
|
|
|
|
*/
|
|
|
|
int virtio_serial_open(VirtIOSerialPort *port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close the connection to the port
|
|
|
|
* Returns 0 on success (always).
|
|
|
|
*/
|
|
|
|
int virtio_serial_close(VirtIOSerialPort *port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send data to Guest
|
|
|
|
*/
|
|
|
|
ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Query whether a guest is ready to receive data.
|
|
|
|
*/
|
|
|
|
size_t virtio_serial_guest_ready(VirtIOSerialPort *port);
|
|
|
|
|
2010-04-27 16:34:11 +04:00
|
|
|
/*
|
|
|
|
* Flow control: Ports can signal to the virtio-serial core to stop
|
|
|
|
* sending data or re-start sending data, depending on the 'throttle'
|
|
|
|
* value here.
|
|
|
|
*/
|
|
|
|
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle);
|
|
|
|
|
2013-04-09 16:53:30 +04:00
|
|
|
#define TYPE_VIRTIO_SERIAL "virtio-serial-device"
|
|
|
|
#define VIRTIO_SERIAL(obj) \
|
|
|
|
OBJECT_CHECK(VirtIOSerial, (obj), TYPE_VIRTIO_SERIAL)
|
|
|
|
|
|
|
|
#define DEFINE_VIRTIO_SERIAL_PROPERTIES(_state, _field) \
|
|
|
|
DEFINE_PROP_UINT32("max_ports", _state, _field.max_virtserial_ports, 31)
|
|
|
|
|
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.
The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.
This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.
As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using
-virtioconsole ...
is maintained, but the new, preferred way is to use
-device virtio-serial -device virtconsole,chardev=...
With this commit, multiple devices as well as multiple ports with a
single device can be supported.
For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.
In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.
This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19 22:06:52 +03:00
|
|
|
#endif
|