Blob Blame History Raw
From 913b8bd3eb3d1c4574d97d9e09411b199b2899d2 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Fri, 9 Oct 2015 14:15:40 +0200
Subject: [PATCH] udev: make naming for virtio devices opt-in

rhel-only

Resolves: #1269216
---
 src/udev/udev-builtin-net_id.c | 19 +++++++++++++++++--
 src/udev/udevd.c               |  6 +++---
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index ddd83d4..ffd6ea4 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -281,14 +281,29 @@ out:
 
 static int names_pci(struct udev_device *dev, struct netnames *names) {
         struct udev_device *parent;
+        static int do_virtio = -1;
+
+        if (do_virtio < 0) {
+                _cleanup_free_ char *value = NULL;
+                int n = 0;
+                do_virtio = 0;
+                if (get_proc_cmdline_key("net.ifnames", NULL) > 0)
+                        do_virtio = 1;
+                else if (get_proc_cmdline_key("net.ifnames=", &value) > 0) {
+                        safe_atoi(value, &n);
+                        if (n > 0)
+                                do_virtio = 1;
+                }
+        }
 
         parent = udev_device_get_parent(dev);
 
         /* there can only ever be one virtio bus per parent device, so we can
            safely ignore any virtio buses. see
            <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */
-        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
-                parent = udev_device_get_parent(parent);
+        if (do_virtio > 0)
+                while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))
+                        parent = udev_device_get_parent(parent);
 
         if (!parent)
                 return -ENOENT;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 87a3f69..21e7e7f 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1003,10 +1003,10 @@ static void kernel_cmdline_options(struct udev *udev) {
                         r = safe_atou64(value, &arg_event_timeout_usec);
                         if (r < 0) {
                                 log_warning("Invalid udev.event-timeout ignored: %s", value);
-                                break;
+                        } else {
+                                arg_event_timeout_usec *= USEC_PER_SEC;
+                                arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
                         }
-                        arg_event_timeout_usec *= USEC_PER_SEC;
-                        arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
                 }
 
                 free(s);