From patchwork Mon Apr 29 15:12:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.konrad@greensocs.com X-Patchwork-Id: 240398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0AB592C009A for ; Tue, 30 Apr 2013 01:14:53 +1000 (EST) Received: from localhost ([::1]:50574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWpn1-0007Av-41 for incoming@patchwork.ozlabs.org; Mon, 29 Apr 2013 11:14:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWplS-00051G-P5 for qemu-devel@nongnu.org; Mon, 29 Apr 2013 11:13:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWplN-0001CE-RJ for qemu-devel@nongnu.org; Mon, 29 Apr 2013 11:13:14 -0400 Received: from greensocs.com ([87.106.252.221]:57816 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWplN-0001C6-AJ for qemu-devel@nongnu.org; Mon, 29 Apr 2013 11:13:09 -0400 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id D99A640EC61; Mon, 29 Apr 2013 15:13:08 +0000 (UTC) Received: from s15328186.onlinehome-server.info ([127.0.0.1]) by localhost (s15328186.onlinehome-server.info [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iwYqEOpHpqXR; Mon, 29 Apr 2013 17:13:05 +0200 (CEST) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id B6E8C40EC64; Mon, 29 Apr 2013 17:13:05 +0200 (CEST) Received: from localhost.localdomain (lan31-11-83-155-143-136.fbx.proxad.net [83.155.143.136]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id A429B40B250; Mon, 29 Apr 2013 17:13:04 +0200 (CEST) From: fred.konrad@greensocs.com To: aliguori@us.ibm.com, qemu-devel@nongnu.org Date: Mon, 29 Apr 2013 17:12:43 +0200 Message-Id: <1367248365-27260-3-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1367248365-27260-1-git-send-email-fred.konrad@greensocs.com> References: <1367248365-27260-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 87.106.252.221 Cc: peter.maydell@linaro.org, mark.burton@greensocs.com, agraf@suse.de, amit.shah@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH for-1.5 2/4] virtio-serial: fix command line compatibility. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: KONRAD Frederic The bus name is wrong since the refactoring. This keep the behaviour of the command line. Signed-off-by: KONRAD Frederic --- hw/char/virtio-serial-bus.c | 16 +++++++++++++++- hw/s390x/s390-virtio-bus.c | 8 ++++++++ hw/s390x/virtio-ccw.c | 9 +++++++++ hw/virtio/virtio-pci.c | 9 +++++++++ include/hw/virtio/virtio-serial.h | 8 ++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 3787ad2..0817041 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -889,6 +889,15 @@ static int virtser_port_qdev_exit(DeviceState *qdev) return 0; } +void set_virtio_serial_bus_name(DeviceState *dev, const char *bus_name) +{ + VirtIOSerial *vser = VIRTIO_SERIAL(dev); + if (bus_name) { + vser->bus_name = g_malloc(strlen(bus_name) + 3); + snprintf(vser->bus_name, strlen(bus_name) + 3, "%s.0", bus_name); + } +} + static int virtio_serial_device_init(VirtIODevice *vdev) { DeviceState *qdev = DEVICE(vdev); @@ -911,7 +920,8 @@ static int virtio_serial_device_init(VirtIODevice *vdev) 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, qdev, NULL); + qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev, + vser->bus_name); vser->bus.qbus.allow_hotplug = 1; vser->bus.vser = vser; QTAILQ_INIT(&vser->ports); @@ -992,6 +1002,10 @@ static int virtio_serial_device_exit(DeviceState *dev) unregister_savevm(dev, "virtio-console", vser); + if (vser->bus_name) { + g_free(vser->bus_name); + } + g_free(vser->ivqs); g_free(vser->ovqs); g_free(vser->ports_map); diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index d52a547..6620d29 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -200,6 +200,14 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev) bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus); + /* + * For command line compatibility, this set the virtio-serial-device bus + * name as before. + */ + if (qdev->id) { + set_virtio_serial_bus_name(vdev, qdev->id); + } + qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)); if (qdev_init(vdev) < 0) { return -1; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index ef99080..daa94d6 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -593,6 +593,15 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev) { VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev); DeviceState *vdev = DEVICE(&dev->vdev); + DeviceState *proxy = DEVICE(ccw_dev); + + /* + * For command line compatibility, this set the virtio-serial-device bus + * name as before. + */ + if (proxy->id) { + set_virtio_serial_bus_name(vdev, proxy->id); + } qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); if (qdev_init(vdev) < 0) { diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 070df44..598876f 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1297,6 +1297,7 @@ static int virtio_serial_pci_init(VirtIOPCIProxy *vpci_dev) { VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(vpci_dev); DeviceState *vdev = DEVICE(&dev->vdev); + DeviceState *proxy = DEVICE(vpci_dev); if (vpci_dev->class_code != PCI_CLASS_COMMUNICATION_OTHER && vpci_dev->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */ @@ -1310,6 +1311,14 @@ static int virtio_serial_pci_init(VirtIOPCIProxy *vpci_dev) vpci_dev->nvectors = dev->vdev.serial.max_virtserial_ports + 1; } + /* + * For command line compatibility, this set the virtio-serial-device bus + * name as before. + */ + if (proxy->id) { + set_virtio_serial_bus_name(vdev, proxy->id); + } + qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); if (qdev_init(vdev) < 0) { return -1; diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h index 1d2040b..786e76b 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -194,6 +194,9 @@ typedef struct VirtIOSerialPostLoad { struct VirtIOSerial { VirtIODevice parent_obj; + /* bus_name, for command line compatibility */ + char *bus_name; + VirtQueue *c_ivq, *c_ovq; /* Arrays of ivqs and ovqs: one per port */ VirtQueue **ivqs, **ovqs; @@ -244,6 +247,11 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port); */ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle); +/* + * For command line back compatibility, set the bus name before initialisation. + */ +void set_virtio_serial_bus_name(DeviceState *dev, const char *bus_name); + #define TYPE_VIRTIO_SERIAL "virtio-serial-device" #define VIRTIO_SERIAL(obj) \ OBJECT_CHECK(VirtIOSerial, (obj), TYPE_VIRTIO_SERIAL)