anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0293-path_id-reintroduce-by-path-links-for-virtio-block-d.patch

923a60
From b6fea1a0e0fd830e1aa82accf389cb8bfd0f0f37 Mon Sep 17 00:00:00 2001
923a60
From: Michal Sekletar <msekleta@redhat.com>
923a60
Date: Tue, 9 Feb 2016 09:57:45 +0100
923a60
Subject: [PATCH] path_id: reintroduce by-path links for virtio block devices
923a60
923a60
Enumeration of virtio buses is global and hence
923a60
non-deterministic. However, we are guaranteed there is never going to be
923a60
more than one virtio bus per parent PCI device. While populating
923a60
ID_PATH we simply skip virtio part of the syspath and we extend the path
923a60
using the sysname of the parent PCI device.
923a60
923a60
With this patch udev creates following by-path links for virtio-blk
923a60
device /dev/vda which contains two partitions.
923a60
923a60
ls -l /dev/disk/by-path/
923a60
total 0
923a60
lrwxrwxrwx 1 root root  9 Feb  9 10:47 virtio-pci-0000:00:05.0 -> ../../vda
923a60
lrwxrwxrwx 1 root root 10 Feb  9 10:47 virtio-pci-0000:00:05.0-part1 -> ../../vda1
923a60
lrwxrwxrwx 1 root root 10 Feb  9 10:47 virtio-pci-0000:00:05.0-part2 -> ../../vda2
923a60
923a60
See:
923a60
http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030328.html
923a60
923a60
Fixes #2501
923a60
923a60
Cherry-picked from: f073b1b3c0f4f0df1b0bd61042ce85fb5d27d407
923a60
Resolves: #952567
923a60
---
923a60
 src/udev/udev-builtin-path_id.c | 6 ++++++
923a60
 1 file changed, 6 insertions(+)
923a60
923a60
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
923a60
index 3b72922d48..8359e236a1 100644
923a60
--- a/src/udev/udev-builtin-path_id.c
923a60
+++ b/src/udev/udev-builtin-path_id.c
923a60
@@ -698,6 +698,12 @@ restart:
923a60
                         path_prepend(&path, "xen-%s", udev_device_get_sysname(parent));
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
+                        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");