mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-12 18:26:39 +02:00
43 lines
1.5 KiB
Diff
43 lines
1.5 KiB
Diff
From 0245196848951cf6b21081923346d3995c715ce0 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@stgraber.org>
|
|
Date: Wed, 3 Jan 2024 15:40:24 -0500
|
|
Subject: [PATCH] lxd/instance/drivers/driver/lxc: Re-generate lxc.conf during
|
|
Exec
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
|
|
(cherry picked from commit 36b995ef876e04ec4f54e1a8f82e178980276392)
|
|
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
|
|
License: Apache-2.0
|
|
---
|
|
lxd/instance/drivers/driver_lxc.go | 15 +++++++++++++++
|
|
1 file changed, 15 insertions(+)
|
|
|
|
diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
|
|
index 09c82f1dbf93..be82efe7065f 100644
|
|
--- a/lxd/instance/drivers/driver_lxc.go
|
|
+++ b/lxd/instance/drivers/driver_lxc.go
|
|
@@ -7071,6 +7071,21 @@ func (d *lxc) ConsoleLog(opts liblxc.ConsoleLogOptions) (string, error) {
|
|
|
|
// Exec executes a command inside the instance.
|
|
func (d *lxc) Exec(req api.InstanceExecPost, stdin *os.File, stdout *os.File, stderr *os.File) (instance.Cmd, error) {
|
|
+ // Generate the LXC config if missing.
|
|
+ configPath := filepath.Join(d.LogPath(), "lxc.conf")
|
|
+ if !shared.PathExists(configPath) {
|
|
+ cc, err := d.initLXC(true)
|
|
+ if err != nil {
|
|
+ return nil, fmt.Errorf("Load go-lxc struct: %w", err)
|
|
+ }
|
|
+
|
|
+ err = cc.SaveConfigFile(configPath)
|
|
+ if err != nil {
|
|
+ _ = os.Remove(configPath)
|
|
+ return nil, err
|
|
+ }
|
|
+ }
|
|
+
|
|
// Prepare the environment
|
|
envSlice := []string{}
|
|
|