f-37: add systemd-run

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-08-14 00:27:25 +02:00
commit c89e3f64de
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
2 changed files with 14 additions and 3 deletions

View file

@ -1,5 +1,9 @@
package qemu package qemu
func ScopeName(vmName string) string {
return "two-vm-" + vmName + ".scope"
}
type DiskConfig struct { type DiskConfig struct {
Path string Path string
Dev string Dev string

View file

@ -103,9 +103,16 @@ func Start(cfg Config) error {
"-daemonize", "-daemonize",
) )
cmd := exec.Command("qemu-system-x86_64", args...) scopeArgs := append([]string{
if err := cmd.Run(); err != nil { "--scope",
return fmt.Errorf("qemu-system-x86_64: %w", err) "--unit=" + ScopeName(cfg.Name),
"--collect",
"qemu-system-x86_64",
}, args...)
cmd := exec.Command("systemd-run", scopeArgs...)
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("systemd-run qemu-system-x86_64: %w: %s", err, strings.TrimSpace(string(out)))
} }
return nil return nil
} }