From nobody Sat Feb 7 07:31:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495435165542906.2904904657977; Sun, 21 May 2017 23:39:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0A6E61BA6; Mon, 22 May 2017 06:39:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32C4A18981; Mon, 22 May 2017 06:39:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6ADEC180BAF2; Mon, 22 May 2017 06:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4M6cier010388 for ; Mon, 22 May 2017 02:38:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD35318EFE; Mon, 22 May 2017 06:38:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7E1A5DC1D for ; Mon, 22 May 2017 06:38:44 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A82A3B54D for ; Mon, 22 May 2017 06:38:43 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4M6Sgd9041083 for ; Mon, 22 May 2017 02:38:42 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2akn9sj3sr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 22 May 2017 02:38:42 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 May 2017 07:38:40 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 May 2017 07:38:39 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4M6cc7q15925642; Mon, 22 May 2017 06:38:38 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EB725204C; Mon, 22 May 2017 06:35:49 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5FEA75204D; Mon, 22 May 2017 06:35:49 +0100 (BST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A0A6E61BA6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A0A6E61BA6 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A82A3B54D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=bwalk@linux.vnet.ibm.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3A82A3B54D From: Bjoern Walk To: libvir-list@redhat.com Date: Mon, 22 May 2017 08:38:22 +0200 In-Reply-To: <20170522063826.15949-1-bwalk@linux.vnet.ibm.com> References: <20170522063826.15949-1-bwalk@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052206-0008-0000-0000-0000044F9451 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052206-0009-0000-0000-00001DC4D893 Message-Id: <20170522063826.15949-4-bwalk@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-22_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705220034 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 22 May 2017 06:38:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 22 May 2017 06:38:43 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'bwalk@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -2.7 (BAYES_50, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Bjoern Walk Subject: [libvirt] [PATCH 3/7] node_device: detect CCW devices X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 22 May 2017 06:39:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make CCW devices available to the node_device driver. The devices are already seen by udev so let's implement necessary code for detecting them properly. Topologically, CCW devices are similar to PCI devices, e.g.: +- ccw_0_0_1a2b | +- scsi_host0 | +- scsi_target0_0_0 | +- scsi_0_0_0_0 Reviewed-by: Boris Fiuczynski Signed-off-by: Bjoern Walk Reviewed-by: John Ferlan --- docs/schemas/basictypes.rng | 31 ++++++++++ docs/schemas/domaincommon.rng | 30 --------- docs/schemas/nodedev.rng | 16 +++++ src/conf/node_device_conf.c | 75 +++++++++++++++++++= +++- src/conf/node_device_conf.h | 10 +++ src/node_device/node_device_driver.c | 1 + src/node_device/node_device_udev.c | 35 ++++++++++- tests/nodedevschemadata/ccw_0_0_10000-invalid.xml | 10 +++ tests/nodedevschemadata/ccw_0_0_ffff.xml | 10 +++ tests/nodedevxml2xmltest.c | 1 + tools/virsh-nodedev.c | 2 + 11 files changed, 188 insertions(+), 33 deletions(-) create mode 100644 tests/nodedevschemadata/ccw_0_0_10000-invalid.xml create mode 100644 tests/nodedevschemadata/ccw_0_0_ffff.xml diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index cc560e66f..1ea667cdf 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -318,6 +318,37 @@ =20 + + + + 0x[0-9a-eA-E][0-9a-fA-F]? + + + 0x[fF][0-9a-eA-E]? + + + 0 + 254 + + + + + + (0x)?[0-3] + + + + + + 0x[0-9a-fA-F]{1,4} + + + 0 + 65535 + + + + ([0-9]+(-[0-9]+)?|\^[0-9]+)(,([0-9]+(-[0-9]+= )?|\^[0-9]+))* diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f88e84ab6..94de10749 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5770,36 +5770,6 @@ - - - - 0x[0-9a-eA-E][0-9a-fA-F]? - - - 0x[fF][0-9a-eA-E]? - - - 0 - 254 - - - - - - (0x)?[0-3] - - - - - - 0x[0-9a-fA-F]{1,4} - - - 0 - 65535 - - - diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 924f73861..87bfb0c28 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -84,6 +84,7 @@ + @@ -597,6 +598,21 @@ =20 + + + ccw + + + + + + + + + + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9cb63860f..28d4907f5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -62,7 +62,8 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, "scsi_generic", "drm", "mdev_types", - "mdev") + "mdev", + "ccw") =20 VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST, "80203", @@ -581,6 +582,14 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferAsprintf(&buf, "\n", data->mdev.iommuGroupNumber); break; + case VIR_NODE_DEV_CAP_CCW_DEV: + virBufferAsprintf(&buf, "0x%x\n", + data->ccw_dev.cssid); + virBufferAsprintf(&buf, "0x%x\n", + data->ccw_dev.ssid); + virBufferAsprintf(&buf, "0x%04x\n", + data->ccw_dev.devno); + break; case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: @@ -718,6 +727,66 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, =20 =20 static int +virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapCCWPtr ccw_dev) +{ + xmlNodePtr orignode; + int ret =3D -1; + char *cssid =3D NULL, *ssid =3D NULL, *devno =3D NULL; + + orignode =3D ctxt->node; + ctxt->node =3D node; + + if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing cssid value for '%s'"), def->name); + goto out; + } + + if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid cssid value '%s' for '%s'"), + cssid, def->name); + goto out; + } + + if (!(ssid =3D virXPathString("string(./ssid[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing ssid value for '%s'"), def->name); + goto out; + } + + if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid ssid value '%s' for '%s'"), + cssid, def->name); + goto out; + } + + if (!(devno =3D virXPathString("string(./devno[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing devno value for '%s'"), def->name); + goto out; + } + + if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid devno value '%s' for '%s'"), + devno, def->name); + goto out; + } + + ret =3D 0; + + out: + ctxt->node =3D orignode; + return ret; +} + + +static int virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, xmlNodePtr node, @@ -1754,6 +1823,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, case VIR_NODE_DEV_CAP_MDEV: ret =3D virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mde= v); break; + case VIR_NODE_DEV_CAP_CCW_DEV: + ret =3D virNodeDevCapCCWParseXML(ctxt, def, node, &caps->data.ccw_= dev); + break; case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: @@ -2083,6 +2155,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_CCW_DEV: case VIR_NODE_DEV_CAP_LAST: /* This case is here to shutup the compiler */ break; diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 5743f9d3e..bf9d5fce5 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -66,6 +66,7 @@ typedef enum { VIR_NODE_DEV_CAP_DRM, /* DRM device */ VIR_NODE_DEV_CAP_MDEV_TYPES, /* Device capable of mediated devi= ces */ VIR_NODE_DEV_CAP_MDEV, /* Mediated device */ + VIR_NODE_DEV_CAP_CCW_DEV, /* s390 CCW device */ =20 VIR_NODE_DEV_CAP_LAST } virNodeDevCapType; @@ -267,6 +268,14 @@ struct _virNodeDevCapDRM { virNodeDevDRMType type; }; =20 +typedef struct _virNodeDevCapCCW virNodeDevCapCCW; +typedef virNodeDevCapCCW *virNodeDevCapCCWPtr; +struct _virNodeDevCapCCW { + unsigned int cssid; + unsigned int ssid; + unsigned int devno; +}; + typedef struct _virNodeDevCapData virNodeDevCapData; typedef virNodeDevCapData *virNodeDevCapDataPtr; struct _virNodeDevCapData { @@ -284,6 +293,7 @@ struct _virNodeDevCapData { virNodeDevCapSCSIGeneric sg; virNodeDevCapDRM drm; virNodeDevCapMdev mdev; + virNodeDevCapCCW ccw_dev; }; }; =20 diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 74507c214..286af26bc 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -84,6 +84,7 @@ static int update_caps(virNodeDeviceObjPtr dev) case VIR_NODE_DEV_CAP_SCSI_GENERIC: case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_CCW_DEV: case VIR_NODE_DEV_CAP_LAST: break; } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 4ecb0b18f..7744c2637 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1105,6 +1105,33 @@ udevProcessMediatedDevice(struct udev_device *dev, } =20 static int +udevProcessCCW(struct udev_device *device, virNodeDeviceDefPtr def) +{ + int online; + char *p; + virNodeDevCapDataPtr data =3D &def->caps->data; + + /* process only online devices to keep the list sane */ + if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != =3D 1) + return -1; + + if ((p =3D strrchr(def->sysfs_path, '/')) =3D=3D NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p =3D= =3D NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p =3D= =3D NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse the CCW address from sysfs path:= '%s'"), + def->sysfs_path); + return -1; + } + + if (udevGenerateDeviceName(device, def, NULL) !=3D 0) + return -1; + + return 0; +} + +static int udevGetDeviceNodes(struct udev_device *device, virNodeDeviceDefPtr def) { @@ -1172,8 +1199,8 @@ udevGetDeviceType(struct udev_device *device, if (udevHasDeviceProperty(device, "INTERFACE")) *type =3D VIR_NODE_DEV_CAP_NET; =20 - /* Neither SCSI generic devices nor mediated devices set DEVTYPE - * property, therefore we need to rely on the SUBSYSTEM property */ + /* The following devices do not set the DEVTYPE property, therefore + * we need to rely on the SUBSYSTEM property */ if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) < 0) return -1; =20 @@ -1181,6 +1208,8 @@ udevGetDeviceType(struct udev_device *device, *type =3D VIR_NODE_DEV_CAP_SCSI_GENERIC; else if (STREQ_NULLABLE(subsystem, "mdev")) *type =3D VIR_NODE_DEV_CAP_MDEV; + else if (STREQ_NULLABLE(subsystem, "ccw")) + *type =3D VIR_NODE_DEV_CAP_CCW_DEV; =20 VIR_FREE(subsystem); } @@ -1222,6 +1251,8 @@ static int udevGetDeviceDetails(struct udev_device *d= evice, return udevProcessDRMDevice(device, def); case VIR_NODE_DEV_CAP_MDEV: return udevProcessMediatedDevice(device, def); + case VIR_NODE_DEV_CAP_CCW_DEV: + return udevProcessCCW(device, def); case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_FC_HOST: diff --git a/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml b/tests/node= devschemadata/ccw_0_0_10000-invalid.xml new file mode 100644 index 000000000..d840555c0 --- /dev/null +++ b/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml @@ -0,0 +1,10 @@ + + ccw_0_0_10000 + /sys/devices/css0/0.0.0000/0.0.10000 + computer + + 0x0 + 0x0 + 0x10000 + + diff --git a/tests/nodedevschemadata/ccw_0_0_ffff.xml b/tests/nodedevschema= data/ccw_0_0_ffff.xml new file mode 100644 index 000000000..5ecd0b0aa --- /dev/null +++ b/tests/nodedevschemadata/ccw_0_0_ffff.xml @@ -0,0 +1,10 @@ + + ccw_0_0_ffff + /sys/devices/css0/0.0.0000/0.0.ffff + computer + + 0x0 + 0x0 + 0xffff + + diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index a2aad518d..805deef26 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -103,6 +103,7 @@ mymain(void) DO_TEST("drm_renderD129"); DO_TEST("pci_0000_02_10_7_mdev_types"); DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b"); + DO_TEST("ccw_0_0_ffff"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index ad96dda1f..1822d3dce 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -460,6 +460,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd A= TTRIBUTE_UNUSED) case VIR_NODE_DEV_CAP_MDEV: flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV; break; + case VIR_NODE_DEV_CAP_CCW_DEV: + /* enable next patch */ case VIR_NODE_DEV_CAP_LAST: break; } --=20 2.11.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list