Received: from eggs.gnu.org ([2001:4830:134:3::10]:51998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPsJk-0000YK-U4 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 10:17:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPsJh-0007nG-56 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 10:17:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57135 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPsJg-0007nC-VU for qemu-devel@nongnu.org; Wed, 20 Jul 2016 10:17:41 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6KEDZSw050908 for ; Wed, 20 Jul 2016 10:17:40 -0400 Received: from e06smtp09.uk.ibm.com (e06smtp09.uk.ibm.com [195.75.94.105]) by mx0a-001b2d01.pphosted.com with ESMTP id 2495r98p62-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 20 Jul 2016 10:17:40 -0400 Received: from localhost by e06smtp09.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jul 2016 15:17:38 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id BFA6217D8063 for ; Wed, 20 Jul 2016 15:18:58 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6KEHSdm9568666 for ; Wed, 20 Jul 2016 14:17:28 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6KEHSD9009334 for ; Wed, 20 Jul 2016 08:17:28 -0600 From: Cornelia Huck Date: Wed, 20 Jul 2016 16:17:25 +0200 In-Reply-To: <20160720141725.20025-1-cornelia.huck@de.ibm.com> References: <20160720141725.20025-1-cornelia.huck@de.ibm.com> Message-Id: <20160720141725.20025-4-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PULL 3/3] s390x/css: provide a dev_path for css devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: borntraeger@de.ibm.com, agraf@suse.de, jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org, Cornelia Huck We need to implement the get_dev_path method for the css bus, or else we might end up with two different devices having the same qdev_path. This was noticed when adding two scsi_hd controllers: The SCSIBus code will produce a non-unique dev_path for vmstate usage if the parent bus does not provide the get_dev_path method. We simply use the device's bus id, as this is unique and we won't have any deeper hierarchy from a channel subsystem perspective anyway. Note that we need to disable this for older machine versions, as this changes the migration format. Reported-by: Marc Hartmayer Reviewed-by: Halil Pasic Reviewed-by: Sascha Silbe Tested-by: Marc Hartmayer Signed-off-by: Cornelia Huck --- hw/s390x/css-bridge.c | 26 +++++++++++++++++++++++++- hw/s390x/s390-virtio-ccw.c | 4 ++++ include/hw/s390x/css-bridge.h | 7 +++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index e4c24e2..9a7f7ee 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -59,11 +59,28 @@ static void virtual_css_bus_reset(BusState *qbus) css_reset(); } +static char *virtual_css_bus_get_dev_path(DeviceState *dev) +{ + CcwDevice *ccw_dev = CCW_DEVICE(dev); + SubchDev *sch = ccw_dev->sch; + VirtualCssBridge *bridge = + VIRTUAL_CSS_BRIDGE(qdev_get_parent_bus(dev)->parent); + + /* + * We can't provide a dev path for backward compatibility on + * older machines, as it is visible in the migration stream. + */ + return bridge->css_dev_path ? + g_strdup_printf("/%02x.%1x.%04x", sch->cssid, sch->ssid, sch->devno) : + NULL; +} + static void virtual_css_bus_class_init(ObjectClass *klass, void *data) { BusClass *k = BUS_CLASS(klass); k->reset = virtual_css_bus_reset; + k->get_dev_path = virtual_css_bus_get_dev_path; } static const TypeInfo virtual_css_bus_info = { @@ -95,6 +112,12 @@ VirtualCssBus *virtual_css_bus_init(void) /***************** Virtual-css Bus Bridge Device ********************/ +static Property virtual_css_bridge_properties[] = { + DEFINE_PROP_BOOL("css_dev_path", VirtualCssBridge, css_dev_path, + true), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) { HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); @@ -102,12 +125,13 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) hc->unplug = ccw_device_unplug; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->props = virtual_css_bridge_properties; } static const TypeInfo virtual_css_bridge_info = { .name = TYPE_VIRTUAL_CSS_BRIDGE, .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(SysBusDevice), + .instance_size = sizeof(VirtualCssBridge), .class_init = virtual_css_bridge_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index caf0a68..91d9cef 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -322,6 +322,10 @@ static const TypeInfo ccw_machine_info = { .driver = TYPE_S390_IPL,\ .property = "iplbext_migration",\ .value = "off",\ + }, {\ + .driver = TYPE_VIRTUAL_CSS_BRIDGE,\ + .property = "css_dev_path",\ + .value = "off",\ }, #define CCW_COMPAT_2_5 \ diff --git a/include/hw/s390x/css-bridge.h b/include/hw/s390x/css-bridge.h index ad73c1f..5a0203b 100644 --- a/include/hw/s390x/css-bridge.h +++ b/include/hw/s390x/css-bridge.h @@ -16,7 +16,14 @@ #include "hw/qdev-core.h" /* virtual css bridge */ +typedef struct VirtualCssBridge { + SysBusDevice sysbus_dev; + bool css_dev_path; +} VirtualCssBridge; + #define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" +#define VIRTUAL_CSS_BRIDGE(obj) \ + OBJECT_CHECK(VirtualCssBridge, (obj), TYPE_VIRTUAL_CSS_BRIDGE) /* virtual css bus type */ typedef struct VirtualCssBus { -- 2.9.2