Polish code
This commit is contained in:
parent
8af3ab3fb6
commit
0870f8113a
10 changed files with 246 additions and 238 deletions
5
vm/vm.go
5
vm/vm.go
|
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"log/slog"
|
||||
|
||||
"github.com/AlexSSD7/linsk/sshutil"
|
||||
"github.com/AlexSSD7/linsk/utils"
|
||||
"github.com/alessio/shellescape"
|
||||
"github.com/bramvdbogaerde/go-scp"
|
||||
|
|
@ -91,8 +92,6 @@ func NewVM(logger *slog.Logger, cfg VMConfig) (*VM, error) {
|
|||
return nil, errors.Wrap(err, "get free port for ssh server")
|
||||
}
|
||||
|
||||
// TODO: Configurable memory allocation
|
||||
|
||||
cmdArgs := []string{"-serial", "stdio", "-m", fmt.Sprint(cfg.MemoryAlloc), "-smp", fmt.Sprint(runtime.NumCPU())}
|
||||
|
||||
baseCmd := "qemu-system"
|
||||
|
|
@ -373,7 +372,7 @@ func (vm *VM) Cancel() error {
|
|||
}
|
||||
} else {
|
||||
vm.logger.Warn("Sending poweroff command to the VM")
|
||||
_, err = runSSHCmd(sc, "poweroff")
|
||||
_, err = sshutil.RunSSHCmd(context.Background(), sc, "poweroff")
|
||||
_ = sc.Close()
|
||||
if err != nil {
|
||||
vm.logger.Warn("Could not power off the VM safely", "error", err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue