daandemeyer / rpms / systemd

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