The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7452

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 5b5d38b5481f5b6dcfa95ef7e1834c86b6e30640 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 27 May 2020 16:44:53 +0200
Subject: [PATCH] unix-hotplug: fix uevent injection

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 lxd/devices.go | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lxd/devices.go b/lxd/devices.go
index 5060c1788c..3442765652 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -112,12 +112,15 @@ func deviceNetlinkListener() (chan []string, chan 
[]string, chan device.USBEvent
                        }
                        ueventLen := 0
                        ueventParts := strings.Split(string(ueventBuf), "\x00")
-                       props := map[string]string{}
-                       for _, part := range ueventParts {
+                       for i, part := range ueventParts {
                                if strings.HasPrefix(part, "SEQNUM=") {
-                                       continue
+                                       ueventParts = append(ueventParts[:i], 
ueventParts[i+1:]...)
+                                       break
                                }
+                       }
 
+                       props := map[string]string{}
+                       for _, part := range ueventParts {
                                // libudev string prefix distinguishes udev 
events from kernel uevents
                                if strings.HasPrefix(part, "libudev") {
                                        udevEvent = true
@@ -136,6 +139,13 @@ func deviceNetlinkListener() (chan []string, chan 
[]string, chan device.USBEvent
 
                        ueventLen--
 
+                       if udevEvent {
+                               // The kernel always prepends this and udev 
expects it.
+                               kernelPrefix := fmt.Sprintf("%s@%s", 
props["ACTION"], props["DEVPATH"])
+                               ueventParts = append([]string{kernelPrefix}, 
ueventParts...)
+                               ueventLen += len(kernelPrefix)
+                       }
+
                        if props["SUBSYSTEM"] == "cpu" && !udevEvent {
                                if props["DRIVER"] != "processor" {
                                        continue
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to