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
|
||||
|
||||
func ScopeName(vmName string) string {
|
||||
return "two-vm-" + vmName + ".scope"
|
||||
}
|
||||
|
||||
type DiskConfig struct {
|
||||
Path string
|
||||
Dev string
|
||||
|
|
|
|||
|
|
@ -103,9 +103,16 @@ func Start(cfg Config) error {
|
|||
"-daemonize",
|
||||
)
|
||||
|
||||
cmd := exec.Command("qemu-system-x86_64", args...)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("qemu-system-x86_64: %w", err)
|
||||
scopeArgs := append([]string{
|
||||
"--scope",
|
||||
"--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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue