From 99db38c51d6b9eb1fd9969aa918c1a6dd5cf2cde Mon Sep 17 00:00:00 2001 From: German Maglione Date: Thu, 4 Jul 2024 14:15:37 +0200 Subject: [PATCH 1/3] Remove useless config load Both the ssh port and identity are provided on each run, so it is unnecessary of doing it while loading the domain. Signed-off-by: German Maglione --- pkg/vm/vm_linux.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkg/vm/vm_linux.go b/pkg/vm/vm_linux.go index 72e61df8..d35f4082 100644 --- a/pkg/vm/vm_linux.go +++ b/pkg/vm/vm_linux.go @@ -287,16 +287,6 @@ func (v *BootcVMLinux) loadExistingDomain() (err error) { } } - // if domain exists, load it's config - if v.domain != nil { - cfg, err := v.GetConfig() - if err != nil { - return fmt.Errorf("unable to load VM config: %w", err) - } - v.sshPort = cfg.SshPort - v.sshIdentity = cfg.SshIdentity - } - return nil } From 5312ba96134d58123e5865b72e68318544afcecd Mon Sep 17 00:00:00 2001 From: German Maglione Date: Thu, 4 Jul 2024 14:21:00 +0200 Subject: [PATCH 2/3] Remove unused wait group The 'WaitForSSHToBeReady()' call will make it to wait until the VM is ready, to stop printing the console. Signed-off-by: German Maglione --- cmd/run.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 021a2ac3..b2bf7f70 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "os" - "sync" "time" "github.com/containers/podman-bootc/pkg/bootc" @@ -159,8 +158,6 @@ func doRun(flags *cobra.Command, args []string) error { if !vmConfig.Background { if !vmConfig.Quiet { - var vmConsoleWg sync.WaitGroup - vmConsoleWg.Add(1) go func() { err := bootcVM.PrintConsole() if err != nil { @@ -173,8 +170,6 @@ func doRun(flags *cobra.Command, args []string) error { return fmt.Errorf("WaitSshReady: %w", err) } - vmConsoleWg.Done() //stop printing the VM console when SSH is ready - // the PrintConsole routine is suddenly stopped without waiting for // the print buffer to be flushed, this can lead to the consoel output // printing after the ssh prompt begins. Sleeping for a second From 34ea90f9a472c6316cbbc1d4411301fd66fc15eb Mon Sep 17 00:00:00 2001 From: German Maglione Date: Mon, 8 Jul 2024 17:33:09 +0200 Subject: [PATCH 3/3] Remove unused user parameter Signed-off-by: German Maglione --- cmd/run.go | 2 +- pkg/utils/podman.go | 8 +++----- podman-bootc.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index b2bf7f70..53926342 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -67,7 +67,7 @@ func doRun(flags *cobra.Command, args []string) error { } //podman machine connection - machineInfo, err := utils.GetMachineInfo(user) + machineInfo, err := utils.GetMachineInfo() if err != nil { return err } diff --git a/pkg/utils/podman.go b/pkg/utils/podman.go index 7e37304d..35c0d3b6 100644 --- a/pkg/utils/podman.go +++ b/pkg/utils/podman.go @@ -7,8 +7,6 @@ import ( "os/exec" "strings" - "github.com/containers/podman-bootc/pkg/user" - "github.com/containers/podman/v5/pkg/machine" "github.com/containers/podman/v5/pkg/machine/define" "github.com/containers/podman/v5/pkg/machine/env" @@ -22,13 +20,13 @@ type MachineInfo struct { Rootful bool } -func GetMachineInfo(user user.User) (*MachineInfo, error) { +func GetMachineInfo() (*MachineInfo, error) { minfo, err := getMachineInfo() if err != nil { var errIncompatibleMachineConfig *define.ErrIncompatibleMachineConfig var errVMDoesNotExist *define.ErrVMDoesNotExist if errors.As(err, &errIncompatibleMachineConfig) || errors.As(err, &errVMDoesNotExist) { - minfo, err := getPv4MachineInfo(user) + minfo, err := getPv4MachineInfo() if err != nil { return nil, err } @@ -71,7 +69,7 @@ func getMachineInfo() (*MachineInfo, error) { } // Just to support podman v4.9, it will be removed in the future -func getPv4MachineInfo(user user.User) (*MachineInfo, error) { +func getPv4MachineInfo() (*MachineInfo, error) { //check if a default podman machine exists listCmd := exec.Command("podman", "machine", "list", "--format", "json") var listCmdOutput strings.Builder diff --git a/podman-bootc.go b/podman-bootc.go index 3f19c2ad..d7f418dc 100644 --- a/podman-bootc.go +++ b/podman-bootc.go @@ -24,7 +24,7 @@ func cleanup() { } //podman machine connection - machineInfo, err := utils.GetMachineInfo(user) + machineInfo, err := utils.GetMachineInfo() if err != nil { logrus.Errorf("unable to get podman machine info: %s", err) os.Exit(1)