Re: [Qemu-devel] [PATCH v2 22/22] virtio: split virtio-serial bits rom virtio-pci

2018-08-16 Thread Thomas Huth
On 08/08/2018 01:48 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela 
> ---
>  hw/virtio/Makefile.objs   |  1 +
>  hw/virtio/virtio-pci.c| 74 --
>  hw/virtio/virtio-serial-pci.c | 97 +++
>  tests/Makefile.include| 12 ++---
>  4 files changed, 104 insertions(+), 80 deletions(-)
>  create mode 100644 hw/virtio/virtio-serial-pci.c
[...]
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index a1352ccefb..8666206ea4 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -143,7 +143,7 @@ check-unit-y += tests/test-crypto-secret$(EXESUF)
>  check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlscredsx509$(EXESUF)
>  check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlssession$(EXESUF)
>  ifneq (,$(findstring qemu-ga,$(TOOLS)))
> -check-unit-$(CONFIG_LINUX) += tests/test-qga$(EXESUF)
> +check-unit-$(land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += 
> tests/test-qga$(EXESUF)

Maybe mention qga's dependency in the patch description?

Anyway:
Reviewed-by: Thomas Huth 



[Qemu-devel] [PATCH v2 22/22] virtio: split virtio-serial bits rom virtio-pci

2018-08-08 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 hw/virtio/Makefile.objs   |  1 +
 hw/virtio/virtio-pci.c| 74 --
 hw/virtio/virtio-serial-pci.c | 97 +++
 tests/Makefile.include| 12 ++---
 4 files changed, 104 insertions(+), 80 deletions(-)
 create mode 100644 hw/virtio/virtio-serial-pci.c

diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs
index 0810553ab8..3d88b60d27 100644
--- a/hw/virtio/Makefile.objs
+++ b/hw/virtio/Makefile.objs
@@ -22,6 +22,7 @@ obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o
 obj-$(CONFIG_VIRTIO_SCSI) += virtio-scsi-pci.o
 obj-$(CONFIG_VIRTIO_BLK) += virtio-blk-pci.o
 obj-$(CONFIG_VIRTIO_NET) += virtio-net-pci.o
+obj-$(CONFIG_VIRTIO_SERIAL) += virtio-serial-pci.o
 endif
 
 common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO),$(CONFIG_LINUX))) += 
vhost-stub.o
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 589e565746..da5161a9a1 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1884,79 +1884,6 @@ static const TypeInfo virtio_pci_info = {
 },
 };
 
-/* virtio-serial-pci */
-
-static void virtio_serial_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
-{
-VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(vpci_dev);
-DeviceState *vdev = DEVICE(>vdev);
-DeviceState *proxy = DEVICE(vpci_dev);
-char *bus_name;
-
-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;
-}
-
-/*
- * For command line compatibility, this sets the virtio-serial-device bus
- * name as before.
- */
-if (proxy->id) {
-bus_name = g_strdup_printf("%s.0", proxy->id);
-virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
-g_free(bus_name);
-}
-
-qdev_set_parent_bus(vdev, BUS(_dev->bus));
-object_property_set_bool(OBJECT(vdev), true, "realized", errp);
-}
-
-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_UINT32("class", VirtIOPCIProxy, class_code, 0),
-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->realize = virtio_serial_pci_realize;
-set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
-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);
-
-virtio_instance_init_common(obj, >vdev, sizeof(dev->vdev),
-TYPE_VIRTIO_SERIAL);
-}
-
-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 */
 
 static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
@@ -2006,7 +1933,6 @@ static void virtio_pci_register_types(void)
 {
 type_register_static(_pci_bus_info);
 type_register_static(_pci_info);
-type_register_static(_serial_pci_info);
 }
 
 type_init(virtio_pci_register_types)
diff --git a/hw/virtio/virtio-serial-pci.c b/hw/virtio/virtio-serial-pci.c
new file mode 100644
index 00..453c6690fb
--- /dev/null
+++ b/hw/virtio/virtio-serial-pci.c
@@ -0,0 +1,97 @@
+/*
+ * Virtio serial PCI Bindings
+ *
+ * Copyright IBM, Corp. 2007
+ * Copyright (c) 2009 CodeSourcery
+ *
+ * Authors:
+ *  Anthony Liguori   
+ *  Paul Brook
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+#include "qemu/osdep.h"
+
+#include "virtio-pci.h"
+
+static void virtio_serial_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(vpci_dev);
+DeviceState *vdev =