From nobody Fri Oct 18 08:43:11 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 171880018964246.83011142870123; Wed, 19 Jun 2024 05:29:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 624F786C; Wed, 19 Jun 2024 08:29:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2C489CA1; Wed, 19 Jun 2024 08:29:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E207DC7A; Wed, 19 Jun 2024 08:29:23 -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 5ED43BD0 for ; Wed, 19 Jun 2024 08:29:23 -0400 (EDT) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45JBPWQs003419 for ; Wed, 19 Jun 2024 12:29:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yuwsb0a3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Jun 2024 12:29:22 +0000 (GMT) Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45JCTHn1002075 for ; Wed, 19 Jun 2024 12:29:22 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yuwsb0a3j-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 (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45JBHaDs006226; Wed, 19 Jun 2024 12:29:21 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ysn9uvk6w-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 smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45JCTHdE53346618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2024 12:29:19 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF5052004B; Wed, 19 Jun 2024 12:29:17 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 930F12006A; Wed, 19 Jun 2024 12:29:17 +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 :mime-version:content-transfer-encoding; s=pp1; bh=RtquyTm9kUQB4 SedBONznwL+q2nTPYd3Zkv2MF6MYSo=; b=o//MtjNuOvjFdAWVQyWcsBR8ULUbf Qm5U1y4m1VBmsQaRdPJ2O8bpLDmBH2SapK8bzp3+Og5681xcGb3OGNiy9nCyTA2q MTTcbV7eRNoLnSQVbUSzkR+GWB2dy7r6jQ15Y+SlVJ7xK8KepiqFQu1oFfIpbsTG uSDoX4cws4bKGTf01uzfjrugGUTpcU5CNHlHZyea0ocb61qMjqN6DRp3Xj6iAn0K rxTzTNttMNmceoUsf0hnjjl6BNHBHXuS6zR/OuinlV+in5eBxuJgIa9Mhcv7gMPe DLm8pqL2helqdD7e6kAvvHNUW4IF3zlbgTBhED3CFmC+1zVDUboLs3xBg== From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 1/4] nodedev: refactor storage type fixup Date: Wed, 19 Jun 2024 14:29:14 +0200 Message-ID: <20240619122917.45827-2-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> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pi9qEutjiQJmc1EXGxRvGY13_AsQNGWk X-Proofpoint-GUID: TiDR_ytbVOPQYt3FmA1PBX909TCGB_e- 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 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=969 adultscore=0 mlxscore=0 priorityscore=1501 phishscore=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: EFG77RPNSC6DOKFYWVJCUAUY62LBXFWE X-Message-ID-Hash: EFG77RPNSC6DOKFYWVJCUAUY62LBXFWE 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: 1718800191717100001 Content-Type: text/plain; charset="utf-8" Refactor the storage type fixup into a reusable method. Reviewed-by: Marc Hartmayer Signed-off-by: Boris Fiuczynski --- src/node_device/node_device_udev.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 3b85db00da..15e31d522a 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -962,6 +962,21 @@ udevProcessDASD(struct udev_device *device, } =20 =20 +static int +udevFixupStorageType(virNodeDeviceDef *def, const char *prefix, const char= *subst) +{ + if (STRPREFIX(def->caps->data.storage.block, prefix)) { + def->caps->data.storage.drive_type =3D g_strdup(subst); + VIR_DEBUG("Found storage type '%s' for device with sysfs path '%s'= ", + def->caps->data.storage.drive_type, + def->sysfs_path); + return 1; + } + + return 0; +} + + /* This function exists to deal with the case in which a driver does * not provide a device type in the usual place, but udev told us it's * a storage device, and we can make a good guess at what kind of @@ -994,13 +1009,8 @@ udevKludgeStorageType(virNodeDeviceDef *def) def->sysfs_path); =20 for (i =3D 0; i < G_N_ELEMENTS(fixups); i++) { - if (STRPREFIX(def->caps->data.storage.block, fixups[i].prefix)) { - def->caps->data.storage.drive_type =3D g_strdup(fixups[i].subs= t); - VIR_DEBUG("Found storage type '%s' for device with sysfs path = '%s'", - def->caps->data.storage.drive_type, - def->sysfs_path); + if (udevFixupStorageType(def, fixups[i].prefix, fixups[i].subst)) return 0; - } } =20 VIR_DEBUG("Could not determine storage type " --=20 2.45.0