daandemeyer / rpms / systemd

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