From nobody Fri Oct 18 08:54:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1718800214674907.3598408761356; Wed, 19 Jun 2024 05:30:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9CAE29E4; Wed, 19 Jun 2024 08:30:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 18D0911B5; Wed, 19 Jun 2024 08:29:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E094AE1; Wed, 19 Jun 2024 08:29:24 -0400 (EDT) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A9C1EC68 for ; Wed, 19 Jun 2024 08:29:23 -0400 (EDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45J9QrJE006689 for ; Wed, 19 Jun 2024 12:29:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yuvf20edr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Jun 2024 12:29:23 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45JCPsF7012887 for ; Wed, 19 Jun 2024 12:29:22 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yuvf20edn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 12:29:22 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45JB9BjT013488; Wed, 19 Jun 2024 12:29:21 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ysr03uxby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 12:29:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45JCTIU819464626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2024 12:29:20 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 236DC2006A; Wed, 19 Jun 2024 12:29:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07B0B20071; Wed, 19 Jun 2024 12:29:18 +0000 (GMT) Received: from fiuczyvm.. (unknown [9.152.222.239]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Jun 2024 12:29:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:mime-version; s=pp1; bh=rixi0BPceqbZ2 N+ClUv2ZqditljV3rpae/0jclTatQo=; b=ANNAXUKm8jetbJpZOlyqgRq0ZMJnV x1cfW6wjSKlnpz41sVVyiffSTQf0+Q4xZuie5/e/mrSHSWRx4Dojj//kAuYRD6Id aUpj+1rT+cQ6OGQ09QlOWNFwfKppUnRTUaZDwlLWeeREDBzDGKhA+NY4ijugSNOW sfFJWNuFL0XW5SenxTyPFCFB6Bk04xCvNyXUFza3HLyrDFEaP0u5vZOWk2Hpk/aC fwKFq7IR9kISs6a8ckQBrLtvGiVr48+/53JxVFxE6w0F9afcCZs7mzC6/PWqF8xu eaO8n5sCIPsL1YForKDmVDQbkJ7qYn2M0Wmvl5evX/nGiRX9xsmbmoADQ== From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 4/4] nodedev: add ccw device state and remove fencing Date: Wed, 19 Jun 2024 14:29:17 +0200 Message-ID: <20240619122917.45827-5-fiuczy@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240619122917.45827-1-fiuczy@linux.ibm.com> References: <20240619122917.45827-1-fiuczy@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: hKgNEdptRZkDcSq_-D8piBWA42clQ9PJ X-Proofpoint-GUID: vuVea2yw6HPP5D_uI8paV52TSGQls-NM X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-19_02,2024-06-19_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406190092 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BEDM43PU2VKQ4ODUVANX5LYRNRAOPLUH X-Message-ID-Hash: BEDM43PU2VKQ4ODUVANX5LYRNRAOPLUH X-MailFrom: fiuczy@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jjongsma@redhat.com, mhartmay@linux.ibm.com, mprivozn@redhat.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1718800215865100001 Content-Type: text/plain; charset="utf-8" Instead of fencing offline ccw devices add the state to the ccw capability. Resolves: https://issues.redhat.com/browse/RHEL-39497 Signed-off-by: Boris Fiuczynski --- src/conf/node_device_conf.c | 24 ++++++++++++++++++++++++ src/conf/node_device_conf.h | 11 +++++++++++ src/conf/schemas/nodedev.rng | 8 ++++++++ src/node_device/node_device_udev.c | 27 ++++++++++++++++++++++++--- 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 416238bec1..08a89942ba 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -86,6 +86,12 @@ VIR_ENUM_IMPL(virNodeDevDRM, "render", ); =20 +VIR_ENUM_IMPL(virNodeDevCCWState, + VIR_NODE_DEV_CCW_STATE_LAST, + "offline", + "online", +); + static int virNodeDevCapsDefParseString(const char *xpath, xmlXPathContextPtr ctxt, @@ -743,6 +749,10 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def, un= signed int flags) virNodeDeviceCapMdevDefFormat(&buf, data, inactive_state); break; case VIR_NODE_DEV_CAP_CCW_DEV: + if (data->ccw_dev.state !=3D VIR_NODE_DEV_CCW_STATE_LAST) { + const char *state =3D virNodeDevCCWStateTypeToString(data-= >ccw_dev.state); + virBufferEscapeString(&buf, "%s\n", state); + } virNodeDeviceCapCCWDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_CSS_DEV: @@ -1189,9 +1199,23 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree virCCWDeviceAddress *ccw_addr =3D NULL; + g_autofree char *state =3D NULL; + int val; =20 ctxt->node =3D node; =20 + /* state is optional */ + ccw_dev->state =3D VIR_NODE_DEV_CCW_STATE_LAST; + + if ((state =3D virXPathString("string(./state[1])", ctxt))) { + if ((val =3D virNodeDevCCWStateTypeFromString(state)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown state '%1$s' for '%2$s'"), state, de= f->name); + return -1; + } + ccw_dev->state =3D val; + } + ccw_addr =3D g_new0(virCCWDeviceAddress, 1); =20 if (virNodeDevCCWDeviceAddressParseXML(ctxt, node, def->name, ccw_addr= ) < 0) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 4b82636af7..32a8a5884b 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -112,6 +112,16 @@ typedef enum { VIR_NODE_DEV_CAP_FLAG_CSS_MDEV =3D (1 << 0), } virNodeDevCCWCapFlags; =20 +typedef enum { + /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ + VIR_NODE_DEV_CCW_STATE_OFFLINE =3D 0, + VIR_NODE_DEV_CCW_STATE_ONLINE, + + VIR_NODE_DEV_CCW_STATE_LAST +} virNodeDevCCWStateType; + +VIR_ENUM_DECL(virNodeDevCCWState); + typedef enum { VIR_NODE_DEV_CAP_FLAG_AP_MATRIX_MDEV =3D (1 << 0), } virNodeDevAPMatrixCapFlags; @@ -279,6 +289,7 @@ struct _virNodeDevCapCCW { virMediatedDeviceType **mdev_types; size_t nmdev_types; virCCWDeviceAddress *channel_dev_addr; + virNodeDevCCWStateType state; }; =20 typedef struct _virNodeDevCapVDPA virNodeDevCapVDPA; diff --git a/src/conf/schemas/nodedev.rng b/src/conf/schemas/nodedev.rng index ff07313968..42a0cdcfd9 100644 --- a/src/conf/schemas/nodedev.rng +++ b/src/conf/schemas/nodedev.rng @@ -673,6 +673,14 @@ ccw + + + + online + offline + + + =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index ad994ef0b2..9d11261b88 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1199,13 +1199,34 @@ udevGetCCWAddress(const char *sysfs_path, =20 =20 static int -udevProcessCCW(struct udev_device *device, - virNodeDeviceDef *def) +udevCCWGetState(struct udev_device *device, + virNodeDevCapData *data) { int online =3D 0; =20 + if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online < = 0) + return -1; + + switch (online) { + case VIR_NODE_DEV_CCW_STATE_OFFLINE: + case VIR_NODE_DEV_CCW_STATE_ONLINE: + data->ccw_dev.state =3D online; + break; + default: + data->ccw_dev.state =3D VIR_NODE_DEV_CCW_STATE_LAST; + break; + } + + return 0; +} + + +static int +udevProcessCCW(struct udev_device *device, + virNodeDeviceDef *def) +{ /* process only online devices to keep the list sane */ - if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != =3D 1) + if (udevCCWGetState(device, &def->caps->data) < 0) return -1; =20 if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) --=20 2.45.0