From nobody Wed May 8 10:26:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643202866; cv=none; d=zohomail.com; s=zohoarc; b=a3VPDRO0FlWpK3QDPDJYlvEXArXKa7IJjoCkDLE2fzMNTC6K0pdnSvocuL+WZ82krWprvWaYWcEqSvy20xilclVcSHKcBjTJRLge/pr8olc89D6ojT7TiKBaVgA3UpZoKCxbhM5d3ePwt9QN8ab/h3QoUVwuW9PjyCYbkQsFijY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643202866; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=saXlfojeRhR7miNmpp3ZBOLniOS0UbrJmWquanY5HDU=; b=T+8/ARtZeX/lzurUy6CqWFQGjUYyprPjKZcvhTcDVnoy3iB7hzZxGDmIyD7N3cjO1vRX7nwLRUK2PdjQW9W+zSLx9WZ5M8Ddx5GdLj4Pi2STCSS+fIX6XwhBnBkEcOPyMSJ6dKK8+Lghs8Lj/9njIVISI7BGNaK4drhQBpV29LM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643202866345693.3665763587334; Wed, 26 Jan 2022 05:14:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-DQzqaNEsOom5y3lZDN3Mvw-1; Wed, 26 Jan 2022 08:14:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC50018B9ED1; Wed, 26 Jan 2022 13:14:18 +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 80884108BD45; Wed, 26 Jan 2022 13:14:17 +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 D56561832B5F; Wed, 26 Jan 2022 13:14:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20QDE8vo008217 for ; Wed, 26 Jan 2022 08:14:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 248D96D02A; Wed, 26 Jan 2022 13:14:08 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 982306F12A for ; Wed, 26 Jan 2022 13:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643202865; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=saXlfojeRhR7miNmpp3ZBOLniOS0UbrJmWquanY5HDU=; b=advKQPGZLNrnWKkcrrDt176B58qQzGyDBX7hvQ0piX12rNPjygiPO6LrvSb7ULL1sa00Ma pGx7ThqDlatvjZOFJAPZNXHrykgX6/etCNbp6+BtZ8DZF/o6WHCZiA8Eom55o/2MqNM82b +JASAR1i6os56DPrL10l6dzwh8sX7Os= X-MC-Unique: DQzqaNEsOom5y3lZDN3Mvw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] node_device: Rework udevKludgeStorageType() Date: Wed, 26 Jan 2022 14:13:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643202868202100002 Content-Type: text/plain; charset="utf-8" The udevKludgeStorageType() function looks at devlink name (/dev/XXX) and guesses the type of the (storage) device using a series of STRPREFIX() calls. Well those can be turn into an array and a for() loop, especially if we are about to add a new case (in the next commit). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index cd1722f934..14acb3fee0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -890,32 +890,32 @@ udevProcessDASD(struct udev_device *device, static int udevKludgeStorageType(virNodeDeviceDef *def) { + size_t i; + const char *fixups[][2] =3D { + /* virtio disk */ + { "/dev/vd", "disk" }, + + /* For Direct Access Storage Devices (DASDs) there are + * currently no identifiers in udev besides ID_PATH. Since + * ID_TYPE=3Ddisk does not exist on DASDs they fall through + * the udevProcessStorage detection logic. */ + { "/dev/dasd", "dasd" }, + }; + VIR_DEBUG("Could not find definitive storage type for device " "with sysfs path '%s', trying to guess it", def->sysfs_path); =20 - /* virtio disk */ - if (STRPREFIX(def->caps->data.storage.block, "/dev/vd")) { - def->caps->data.storage.drive_type =3D g_strdup("disk"); - VIR_DEBUG("Found storage type '%s' for device " - "with sysfs path '%s'", - def->caps->data.storage.drive_type, - def->sysfs_path); - return 0; + for (i =3D 0; i < G_N_ELEMENTS(fixups); i++) { + if (STRPREFIX(def->caps->data.storage.block, fixups[i][0])) { + def->caps->data.storage.drive_type =3D g_strdup(fixups[i][1]); + VIR_DEBUG("Found storage type '%s' for device with sysfs path = '%s'", + def->caps->data.storage.drive_type, + def->sysfs_path); + return 0; + } } =20 - /* For Direct Access Storage Devices (DASDs) there are - * currently no identifiers in udev besides ID_PATH. Since - * ID_TYPE=3Ddisk does not exist on DASDs they fall through - * the udevProcessStorage detection logic. */ - if (STRPREFIX(def->caps->data.storage.block, "/dev/dasd")) { - def->caps->data.storage.drive_type =3D g_strdup("dasd"); - VIR_DEBUG("Found storage type '%s' for device " - "with sysfs path '%s'", - def->caps->data.storage.drive_type, - def->sysfs_path); - return 0; - } VIR_DEBUG("Could not determine storage type " "for device with sysfs path '%s'", def->sysfs_path); return -1; --=20 2.34.1 From nobody Wed May 8 10:26:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643202866; cv=none; d=zohomail.com; s=zohoarc; b=Ec2a14z0lTXltKg59QMrqxU/JwzDItavyc1LnAnYKVe7lTJb8nv8ALq2wm+od7Jj6aqSUch1lOUURlnBWE5iKvgN70Yw8qDVhez+f23yNoawCdTaltF+ps8A+kRzKiByrW2ysKJqDN7JxRc34fQU5I1y0pT88vOpN9aDJU183co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643202866; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HeT6Q0Nem4vpDSam2Zpc8SOjwHV253BABIAwFiV4fc4=; b=YrgkXwql7VXKETrZxbMhjzhfz/IMsNHd5jEBGBSxe4l5a+L0vuw9e1vG6y49lWoIfGMk6lLsZ0DjYHfT9BfFRtVJEfcTYinCiimVHFezQZIOTgl4AZICaiuTHBHLFDrQCKIRhiTYdhLjS4PIw6rxMik9vAT0XEGPNP9kl3CiLpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643202866877603.5293897971127; Wed, 26 Jan 2022 05:14:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-hvd28S4iNnSnLhVYwslHrQ-1; Wed, 26 Jan 2022 08:14:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A91D6760C6; Wed, 26 Jan 2022 13:14:18 +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 7D2B216A4F; Wed, 26 Jan 2022 13:14:17 +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 51EF21832B5E; Wed, 26 Jan 2022 13:14:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20QDE8LI008225 for ; Wed, 26 Jan 2022 08:14:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id E34AD6D02A; Wed, 26 Jan 2022 13:14:08 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D4004EC66 for ; Wed, 26 Jan 2022 13:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643202866; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HeT6Q0Nem4vpDSam2Zpc8SOjwHV253BABIAwFiV4fc4=; b=YCTryg0SEoKsq6DXwGIYkrlYK3wb1JR20rkVl1eucNjCEatDcnwcRDH+omFk/baSGzC0JP Gen9YouHR6wayt+u1swgd3KKUgpET+0ZzaPX/HLqu+KiMlbFeu6e6XPMETGzD/8DI5CatR xlMSMtqxqEzXmNsq8pbo5uUTXwsorSI= X-MC-Unique: hvd28S4iNnSnLhVYwslHrQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] node_device: Treat NVMe disks as regular disks Date: Wed, 26 Jan 2022 14:13:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643202868191100001 Content-Type: text/plain; charset="utf-8" Unfortunately, udev doesn't set ID_TYPE attribute for NVMe disks, therefore we have to add another case into udevKludgeStorageType() to treat /dev/nvme* devlinks as any other disk. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2045953 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 14acb3fee0..27efda1ab0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -900,6 +900,9 @@ udevKludgeStorageType(virNodeDeviceDef *def) * ID_TYPE=3Ddisk does not exist on DASDs they fall through * the udevProcessStorage detection logic. */ { "/dev/dasd", "dasd" }, + + /* NVMe disk */ + { "/dev/nvme", "disk" }, }; =20 VIR_DEBUG("Could not find definitive storage type for device " --=20 2.34.1