[lxc-devel] [lxd/master] lxd/vm: Add udev rule fallback

stgraber on Github lxc-bot at linuxcontainers.org
Mon Jun 22 19:29:16 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200622/4003da0f/attachment.bin>
-------------- next part --------------
From 315ed71cd206ebb30d95b6fbe9d3121c431167a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 22 Jun 2020 15:27:42 -0400
Subject: [PATCH] lxd/vm: Add udev rule fallback
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/instance/drivers/driver_qemu.go | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index 8ebb0fdd41..b76f5f31c8 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -1341,6 +1341,19 @@ WantedBy=multi-user.target
 		return err
 	}
 
+	// Udev rules
+	err = os.MkdirAll(filepath.Join(configDrivePath, "udev"), 0500)
+	if err != nil {
+		return err
+	}
+
+	lxdAgentRules := `ACTION=="add", SYMLINK=="virtio-ports/org.linuxcontainers.lxd", TAG+="systemd", ACTION=="add", RUN+="/bin/systemctl start lxd-agent.service"`
+	err = ioutil.WriteFile(filepath.Join(configDrivePath, "udev", "99-lxd-agent.rules"), []byte(lxdAgentRules), 0400)
+	if err != nil {
+		return err
+	}
+
+
 	// Install script for manual installs.
 	lxdConfigShareInstall := `#!/bin/sh
 if [ ! -e "systemd" ] || [ ! -e "lxd-agent" ]; then
@@ -1353,6 +1366,7 @@ if [ ! -e "/lib/systemd/system" ]; then
     exit 1
 fi
 
+cp udev/99-lxd-agent.rules /lib/udev/rules.d/
 cp systemd/lxd-agent.service /lib/systemd/system/
 cp systemd/lxd-agent-9p.service /lib/systemd/system/
 systemctl daemon-reload


More information about the lxc-devel mailing list