[lxc-devel] [lxd/master] unix-hotplug: fix uevent injection
brauner on Github
lxc-bot at linuxcontainers.org
Wed May 27 14:48:21 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200527/c4250b42/attachment.bin>
-------------- next part --------------
From 5b5d38b5481f5b6dcfa95ef7e1834c86b6e30640 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 27 May 2020 16:44:53 +0200
Subject: [PATCH] unix-hotplug: fix uevent injection
Signed-off-by: Christian Brauner <christian.brauner at 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
More information about the lxc-devel
mailing list