teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0256-udev-make-naming-for-virtio-devices-opt-in.patch

923a60
From 913b8bd3eb3d1c4574d97d9e09411b199b2899d2 Mon Sep 17 00:00:00 2001
923a60
From: Lukas Nykryn <lnykryn@redhat.com>
923a60
Date: Fri, 9 Oct 2015 14:15:40 +0200
923a60
Subject: [PATCH] udev: make naming for virtio devices opt-in
923a60
923a60
rhel-only
923a60
923a60
Resolves: #1269216
923a60
---
923a60
 src/udev/udev-builtin-net_id.c | 19 +++++++++++++++++--
923a60
 src/udev/udevd.c               |  6 +++---
923a60
 2 files changed, 20 insertions(+), 5 deletions(-)
923a60
923a60
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
923a60
index ddd83d4f1b..ffd6ea4166 100644
923a60
--- a/src/udev/udev-builtin-net_id.c
923a60
+++ b/src/udev/udev-builtin-net_id.c
923a60
@@ -281,14 +281,29 @@ out:
923a60
 
923a60
 static int names_pci(struct udev_device *dev, struct netnames *names) {
923a60
         struct udev_device *parent;
923a60
+        static int do_virtio = -1;
923a60
+
923a60
+        if (do_virtio < 0) {
923a60
+                _cleanup_free_ char *value = NULL;
923a60
+                int n = 0;
923a60
+                do_virtio = 0;
923a60
+                if (get_proc_cmdline_key("net.ifnames", NULL) > 0)
923a60
+                        do_virtio = 1;
923a60
+                else if (get_proc_cmdline_key("net.ifnames=", &value) > 0) {
923a60
+                        safe_atoi(value, &n);
923a60
+                        if (n > 0)
923a60
+                                do_virtio = 1;
923a60
+                }
923a60
+        }
923a60
 
923a60
         parent = udev_device_get_parent(dev);
923a60
 
923a60
         /* there can only ever be one virtio bus per parent device, so we can
923a60
            safely ignore any virtio buses. see
923a60
            <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */
923a60
-        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
923a60
-                parent = udev_device_get_parent(parent);
923a60
+        if (do_virtio > 0)
923a60
+                while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
923a60
+                        parent = udev_device_get_parent(parent);
923a60
 
923a60
         if (!parent)
923a60
                 return -ENOENT;
923a60
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
923a60
index 87a3f69e90..21e7e7f9a9 100644
923a60
--- a/src/udev/udevd.c
923a60
+++ b/src/udev/udevd.c
923a60
@@ -1003,10 +1003,10 @@ static void kernel_cmdline_options(struct udev *udev) {
923a60
                         r = safe_atou64(value, &arg_event_timeout_usec);
923a60
                         if (r < 0) {
923a60
                                 log_warning("Invalid udev.event-timeout ignored: %s", value);
923a60
-                                break;
923a60
+                        } else {
923a60
+                                arg_event_timeout_usec *= USEC_PER_SEC;
923a60
+                                arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
923a60
                         }
923a60
-                        arg_event_timeout_usec *= USEC_PER_SEC;
923a60
-                        arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
923a60
                 }
923a60
 
923a60
                 free(s);