File fwupd-bsc1193921-nvme-ignore-non-PCI-NVMe-devices.patch of Package fwupd.22836
From 9b386965f2b63027262f28094b3f8516d4dba17a Mon Sep 17 00:00:00 2001
From: Enzo Matsumiya <ematsumiya@suse.de>
Date: Thu, 23 Dec 2021 23:38:17 -0300
Subject: [PATCH] nvme: ignore non-PCI NVMe devices
Ignore non-PCI NVMe devices (e.g. NVMe-over-Fabrics) when probing.
Otherwise, logs might be flooded with error messages:
03:10:53:0251 FuEngine failed to add device /sys/devices/virtual/nvme-fabrics/ctl/nvme1: failed to find device with subsystems pci, only got nvme,nvme-fabrics
These devices are not supported as they are not on the PCI subsystem.
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
---
plugins/nvme/fu-nvme-device.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
Index: fwupd-1.5.8/plugins/nvme/fu-nvme-device.c
===================================================================
--- fwupd-1.5.8.orig/plugins/nvme/fu-nvme-device.c
+++ fwupd-1.5.8/plugins/nvme/fu-nvme-device.c
@@ -262,6 +262,31 @@ fu_nvme_device_dump (const gchar *title,
g_print ("\n");
}
+/*
+ * Returns:
+ * %TRUE: device is in PCI subsystem
+ * %FALSE: device is, probably, NVMe-over-Fabrics
+ */
+static gboolean
+fu_nvme_device_is_pci(FuDevice *device, GError **error)
+{
+ g_autoptr(GUdevDevice) device_tmp = NULL;
+ GUdevDevice *gdev;
+
+ gdev = fu_udev_device_get_dev(FU_UDEV_DEVICE(device));
+
+ device_tmp = g_udev_device_get_parent_with_subsystem(gdev, "pci", NULL);
+ if (device_tmp == NULL) {
+ g_set_error(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "device is not on PCI subsystem");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean
fu_nvme_device_probe (FuDevice *device, GError **error)
{
@@ -271,6 +296,10 @@ fu_nvme_device_probe (FuDevice *device,
if (!FU_DEVICE_CLASS (fu_nvme_device_parent_class)->probe (device, error))
return FALSE;
+ /* ignore non-PCI NVMe devices */
+ if (!fu_nvme_device_is_pci(device, error))
+ return FALSE;
+
/* set the physical ID */
if (!fu_udev_device_set_physical_id (FU_UDEV_DEVICE (device), "pci", error))
return FALSE;