* [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
@ 2013-04-09 12:53 fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 1/7] virtio-serial: add the virtio-serial device fred.konrad
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
This is the next part of virtio-refactoring.
Basically it creates virtio-serial device which extends virtio-device.
Then a virtio-serial can be connected on a virtio-bus.
virtio-serial-pci, virtio-serial-s390 and virtio-serial-ccw are created too,
they extend respectively virtio-pci, virtio-s390-device, virtio-ccw-device and
have a virtio-serial.
Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
You can checkout my branch here:
git://project.greensocs.com/qemu-virtio.git virtio-serial-v6
Note that it is nearly the same series as virtio-blk and virtio-scsi
refactoring.
I made basic tests (with linux guests) on:
* qemu-system-i386
Amit are you ok with that?
Changes v5 -> v6:
* Renamed device "virtio-serial" => "virtio-serial-device".
Changes v4 -> v5:
* Fixed rebase issue with nvector and the clarifying comment.
* Changed property macro for s390 and ccw device too.
Changes v3 -> v4:
* Removed serial configuration field ommited in VirtioCCWDevice structure.
Changes v2 -> v3:
* Added CCW device.
* Rebased.
Thanks,
Fred
KONRAD Frederic (7):
virtio-serial: add the virtio-serial device.
virtio-serial-pci: switch to the new API.
virtio-serial-s390: switch to the new API.
virtio-serial-ccw: switch to the new API.
virtio-serial: cleanup: init and exit functions.
virtio-serial: cleanup: use QOM casts.
virtio-serial: cleanup: remove qdev field.
hw/char/virtio-serial-bus.c | 157 ++++++++++++++++++++++----------------
hw/s390x/s390-virtio-bus.c | 31 +++++---
hw/s390x/s390-virtio-bus.h | 12 ++-
hw/s390x/virtio-ccw.c | 29 +++----
hw/s390x/virtio-ccw.h | 12 ++-
hw/virtio/virtio-pci.c | 131 ++++++++++++++++---------------
hw/virtio/virtio-pci.h | 14 +++-
include/hw/virtio/virtio-serial.h | 13 +++-
8 files changed, 239 insertions(+), 160 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 1/7] virtio-serial: add the virtio-serial device.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 2/7] virtio-serial-pci: switch to the new API fred.konrad
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
Create virtio-serial which extends virtio-device, so it can be connected
on virtio-bus.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/char/virtio-serial-bus.c | 95 ++++++++++++++++++++++++++++++++++++---
hw/s390x/s390-virtio-bus.c | 3 +-
hw/s390x/virtio-ccw.c | 3 +-
hw/virtio/virtio-pci.c | 2 +-
include/hw/virtio/virtio-serial.h | 9 ++++
5 files changed, 100 insertions(+), 12 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 1dba8ab..506377e 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -887,10 +887,12 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
return 0;
}
-VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
+static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
+ virtio_serial_conf *conf,
+ VirtIODevice **pvdev)
{
VirtIOSerial *vser;
- VirtIODevice *vdev;
+ VirtIODevice *vdev = *pvdev;
uint32_t i, max_supported_ports;
if (!conf->max_virtserial_ports)
@@ -904,11 +906,22 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
return NULL;
}
- vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
- sizeof(struct virtio_console_config),
- sizeof(VirtIOSerial));
-
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ /*
+ * We have two cases here: the old virtio-serial-pci device, and the
+ * refactored virtio-serial.
+ */
+ if (vdev == NULL) {
+ /* virtio-serial-pci */
+ vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
+ sizeof(struct virtio_console_config),
+ sizeof(VirtIOSerial));
+ vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ } else {
+ /* virtio-serial */
+ virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
+ sizeof(struct virtio_console_config));
+ vser = VIRTIO_SERIAL(vdev);
+ }
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, dev, NULL);
@@ -972,6 +985,16 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
return vdev;
}
+/*
+ * The two following functions will be cleaned up at the end.
+ */
+
+VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
+{
+ VirtIODevice *vdev = NULL;
+ return virtio_serial_common_init(dev, conf, &vdev);
+}
+
void virtio_serial_exit(VirtIODevice *vdev)
{
VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
@@ -1009,10 +1032,68 @@ static const TypeInfo virtio_serial_port_type_info = {
.class_init = virtio_serial_port_class_init,
};
+static int virtio_serial_device_init(VirtIODevice *vdev)
+{
+ DeviceState *qdev = DEVICE(vdev);
+ VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
+ virtio_serial_conf *conf = &(vser->serial);
+ if (virtio_serial_common_init(qdev, conf, &vdev) == NULL) {
+ return -1;
+ }
+ return 0;
+}
+
+static int virtio_serial_device_exit(DeviceState *dev)
+{
+ VirtIOSerial *vser = VIRTIO_SERIAL(dev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+
+ unregister_savevm(dev, "virtio-console", vser);
+
+ g_free(vser->ivqs);
+ g_free(vser->ovqs);
+ g_free(vser->ports_map);
+ if (vser->post_load) {
+ g_free(vser->post_load->connected);
+ qemu_del_timer(vser->post_load->timer);
+ qemu_free_timer(vser->post_load->timer);
+ g_free(vser->post_load);
+ }
+ virtio_common_cleanup(vdev);
+ return 0;
+}
+
+static Property virtio_serial_properties[] = {
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerial, serial),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_serial_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+ dc->exit = virtio_serial_device_exit;
+ dc->props = virtio_serial_properties;
+ vdc->init = virtio_serial_device_init;
+ vdc->get_features = get_features;
+ vdc->get_config = get_config;
+ vdc->set_config = set_config;
+ vdc->set_status = set_status;
+ vdc->reset = vser_reset;
+}
+
+static const TypeInfo virtio_device_info = {
+ .name = TYPE_VIRTIO_SERIAL,
+ .parent = TYPE_VIRTIO_DEVICE,
+ .instance_size = sizeof(VirtIOSerial),
+ .class_init = virtio_serial_class_init,
+};
+
static void virtio_serial_register_types(void)
{
type_register_static(&virtser_bus_info);
type_register_static(&virtio_serial_port_type_info);
+ type_register_static(&virtio_device_info);
}
type_init(virtio_serial_register_types)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index ddf15a2..6d857b9 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -465,8 +465,7 @@ static const TypeInfo s390_virtio_blk = {
};
static Property s390_virtio_serial_properties[] = {
- DEFINE_PROP_UINT32("max_ports", VirtIOS390Device,
- serial.max_virtserial_ports, 31),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOS390Device, serial),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 4dec0cd..817d11c 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -786,8 +786,7 @@ static const TypeInfo virtio_ccw_blk = {
static Property virtio_ccw_serial_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
- DEFINE_PROP_UINT32("max_ports", VirtioCcwDevice,
- serial.max_virtserial_ports, 31),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioCcwDevice, serial),
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 2b22588..434e76e 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1075,7 +1075,7 @@ static Property virtio_serial_properties[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy, serial.max_virtserial_ports, 31),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOPCIProxy, serial),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h
index 098deea..fbaf65f 100644
--- a/include/hw/virtio/virtio-serial.h
+++ b/include/hw/virtio/virtio-serial.h
@@ -210,6 +210,8 @@ struct VirtIOSerial {
struct virtio_console_config config;
struct VirtIOSerialPostLoad *post_load;
+
+ virtio_serial_conf serial;
};
/* Interface to the virtio-serial bus */
@@ -244,4 +246,11 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port);
*/
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle);
+#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)
+
#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 2/7] virtio-serial-pci: switch to the new API.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 1/7] virtio-serial: add the virtio-serial device fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 3/7] virtio-serial-s390: " fred.konrad
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
Here the virtio-serial-pci is modified for the new API. The device
virtio-serial-pci extends virtio-pci. It creates and connects a
virtio-serial during the init. The properties are not changed.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/virtio/virtio-pci.c | 131 ++++++++++++++++++++++++-------------------------
hw/virtio/virtio-pci.h | 14 +++++-
2 files changed, 78 insertions(+), 67 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 434e76e..c2a0452 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -942,40 +942,6 @@ static void virtio_exit_pci(PCIDevice *pci_dev)
msix_uninit_exclusive_bar(pci_dev);
}
-static int virtio_serial_init_pci(PCIDevice *pci_dev)
-{
- VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
- VirtIODevice *vdev;
-
- if (proxy->class_code != PCI_CLASS_COMMUNICATION_OTHER &&
- proxy->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */
- proxy->class_code != PCI_CLASS_OTHERS) /* qemu-kvm */
- proxy->class_code = PCI_CLASS_COMMUNICATION_OTHER;
-
- vdev = virtio_serial_init(&pci_dev->qdev, &proxy->serial);
- if (!vdev) {
- return -1;
- }
-
- /* backwards-compatibility with machines that were created with
- DEV_NVECTORS_UNSPECIFIED */
- vdev->nvectors = proxy->nvectors == DEV_NVECTORS_UNSPECIFIED
- ? proxy->serial.max_virtserial_ports + 1
- : proxy->nvectors;
- virtio_init_pci(proxy, vdev);
- proxy->nvectors = vdev->nvectors;
- return 0;
-}
-
-static void virtio_serial_exit_pci(PCIDevice *pci_dev)
-{
- VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
-
- virtio_pci_stop_ioeventfd(proxy);
- virtio_serial_exit(proxy->vdev);
- virtio_exit_pci(pci_dev);
-}
-
static int virtio_net_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
@@ -1070,37 +1036,6 @@ static const TypeInfo virtio_net_info = {
.class_init = virtio_net_class_init,
};
-static Property virtio_serial_properties[] = {
- DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
- DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
- DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
- DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOPCIProxy, serial),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void virtio_serial_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
- k->init = virtio_serial_init_pci;
- k->exit = virtio_serial_exit_pci;
- k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- k->device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE;
- k->revision = VIRTIO_PCI_ABI_VERSION;
- k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
- dc->reset = virtio_pci_reset;
- dc->props = virtio_serial_properties;
-}
-
-static const TypeInfo virtio_serial_info = {
- .name = "virtio-serial-pci",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(VirtIOPCIProxy),
- .class_init = virtio_serial_class_init,
-};
-
static void virtio_rng_initfn(Object *obj)
{
PCIDevice *pci_dev = PCI_DEVICE(obj);
@@ -1460,6 +1395,70 @@ static const TypeInfo virtio_balloon_pci_info = {
.class_init = virtio_balloon_pci_class_init,
};
+/* virtio-serial-pci */
+
+static int virtio_serial_pci_init(VirtIOPCIProxy *vpci_dev)
+{
+ VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(vpci_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+
+ if (vpci_dev->class_code != PCI_CLASS_COMMUNICATION_OTHER &&
+ vpci_dev->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */
+ vpci_dev->class_code != PCI_CLASS_OTHERS) { /* qemu-kvm */
+ vpci_dev->class_code = PCI_CLASS_COMMUNICATION_OTHER;
+ }
+
+ /* backwards-compatibility with machines that were created with
+ DEV_NVECTORS_UNSPECIFIED */
+ if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+ vpci_dev->nvectors = dev->vdev.serial.max_virtserial_ports + 1;
+ }
+
+ qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
+ if (qdev_init(vdev) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+static Property virtio_serial_pci_properties[] = {
+ DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+ VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
+ DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerialPCI, vdev.serial),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_serial_pci_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+ PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+ k->init = virtio_serial_pci_init;
+ dc->props = virtio_serial_pci_properties;
+ pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+ pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE;
+ pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
+ pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
+}
+
+static void virtio_serial_pci_instance_init(Object *obj)
+{
+ VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(obj);
+ object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL);
+ object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
+static const TypeInfo virtio_serial_pci_info = {
+ .name = TYPE_VIRTIO_SERIAL_PCI,
+ .parent = TYPE_VIRTIO_PCI,
+ .instance_size = sizeof(VirtIOSerialPCI),
+ .instance_init = virtio_serial_pci_instance_init,
+ .class_init = virtio_serial_pci_class_init,
+};
+
/* virtio-pci-bus */
void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev)
@@ -1499,7 +1498,6 @@ static const TypeInfo virtio_pci_bus_info = {
static void virtio_pci_register_types(void)
{
type_register_static(&virtio_net_info);
- type_register_static(&virtio_serial_info);
type_register_static(&virtio_rng_info);
type_register_static(&virtio_pci_bus_info);
type_register_static(&virtio_pci_info);
@@ -1509,6 +1507,7 @@ static void virtio_pci_register_types(void)
type_register_static(&virtio_blk_pci_info);
type_register_static(&virtio_scsi_pci_info);
type_register_static(&virtio_balloon_pci_info);
+ type_register_static(&virtio_serial_pci_info);
}
type_init(virtio_pci_register_types)
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index fb83155..879cc83 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -29,6 +29,7 @@ typedef struct VirtIOPCIProxy VirtIOPCIProxy;
typedef struct VirtIOBlkPCI VirtIOBlkPCI;
typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
+typedef struct VirtIOSerialPCI VirtIOSerialPCI;
/* virtio-pci-bus */
@@ -82,7 +83,6 @@ struct VirtIOPCIProxy {
#ifdef CONFIG_VIRTFS
V9fsConf fsconf;
#endif
- virtio_serial_conf serial;
virtio_net_conf net;
VirtIORNGConf rng;
bool ioeventfd_disabled;
@@ -130,6 +130,18 @@ struct VirtIOBalloonPCI {
VirtIOBalloon vdev;
};
+/*
+ * virtio-serial-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
+#define VIRTIO_SERIAL_PCI(obj) \
+ OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
+
+struct VirtIOSerialPCI {
+ VirtIOPCIProxy parent_obj;
+ VirtIOSerial vdev;
+};
+
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 3/7] virtio-serial-s390: switch to the new API.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 1/7] virtio-serial: add the virtio-serial device fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 2/7] virtio-serial-pci: switch to the new API fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 4/7] virtio-serial-ccw: " fred.konrad
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
Here the virtio-serial-s390 is modified for the new API. The device
virtio-serial-s390 extends virtio-s390-device as before. It creates and
connects a virtio-serial during the init. The properties are not
modified.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/s390x/s390-virtio-bus.c | 30 ++++++++++++++++++++----------
hw/s390x/s390-virtio-bus.h | 12 +++++++++++-
2 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 6d857b9..a71c145 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -181,27 +181,36 @@ static void s390_virtio_blk_instance_init(Object *obj)
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
}
-static int s390_virtio_serial_init(VirtIOS390Device *dev)
+static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
{
+ VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(s390_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+ DeviceState *qdev = DEVICE(s390_dev);
VirtIOS390Bus *bus;
- VirtIODevice *vdev;
int r;
- bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus);
+ bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus);
- vdev = virtio_serial_init((DeviceState *)dev, &dev->serial);
- if (!vdev) {
+ qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
+ if (qdev_init(vdev) < 0) {
return -1;
}
- r = s390_virtio_device_init(dev, vdev);
+ r = s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
if (!r) {
- bus->console = dev;
+ bus->console = s390_dev;
}
return r;
}
+static void s390_virtio_serial_instance_init(Object *obj)
+{
+ VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(obj);
+ object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL);
+ object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
{
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(s390_dev);
@@ -465,7 +474,7 @@ static const TypeInfo s390_virtio_blk = {
};
static Property s390_virtio_serial_properties[] = {
- DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOS390Device, serial),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerialS390, vdev.serial),
DEFINE_PROP_END_OF_LIST(),
};
@@ -479,9 +488,10 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo s390_virtio_serial = {
- .name = "virtio-serial-s390",
+ .name = TYPE_VIRTIO_SERIAL_S390,
.parent = TYPE_VIRTIO_S390_DEVICE,
- .instance_size = sizeof(VirtIOS390Device),
+ .instance_size = sizeof(VirtIOSerialS390),
+ .instance_init = s390_virtio_serial_instance_init,
.class_init = s390_virtio_serial_class_init,
};
diff --git a/hw/s390x/s390-virtio-bus.h b/hw/s390x/s390-virtio-bus.h
index c557132..1daf753 100644
--- a/hw/s390x/s390-virtio-bus.h
+++ b/hw/s390x/s390-virtio-bus.h
@@ -91,7 +91,6 @@ struct VirtIOS390Device {
VirtIODevice *vdev;
NICConf nic;
uint32_t host_features;
- virtio_serial_conf serial;
virtio_net_conf net;
VirtIORNGConf rng;
VirtioBusState bus;
@@ -141,4 +140,15 @@ typedef struct VirtIOSCSIS390 {
VirtIOSCSI vdev;
} VirtIOSCSIS390;
+/* virtio-serial-s390 */
+
+#define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
+#define VIRTIO_SERIAL_S390(obj) \
+ OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
+
+typedef struct VirtIOSerialS390 {
+ VirtIOS390Device parent_obj;
+ VirtIOSerial vdev;
+} VirtIOSerialS390;
+
#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 4/7] virtio-serial-ccw: switch to the new API.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (2 preceding siblings ...)
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 3/7] virtio-serial-s390: " fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 5/7] virtio-serial: cleanup: init and exit functions fred.konrad
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
Here the virtio-serial-ccw is modified for the new API. The device
virtio-serial-ccw extends virtio-ccw-device as before. It creates and
connects a virtio-serial during the init. The properties are not modified.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/s390x/virtio-ccw.c | 28 ++++++++++++++++------------
hw/s390x/virtio-ccw.h | 12 +++++++++++-
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 817d11c..9f2289d 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -590,22 +590,25 @@ static void virtio_ccw_blk_instance_init(Object *obj)
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
}
-static int virtio_ccw_serial_init(VirtioCcwDevice *dev)
+static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
{
- VirtIODevice *vdev;
+ VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
- vdev = virtio_serial_init((DeviceState *)dev, &dev->serial);
- if (!vdev) {
+ qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
+ if (qdev_init(vdev) < 0) {
return -1;
}
- return virtio_ccw_device_init(dev, vdev);
+ return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
}
-static int virtio_ccw_serial_exit(VirtioCcwDevice *dev)
+
+static void virtio_ccw_serial_instance_init(Object *obj)
{
- virtio_serial_exit(dev->vdev);
- return virtio_ccw_exit(dev);
+ VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj);
+ object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL);
+ object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
}
static int virtio_ccw_balloon_init(VirtioCcwDevice *ccw_dev)
@@ -786,7 +789,7 @@ static const TypeInfo virtio_ccw_blk = {
static Property virtio_ccw_serial_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
- DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioCcwDevice, serial),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioSerialCcw, vdev.serial),
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
DEFINE_PROP_END_OF_LIST(),
};
@@ -797,15 +800,16 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->init = virtio_ccw_serial_init;
- k->exit = virtio_ccw_serial_exit;
+ k->exit = virtio_ccw_exit;
dc->reset = virtio_ccw_reset;
dc->props = virtio_ccw_serial_properties;
}
static const TypeInfo virtio_ccw_serial = {
- .name = "virtio-serial-ccw",
+ .name = TYPE_VIRTIO_SERIAL_CCW,
.parent = TYPE_VIRTIO_CCW_DEVICE,
- .instance_size = sizeof(VirtioCcwDevice),
+ .instance_size = sizeof(VirtioSerialCcw),
+ .instance_init = virtio_ccw_serial_instance_init,
.class_init = virtio_ccw_serial_class_init,
};
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 46e9a55..2208a11 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -75,7 +75,6 @@ struct VirtioCcwDevice {
char *bus_id;
NICConf nic;
uint32_t host_features[VIRTIO_CCW_FEATURE_SIZE];
- virtio_serial_conf serial;
virtio_net_conf net;
VirtIORNGConf rng;
VirtioBusState bus;
@@ -127,6 +126,17 @@ typedef struct VirtIOBalloonCcw {
VirtIOBalloon vdev;
} VirtIOBalloonCcw;
+/* virtio-serial-ccw */
+
+#define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
+#define VIRTIO_SERIAL_CCW(obj) \
+ OBJECT_CHECK(VirtioSerialCcw, (obj), TYPE_VIRTIO_SERIAL_CCW)
+
+typedef struct VirtioSerialCcw {
+ VirtioCcwDevice parent_obj;
+ VirtIOSerial vdev;
+} VirtioSerialCcw;
+
VirtualCssBus *virtual_css_bus_init(void);
void virtio_ccw_device_update_status(SubchDev *sch);
VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 5/7] virtio-serial: cleanup: init and exit functions.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (3 preceding siblings ...)
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 4/7] virtio-serial-ccw: " fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 6/7] virtio-serial: cleanup: use QOM casts fred.konrad
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
This remove old init and exit function as they are no longer needed.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/char/virtio-serial-bus.c | 94 ++++++++++-----------------------------------
1 file changed, 21 insertions(+), 73 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 506377e..6dec044 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -887,51 +887,38 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
return 0;
}
-static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
- virtio_serial_conf *conf,
- VirtIODevice **pvdev)
+static int virtio_serial_device_init(VirtIODevice *vdev)
{
- VirtIOSerial *vser;
- VirtIODevice *vdev = *pvdev;
+ DeviceState *qdev = DEVICE(vdev);
+ VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
uint32_t i, max_supported_ports;
- if (!conf->max_virtserial_ports)
- return NULL;
+ if (!vser->serial.max_virtserial_ports) {
+ return -1;
+ }
/* Each port takes 2 queues, and one pair is for the control queue */
max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1;
- if (conf->max_virtserial_ports > max_supported_ports) {
+ if (vser->serial.max_virtserial_ports > max_supported_ports) {
error_report("maximum ports supported: %u", max_supported_ports);
- return NULL;
+ return -1;
}
- /*
- * We have two cases here: the old virtio-serial-pci device, and the
- * refactored virtio-serial.
- */
- if (vdev == NULL) {
- /* virtio-serial-pci */
- vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
- sizeof(struct virtio_console_config),
- sizeof(VirtIOSerial));
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
- } else {
- /* virtio-serial */
- virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
- sizeof(struct virtio_console_config));
- vser = VIRTIO_SERIAL(vdev);
- }
+ virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
+ sizeof(struct virtio_console_config));
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
- qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, dev, NULL);
+ qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev, NULL);
vser->bus.qbus.allow_hotplug = 1;
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
- vser->bus.max_nr_ports = conf->max_virtserial_ports;
- vser->ivqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
- vser->ovqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
+ vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
+ vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
+ * sizeof(VirtQueue *));
+ vser->ovqs = g_malloc(vser->serial.max_virtserial_ports
+ * sizeof(VirtQueue *));
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
@@ -956,8 +943,8 @@ static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
- vser->config.max_nr_ports = tswap32(conf->max_virtserial_ports);
- vser->ports_map = g_malloc0(((conf->max_virtserial_ports + 31) / 32)
+ vser->config.max_nr_ports = tswap32(vser->serial.max_virtserial_ports);
+ vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
/*
* Reserve location 0 for a console port for backward compat
@@ -971,7 +958,7 @@ static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
vser->vdev.set_status = set_status;
vser->vdev.reset = vser_reset;
- vser->qdev = dev;
+ vser->qdev = qdev;
vser->post_load = NULL;
@@ -979,38 +966,10 @@ static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
* Register for the savevm section with the virtio-console name
* to preserve backward compat
*/
- register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
+ register_savevm(qdev, "virtio-console", -1, 3, virtio_serial_save,
virtio_serial_load, vser);
- return vdev;
-}
-
-/*
- * The two following functions will be cleaned up at the end.
- */
-
-VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
-{
- VirtIODevice *vdev = NULL;
- return virtio_serial_common_init(dev, conf, &vdev);
-}
-
-void virtio_serial_exit(VirtIODevice *vdev)
-{
- VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
-
- unregister_savevm(vser->qdev, "virtio-console", vser);
-
- g_free(vser->ivqs);
- g_free(vser->ovqs);
- g_free(vser->ports_map);
- if (vser->post_load) {
- g_free(vser->post_load->connected);
- qemu_del_timer(vser->post_load->timer);
- qemu_free_timer(vser->post_load->timer);
- g_free(vser->post_load);
- }
- virtio_cleanup(vdev);
+ return 0;
}
static void virtio_serial_port_class_init(ObjectClass *klass, void *data)
@@ -1032,17 +991,6 @@ static const TypeInfo virtio_serial_port_type_info = {
.class_init = virtio_serial_port_class_init,
};
-static int virtio_serial_device_init(VirtIODevice *vdev)
-{
- DeviceState *qdev = DEVICE(vdev);
- VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
- virtio_serial_conf *conf = &(vser->serial);
- if (virtio_serial_common_init(qdev, conf, &vdev) == NULL) {
- return -1;
- }
- return 0;
-}
-
static int virtio_serial_device_exit(DeviceState *dev)
{
VirtIOSerial *vser = VIRTIO_SERIAL(dev);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 6/7] virtio-serial: cleanup: use QOM casts.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (4 preceding siblings ...)
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 5/7] virtio-serial: cleanup: init and exit functions fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 7/7] virtio-serial: cleanup: remove qdev field fred.konrad
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
As the virtio-serial-pci and virtio-serial-s390 are switched to the new
API, we can use QOM casts.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/char/virtio-serial-bus.c | 50 ++++++++++++++++++++-------------------
include/hw/virtio/virtio-serial.h | 2 +-
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 6dec044..aabb36a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -53,7 +53,8 @@ static VirtIOSerialPort *find_port_by_vq(VirtIOSerial *vser, VirtQueue *vq)
static bool use_multiport(VirtIOSerial *vser)
{
- return vser->vdev.guest_features & (1 << VIRTIO_CONSOLE_F_MULTIPORT);
+ VirtIODevice *vdev = VIRTIO_DEVICE(vser);
+ return vdev->guest_features & (1 << VIRTIO_CONSOLE_F_MULTIPORT);
}
static size_t write_to_port(VirtIOSerialPort *port,
@@ -83,7 +84,7 @@ static size_t write_to_port(VirtIOSerialPort *port,
virtqueue_push(vq, &elem, len);
}
- virtio_notify(&port->vser->vdev, vq);
+ virtio_notify(VIRTIO_DEVICE(port->vser), vq);
return offset;
}
@@ -156,7 +157,7 @@ static void flush_queued_data(VirtIOSerialPort *port)
if (!virtio_queue_ready(port->ovq)) {
return;
}
- do_flush_queued_data(port, port->ovq, &port->vser->vdev);
+ do_flush_queued_data(port, port->ovq, VIRTIO_DEVICE(port->vser));
}
static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
@@ -175,7 +176,7 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
memcpy(elem.in_sg[0].iov_base, buf, len);
virtqueue_push(vq, &elem, len);
- virtio_notify(&vser->vdev, vq);
+ virtio_notify(VIRTIO_DEVICE(vser), vq);
return len;
}
@@ -214,7 +215,7 @@ int virtio_serial_close(VirtIOSerialPort *port)
* consume, reset the throttling flag and discard the data.
*/
port->throttled = false;
- discard_vq_data(port->ovq, &port->vser->vdev);
+ discard_vq_data(port->ovq, VIRTIO_DEVICE(port->vser));
send_control_event(port->vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 0);
@@ -237,11 +238,12 @@ ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
*/
size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
{
+ VirtIODevice *vdev = VIRTIO_DEVICE(port->vser);
VirtQueue *vq = port->ivq;
unsigned int bytes;
if (!virtio_queue_ready(vq) ||
- !(port->vser->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) ||
+ !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) ||
virtio_queue_empty(vq)) {
return 0;
}
@@ -391,7 +393,7 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
uint8_t *buf;
size_t len;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
len = 0;
buf = NULL;
@@ -424,7 +426,7 @@ static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
VirtIOSerial *vser;
VirtIOSerialPort *port;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
port = find_port_by_vq(vser, vq);
if (!port || !port->host_connected) {
@@ -446,7 +448,7 @@ static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIOSerial *vser;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
if (vser->bus.max_nr_ports > 1) {
features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
@@ -459,7 +461,7 @@ static void get_config(VirtIODevice *vdev, uint8_t *config_data)
{
VirtIOSerial *vser;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
memcpy(config_data, &vser->config, sizeof(struct virtio_console_config));
}
@@ -491,7 +493,7 @@ static void set_status(VirtIODevice *vdev, uint8_t status)
VirtIOSerial *vser;
VirtIOSerialPort *port;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
port = find_port_by_id(vser, 0);
if (port && !use_multiport(port->vser)
@@ -513,19 +515,19 @@ static void vser_reset(VirtIODevice *vdev)
{
VirtIOSerial *vser;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = VIRTIO_SERIAL(vdev);
guest_reset(vser);
}
static void virtio_serial_save(QEMUFile *f, void *opaque)
{
- VirtIOSerial *s = opaque;
+ VirtIOSerial *s = VIRTIO_SERIAL(opaque);
VirtIOSerialPort *port;
uint32_t nr_active_ports;
unsigned int i, max_nr_ports;
/* The virtio device */
- virtio_save(&s->vdev, f);
+ virtio_save(VIRTIO_DEVICE(s), f);
/* The config space */
qemu_put_be16s(f, &s->config.cols);
@@ -576,7 +578,7 @@ static void virtio_serial_save(QEMUFile *f, void *opaque)
static void virtio_serial_post_load_timer_cb(void *opaque)
{
uint32_t i;
- VirtIOSerial *s = opaque;
+ VirtIOSerial *s = VIRTIO_SERIAL(opaque);
VirtIOSerialPort *port;
uint8_t host_connected;
VirtIOSerialPortClass *vsc;
@@ -664,7 +666,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
{
- VirtIOSerial *s = opaque;
+ VirtIOSerial *s = VIRTIO_SERIAL(opaque);
uint32_t max_nr_ports, nr_active_ports, ports_map;
unsigned int i;
int ret;
@@ -674,7 +676,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
}
/* The virtio device */
- ret = virtio_load(&s->vdev, f);
+ ret = virtio_load(VIRTIO_DEVICE(s), f);
if (ret) {
return ret;
}
@@ -801,7 +803,7 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
assert(port);
/* Flush out any unconsumed buffers first */
- discard_vq_data(port->ovq, &port->vser->vdev);
+ discard_vq_data(port->ovq, VIRTIO_DEVICE(port->vser));
send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_REMOVE, 1);
}
@@ -865,7 +867,7 @@ static int virtser_port_qdev_init(DeviceState *qdev)
add_port(port->vser, port->id);
/* Send an update to the guest about this new port added */
- virtio_notify_config(&port->vser->vdev);
+ virtio_notify_config(VIRTIO_DEVICE(port->vser));
return ret;
}
@@ -952,11 +954,11 @@ static int virtio_serial_device_init(VirtIODevice *vdev)
*/
mark_port_added(vser, 0);
- vser->vdev.get_features = get_features;
- vser->vdev.get_config = get_config;
- vser->vdev.set_config = set_config;
- vser->vdev.set_status = set_status;
- vser->vdev.reset = vser_reset;
+ vdev->get_features = get_features;
+ vdev->get_config = get_config;
+ vdev->set_config = set_config;
+ vdev->set_status = set_status;
+ vdev->reset = vser_reset;
vser->qdev = qdev;
diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h
index fbaf65f..3808bc3 100644
--- a/include/hw/virtio/virtio-serial.h
+++ b/include/hw/virtio/virtio-serial.h
@@ -192,7 +192,7 @@ typedef struct VirtIOSerialPostLoad {
} VirtIOSerialPostLoad;
struct VirtIOSerial {
- VirtIODevice vdev;
+ VirtIODevice parent_obj;
VirtQueue *c_ivq, *c_ovq;
/* Arrays of ivqs and ovqs: one per port */
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v6 7/7] virtio-serial: cleanup: remove qdev field.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (5 preceding siblings ...)
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 6/7] virtio-serial: cleanup: use QOM casts fred.konrad
@ 2013-04-09 12:53 ` fred.konrad
2013-04-09 14:53 ` [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring Peter Maydell
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: fred.konrad @ 2013-04-09 12:53 UTC (permalink / raw)
To: aliguori, qemu-devel, amit.shah
Cc: cornelia.huck, peter.maydell, mark.burton, fred.konrad
From: KONRAD Frederic <fred.konrad@greensocs.com>
The qdev field is no longer needed, just drop it.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/char/virtio-serial-bus.c | 2 --
include/hw/virtio/virtio-serial.h | 2 --
2 files changed, 4 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index aabb36a..35c996d 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -960,8 +960,6 @@ static int virtio_serial_device_init(VirtIODevice *vdev)
vdev->set_status = set_status;
vdev->reset = vser_reset;
- vser->qdev = qdev;
-
vser->post_load = NULL;
/*
diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h
index 3808bc3..7c71304 100644
--- a/include/hw/virtio/virtio-serial.h
+++ b/include/hw/virtio/virtio-serial.h
@@ -200,8 +200,6 @@ struct VirtIOSerial {
VirtIOSerialBus bus;
- DeviceState *qdev;
-
QTAILQ_HEAD(, VirtIOSerialPort) ports;
/* bitmap for identifying active ports */
--
1.8.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (6 preceding siblings ...)
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 7/7] virtio-serial: cleanup: remove qdev field fred.konrad
@ 2013-04-09 14:53 ` Peter Maydell
2013-04-09 15:05 ` KONRAD Frédéric
2013-04-09 15:07 ` Anthony Liguori
2013-04-10 10:34 ` Amit Shah
2013-04-15 21:10 ` Anthony Liguori
9 siblings, 2 replies; 14+ messages in thread
From: Peter Maydell @ 2013-04-09 14:53 UTC (permalink / raw)
To: Anthony Liguori
Cc: amit.shah, cornelia.huck, mark.burton, qemu-devel,
KONRAD Frédéric
On 9 April 2013 13:53, <fred.konrad@greensocs.com> wrote:
> From: KONRAD Frederic <fred.konrad@greensocs.com>
>
> This is the next part of virtio-refactoring.
>
> Basically it creates virtio-serial device which extends virtio-device.
> Then a virtio-serial can be connected on a virtio-bus.
> virtio-serial-pci, virtio-serial-s390 and virtio-serial-ccw are created too,
> they extend respectively virtio-pci, virtio-s390-device, virtio-ccw-device and
> have a virtio-serial.
>
> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Note to Anthony -- the way Fred has put the R-b: tags in
his cover letter here seems to confuse your 'patches'
script. 'patches apply' applies the patches and adds these
tags to every patch in the series, but
patches list id:1365512016-21944-1-git-send-email-fred.konrad@greensocs.com
status:reviewed
produces no output.
I flag this up because this patch series will probably not appear
on your radar otherwise.
Fred: the usual convention is to put reviewed-by
tags on the patches themselves when resending, even
if the reviewers were lazy and replied to the coverletter.
thanks
-- PMM
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 14:53 ` [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring Peter Maydell
@ 2013-04-09 15:05 ` KONRAD Frédéric
2013-04-09 15:07 ` Anthony Liguori
1 sibling, 0 replies; 14+ messages in thread
From: KONRAD Frédéric @ 2013-04-09 15:05 UTC (permalink / raw)
To: Peter Maydell
Cc: amit.shah, cornelia.huck, Anthony Liguori, mark.burton,
qemu-devel
On 09/04/2013 16:53, Peter Maydell wrote:
> On 9 April 2013 13:53, <fred.konrad@greensocs.com> wrote:
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> This is the next part of virtio-refactoring.
>>
>> Basically it creates virtio-serial device which extends virtio-device.
>> Then a virtio-serial can be connected on a virtio-bus.
>> virtio-serial-pci, virtio-serial-s390 and virtio-serial-ccw are created too,
>> they extend respectively virtio-pci, virtio-s390-device, virtio-ccw-device and
>> have a virtio-serial.
>>
>> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Note to Anthony -- the way Fred has put the R-b: tags in
> his cover letter here seems to confuse your 'patches'
> script. 'patches apply' applies the patches and adds these
> tags to every patch in the series, but
> patches list id:1365512016-21944-1-git-send-email-fred.konrad@greensocs.com
> status:reviewed
>
> produces no output.
>
> I flag this up because this patch series will probably not appear
> on your radar otherwise.
>
> Fred: the usual convention is to put reviewed-by
> tags on the patches themselves when resending, even
> if the reviewers were lazy and replied to the coverletter.
>
> thanks
> -- PMM
Sorry for that, I'm not too aware of this patches scripts and thought it
had the same result.
Do you want me to resend with the r-b tags inside each patches?
Fred
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 14:53 ` [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring Peter Maydell
2013-04-09 15:05 ` KONRAD Frédéric
@ 2013-04-09 15:07 ` Anthony Liguori
2013-04-09 15:20 ` Peter Maydell
1 sibling, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2013-04-09 15:07 UTC (permalink / raw)
To: Peter Maydell
Cc: amit.shah, cornelia.huck, mark.burton, qemu-devel,
KONRAD Frédéric
Peter Maydell <peter.maydell@linaro.org> writes:
> On 9 April 2013 13:53, <fred.konrad@greensocs.com> wrote:
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> This is the next part of virtio-refactoring.
>>
>> Basically it creates virtio-serial device which extends virtio-device.
>> Then a virtio-serial can be connected on a virtio-bus.
>> virtio-serial-pci, virtio-serial-s390 and virtio-serial-ccw are created too,
>> they extend respectively virtio-pci, virtio-s390-device, virtio-ccw-device and
>> have a virtio-serial.
>>
>> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> Note to Anthony -- the way Fred has put the R-b: tags in
> his cover letter here seems to confuse your 'patches'
> script. 'patches apply' applies the patches and adds these
> tags to every patch in the series, but
> patches list id:1365512016-21944-1-git-send-email-fred.konrad@greensocs.com
> status:reviewed
>
> produces no output.
I think you need to update your patches install because it works for me:
$ patches list id:1365512016-21944-1-git-send-email-fred.konrad@greensocs.com status:reviewed
Message-id: 1365512016-21944-1-git-send-email-fred.konrad@greensocs.com
From: <fred.konrad@greensocs.com>
Date: 2013-04-09
Tags: v6
[0/7] virtio-serial refactoring.
[1/7] virtio-serial: add the virtio-serial device.
[2/7] virtio-serial-pci: switch to the new API.
[3/7] virtio-serial-s390: switch to the new API.
[4/7] virtio-serial-ccw: switch to the new API.
[5/7] virtio-serial: cleanup: init and exit functions.
[6/7] virtio-serial: cleanup: use QOM casts.
[7/7] virtio-serial: cleanup: remove qdev field.
Regards,
Anthony Liguori
>
> I flag this up because this patch series will probably not appear
> on your radar otherwise.
>
> Fred: the usual convention is to put reviewed-by
> tags on the patches themselves when resending, even
> if the reviewers were lazy and replied to the coverletter.
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 15:07 ` Anthony Liguori
@ 2013-04-09 15:20 ` Peter Maydell
0 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2013-04-09 15:20 UTC (permalink / raw)
To: Anthony Liguori
Cc: amit.shah, cornelia.huck, mark.burton, qemu-devel,
KONRAD Frédéric
On 9 April 2013 16:07, Anthony Liguori <aliguori@us.ibm.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>> patches list id:1365512016-21944-1-git-send-email-fred.konrad@greensocs.com
>> status:reviewed
>>
>> produces no output.
>
> I think you need to update your patches install because it works for me:
Doh. I had done a git pull but forgot to rerun the install script.
Apologies for the noise.
-- PMM
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (7 preceding siblings ...)
2013-04-09 14:53 ` [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring Peter Maydell
@ 2013-04-10 10:34 ` Amit Shah
2013-04-15 21:10 ` Anthony Liguori
9 siblings, 0 replies; 14+ messages in thread
From: Amit Shah @ 2013-04-10 10:34 UTC (permalink / raw)
To: fred.konrad
Cc: cornelia.huck, peter.maydell, aliguori, mark.burton, qemu-devel
On (Tue) 09 Apr 2013 [14:53:29], fred.konrad@greensocs.com wrote:
> From: KONRAD Frederic <fred.konrad@greensocs.com>
>
> This is the next part of virtio-refactoring.
>
> Basically it creates virtio-serial device which extends virtio-device.
> Then a virtio-serial can be connected on a virtio-bus.
> virtio-serial-pci, virtio-serial-s390 and virtio-serial-ccw are created too,
> they extend respectively virtio-pci, virtio-s390-device, virtio-ccw-device and
> have a virtio-serial.
>
> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> You can checkout my branch here:
>
> git://project.greensocs.com/qemu-virtio.git virtio-serial-v6
>
> Note that it is nearly the same series as virtio-blk and virtio-scsi
> refactoring.
>
> I made basic tests (with linux guests) on:
> * qemu-system-i386
>
> Amit are you ok with that?
Thanks, this looks good.
Acked-by: Amit Shah <amit.shah@redhat.com>
Amit
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring.
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
` (8 preceding siblings ...)
2013-04-10 10:34 ` Amit Shah
@ 2013-04-15 21:10 ` Anthony Liguori
9 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2013-04-15 21:10 UTC (permalink / raw)
To: fred.konrad, aliguori, qemu-devel, amit.shah; +Cc: mark.burton, cornelia.huck
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-04-15 21:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 12:53 [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 1/7] virtio-serial: add the virtio-serial device fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 2/7] virtio-serial-pci: switch to the new API fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 3/7] virtio-serial-s390: " fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 4/7] virtio-serial-ccw: " fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 5/7] virtio-serial: cleanup: init and exit functions fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 6/7] virtio-serial: cleanup: use QOM casts fred.konrad
2013-04-09 12:53 ` [Qemu-devel] [PATCH v6 7/7] virtio-serial: cleanup: remove qdev field fred.konrad
2013-04-09 14:53 ` [Qemu-devel] [PATCH v6 0/7] virtio-serial refactoring Peter Maydell
2013-04-09 15:05 ` KONRAD Frédéric
2013-04-09 15:07 ` Anthony Liguori
2013-04-09 15:20 ` Peter Maydell
2013-04-10 10:34 ` Amit Shah
2013-04-15 21:10 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).