Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

spindle/microvm: use consistent qmp sock paths to avoid the AF_UNIX path limit

Signed-off-by: dawn <dawn@tangled.org>

+27 -1
+4
docker-compose.yml
··· 151 151 SPINDLE_MICROVM_PIPELINES_OVERLAY_DIR: /var/lib/spindle/overlays 152 152 SPINDLE_MICROVM_PIPELINES_AGENT_PORT: "11240" 153 153 SPINDLE_S3_LOG_BUCKET: "" 154 + SPINDLE_MICROVM_PIPELINES_ENABLE_CGROUPS: "false" 155 + # these two are required for cgroups, uncomment if testing 156 + # privileged: true 157 + # cgroup: host 154 158 devices: 155 159 - /dev/vsock:/dev/vsock 156 160 - /dev/kvm:/dev/kvm
+23 -1
spindle/engines/microvm/qemu.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "crypto/sha256" 5 6 _ "embed" 7 + "encoding/hex" 6 8 "encoding/json" 7 9 "errors" 8 10 "fmt" ··· 54 56 serialLogPath string 55 57 workDir string 56 58 59 + qmpSocketPath string 60 + 57 61 cmd *exec.Cmd 58 62 done chan struct{} 59 63 qemuLogFile *os.File ··· 108 112 }, logger) 109 113 } 110 114 115 + // we hash the workDir to get a deterministic qmpSock path 116 + // since they are AF_UNIX sockets, they are bound by a 108 char long path limit... 117 + func qmpSocketPath(workDir string) string { 118 + base := filepath.Dir(workDir) 119 + if workDir == "" { 120 + base = os.TempDir() 121 + } 122 + sum := sha256.Sum256([]byte(workDir)) 123 + return filepath.Join(base, hex.EncodeToString(sum[:8])+".qmp.sock") 124 + } 125 + 111 126 func StartQEMU(ctx context.Context, cfg QEMUConfig, logger *slog.Logger) (VMHandle, error) { 112 127 if logger == nil { 113 128 logger = slog.Default() ··· 163 178 164 179 qmpPath := cfg.QMPPath 165 180 if qmpPath == "" { 166 - qmpPath = filepath.Join(workDir, "qmp.sock") 181 + qmpPath = qmpSocketPath(workDir) 182 + handle.qmpSocketPath = qmpPath 167 183 } 168 184 handle.QMPPath = qmpPath 169 185 ··· 334 350 if h.cgroup != nil { 335 351 closeErr = errors.Join(closeErr, h.cgroup.Close()) 336 352 h.cgroup = nil 353 + } 354 + if h.qmpSocketPath != "" { 355 + if err := os.Remove(h.qmpSocketPath); err != nil && !os.IsNotExist(err) { 356 + closeErr = errors.Join(closeErr, err) 357 + } 358 + h.qmpSocketPath = "" 337 359 } 338 360 return closeErr 339 361 }