valeriyvdovin / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
923a60
From 104d13b765fac0308dbd01a1f3a0221504bd0412 Mon Sep 17 00:00:00 2001
923a60
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
923a60
Date: Wed, 1 Mar 2017 21:30:17 +0100
923a60
Subject: [PATCH] udev: Use parent bus id for virtio disk builtin path-id
923a60
 (#5500)
923a60
923a60
The builtin path id for virtio block devices has been changed
923a60
to use the bus id without a prefix "virtio-pci" to be
923a60
compatible with all virtio transport types.
923a60
923a60
In order to not break existing setups, the by-path symlinks for
923a60
virtio block devices on the PCI bus are reintroduced by udev rules.
923a60
The virtio-pci symlinks are considered to be deprecated and
923a60
should be replaced by the native PCI symlinks.
923a60
923a60
Example output for a virtio disk in PCI slot 7:
923a60
 $ ls  /dev/disk/by-path
923a60
 pci-0000:00:07.0
923a60
 pci-0000:00:07.0-part1
923a60
 virtio-pci-0000:00:07.0
923a60
 virtio-pci-0000:00:07.0-part1
923a60
923a60
See also
923a60
[1] https://lists.freedesktop.org/archives/systemd-devel/2017-February/038326.html
923a60
[2] https://lists.freedesktop.org/archives/systemd-devel/2017-March/038397.html
923a60
923a60
This reverts f073b1b but keeps the same symlinks for compatibility.
923a60
923a60
(cherry picked from commit fb92fbb1b171ef94207a1ebc111ef0e414d49b4c)
923a60
923a60
Resolves: #1496697
923a60
---
923a60
 rules/60-persistent-storage.rules | 4 ++++
923a60
 src/udev/udev-builtin-path_id.c   | 5 +----
923a60
 2 files changed, 5 insertions(+), 4 deletions(-)
923a60
923a60
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
923a60
index 06e3329cc9..10642a1fd8 100644
923a60
--- a/rules/60-persistent-storage.rules
923a60
+++ b/rules/60-persistent-storage.rules
923a60
@@ -71,6 +71,10 @@ ENV{DEVTYPE}=="partition", ENV{ID_SAS_PATH}=="?*", SYMLINK+="disk/by-path/$env{I
923a60
 # skip unpartitioned removable media devices from drivers which do not send "change" events
923a60
 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
923a60
 
923a60
+# legacy virtio-pci by-path links (deprecated)
923a60
+KERNEL=="vd*[!0-9]", ENV{ID_PATH}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH}"
923a60
+KERNEL=="vd*[0-9]", ENV{ID_PATH}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH}-part%n"
923a60
+
923a60
 # probe filesystem metadata of optical drives which have a media inserted
923a60
 KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
923a60
   IMPORT{builtin}="blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}"
923a60
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
923a60
index 19447201b4..d113ff21b0 100644
923a60
--- a/src/udev/udev-builtin-path_id.c
923a60
+++ b/src/udev/udev-builtin-path_id.c
923a60
@@ -688,11 +688,8 @@ restart:
923a60
                         parent = skip_subsystem(parent, "xen");
923a60
                         supported_parent = true;
923a60
                 } else if (streq(subsys, "virtio")) {
923a60
-                        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
923a60
-                                parent = udev_device_get_parent(parent);
923a60
-                        path_prepend(&path, "virtio-pci-%s", udev_device_get_sysname(parent));
923a60
+                        parent = skip_subsystem(parent, "virtio");
923a60
                         supported_transport = true;
923a60
-                        supported_parent = true;
923a60
                 } else if (streq(subsys, "scm")) {
923a60
                         path_prepend(&path, "scm-%s", udev_device_get_sysname(parent));
923a60
                         parent = skip_subsystem(parent, "scm");