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>
This commit is contained in:
Amit Shah 2010-01-20 00:36:52 +05:30 committed by Anthony Liguori
parent bb61564c77
commit 98b19252cf
17 changed files with 809 additions and 213 deletions

View file

@ -26,7 +26,7 @@
#include "loader.h"
#include "elf.h"
#include "hw/virtio.h"
#include "hw/virtio-console.h"
#include "hw/virtio-serial.h"
#include "hw/sysbus.h"
#include "kvm.h"
@ -131,7 +131,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *dev)
return s390_virtio_device_init(dev, vdev);
}
static int s390_virtio_console_init(VirtIOS390Device *dev)
static int s390_virtio_serial_init(VirtIOS390Device *dev)
{
VirtIOS390Bus *bus;
VirtIODevice *vdev;
@ -139,7 +139,7 @@ static int s390_virtio_console_init(VirtIOS390Device *dev)
bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus);
vdev = virtio_console_init((DeviceState *)dev);
vdev = virtio_serial_init((DeviceState *)dev, dev->max_virtserial_ports);
if (!vdev) {
return -1;
}
@ -342,11 +342,14 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
},
};
static VirtIOS390DeviceInfo s390_virtio_console = {
.init = s390_virtio_console_init,
.qdev.name = "virtio-console-s390",
static VirtIOS390DeviceInfo s390_virtio_serial = {
.init = s390_virtio_serial_init,
.qdev.name = "virtio-serial-s390",
.qdev.alias = "virtio-serial",
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("max_ports", VirtIOS390Device, max_virtserial_ports,
31),
DEFINE_PROP_END_OF_LIST(),
},
};
@ -370,7 +373,7 @@ static void s390_virtio_bus_register_withprop(VirtIOS390DeviceInfo *info)
static void s390_virtio_register(void)
{
s390_virtio_bus_register_withprop(&s390_virtio_console);
s390_virtio_bus_register_withprop(&s390_virtio_serial);
s390_virtio_bus_register_withprop(&s390_virtio_blk);
s390_virtio_bus_register_withprop(&s390_virtio_net);
}