From ea1436650a3f5495bc159dccea1fe5f7bb8d9b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 15 Feb 2024 22:39:23 -0500 Subject: [PATCH] incus-agent: Load virtio_net before configuring NICs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some distros, virtio_net may not be loaded by the time the agent starts up. This isn't really a problem normally as the agent doesn't need access to the network, but it is a problem if the user is using agent.nic_config to rename network interfaces. So just attempt to load virtio_net prior to performing any reconfiguration. Signed-off-by: Stéphane Graber --- cmd/incus-agent/network.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/incus-agent/network.go b/cmd/incus-agent/network.go index a044ad6356e..09c85513640 100644 --- a/cmd/incus-agent/network.go +++ b/cmd/incus-agent/network.go @@ -10,6 +10,7 @@ import ( "github.com/lxc/incus/internal/revert" deviceConfig "github.com/lxc/incus/internal/server/device/config" + "github.com/lxc/incus/internal/linux" "github.com/lxc/incus/internal/server/ip" "github.com/lxc/incus/internal/server/util" "github.com/lxc/incus/shared/logger" @@ -72,6 +73,9 @@ func reconfigureNetworkInterfaces() { return } + // Attempt to load the virtio_net driver in case it's not be loaded yet. + _ = linux.LoadModule("virtio_net") + // nicData is a map of MAC address to NICConfig. nicData := make(map[string]deviceConfig.NICConfig, len(nicDirEntries))