f-37: add systemd-run
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
2150530ef2
commit
c89e3f64de
2 changed files with 14 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue