diff --git a/go.mod b/go.mod index e002d13c55..2e88bb8826 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/containers/common v0.55.1-0.20230830075933-12405381ff45 github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa - github.com/containers/libhvee v0.4.1-0.20230816135538-b81ee3f10e1e + github.com/containers/libhvee v0.4.1-0.20230830164110-3777cdaa7db8 github.com/containers/ocicrypt v1.1.8 github.com/containers/psgo v1.8.0 github.com/containers/storage v1.49.1-0.20230823084450-6902c2df7cca diff --git a/go.sum b/go.sum index 057668d13f..e53b6b8777 100644 --- a/go.sum +++ b/go.sum @@ -252,8 +252,8 @@ github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6J github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa h1:wDfVQtc6ik2MvsUmu/YRSyBAE5YUxdjcEDtuT1q2KDo= github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa/go.mod h1:apL4qwq31NV0gsSZQJPxYyTH0yzWavmMCjT8vsQaXSk= -github.com/containers/libhvee v0.4.1-0.20230816135538-b81ee3f10e1e h1:j8QuCCOnTxQNtVwARhgUhe3+QYhXpcuoy9YuIgpLWDE= -github.com/containers/libhvee v0.4.1-0.20230816135538-b81ee3f10e1e/go.mod h1:I30im5oKCYBJMEa+r0jffZn+Yb5/8CnYeAJy+vb77Mg= +github.com/containers/libhvee v0.4.1-0.20230830164110-3777cdaa7db8 h1:PTtzc5IcpcdHp9vLjE1cpT19Qo1GpouFTFE+rL0UO5I= +github.com/containers/libhvee v0.4.1-0.20230830164110-3777cdaa7db8/go.mod h1:I30im5oKCYBJMEa+r0jffZn+Yb5/8CnYeAJy+vb77Mg= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY= github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc= diff --git a/pkg/machine/gvproxy.go b/pkg/machine/gvproxy.go index f159b8266c..1dddb1c1f1 100644 --- a/pkg/machine/gvproxy.go +++ b/pkg/machine/gvproxy.go @@ -2,6 +2,7 @@ package machine import ( "fmt" + "runtime" "strconv" "syscall" "time" @@ -40,15 +41,17 @@ func waitOnProcess(processID int) error { } // Try to kill the pid with sigterm - if err := proxyProc.Signal(syscall.SIGTERM); err != nil { - if err == syscall.ESRCH { + if runtime.GOOS != "windows" { // FIXME: temporary work around because signals are lame in windows + if err := proxyProc.Signal(syscall.SIGTERM); err != nil { + if err == syscall.ESRCH { + return nil + } + return err + } + + if err := backoffForProcess(processID); err == nil { return nil } - return err - } - - if err := backoffForProcess(processID); err == nil { - return nil } // sigterm has not killed it yet, lets send a sigkill diff --git a/pkg/machine/hyperv/config.go b/pkg/machine/hyperv/config.go index 19a731bd56..0a096ba345 100644 --- a/pkg/machine/hyperv/config.go +++ b/pkg/machine/hyperv/config.go @@ -106,6 +106,8 @@ func (v HyperVVirtualization) NewMachine(opts machine.InitOptions) (machine.VM, return nil, errors.New("must define --image-path for hyperv support") } + m.RemoteUsername = opts.Username + configDir, err := machine.GetConfDir(machine.HyperVVirt) if err != nil { return nil, err diff --git a/pkg/machine/hyperv/machine.go b/pkg/machine/hyperv/machine.go index 668cad27c1..faccea4ee9 100644 --- a/pkg/machine/hyperv/machine.go +++ b/pkg/machine/hyperv/machine.go @@ -131,7 +131,7 @@ Description=vsock_network After=NetworkManager.service [Service] -ExecStart=/usr/libexec/podman/gvforwader -preexisting -iface vsock0 -url vsock://2:%d/connect +ExecStart=/usr/libexec/podman/gvforwarder -preexisting -iface vsock0 -url vsock://2:%d/connect ExecStartPost=/usr/bin/nmcli c up vsock0 [Install] @@ -316,7 +316,7 @@ func (m *HyperVMachine) collectFilesToDestroy(opts machine.RemoveOptions, diskPa files = append(files, *diskPath) } - files = append(files, getVMConfigPath(m.ConfigPath.GetPath(), m.Name)) + files = append(files, m.ConfigPath.GetPath()) return files } @@ -354,6 +354,11 @@ func (m *HyperVMachine) Remove(_ string, opts machine.RemoveOptions) (string, fu } } + vm, err = vmm.GetMachine(m.Name) + if err != nil { + return "", nil, err + } + // Collect all the files that need to be destroyed files = m.collectFilesToDestroy(opts, &diskPath) @@ -366,7 +371,7 @@ func (m *HyperVMachine) Remove(_ string, opts machine.RemoveOptions) (string, fu return confirmationMessage, func() error { machine.RemoveFilesAndConnections(files, m.Name, m.Name+"-root") m.removeNetworkAndReadySocketsFromRegistry() - return vm.Remove(diskPath) + return vm.Remove("") }, nil } @@ -503,7 +508,11 @@ func (m *HyperVMachine) Stop(name string, opts machine.StopOptions) error { if err != nil { return err } - if vm.State() != hypervctl.Enabled { + vmState := vm.State() + if vm.State() == hypervctl.Disabled { + return nil + } + if vmState != hypervctl.Enabled { // more states could be provided as well return hypervctl.ErrMachineStateInvalid } diff --git a/vendor/github.com/containers/libhvee/pkg/hypervctl/vm.go b/vendor/github.com/containers/libhvee/pkg/hypervctl/vm.go index 1fbff4ee3e..b710582b13 100644 --- a/vendor/github.com/containers/libhvee/pkg/hypervctl/vm.go +++ b/vendor/github.com/containers/libhvee/pkg/hypervctl/vm.go @@ -240,7 +240,7 @@ func (vm *VirtualMachine) Stop() error { } // Wait for vm to actually *be* down - for i := 0; i < 25; i++ { + for i := 0; i < 200; i++ { refreshVM, err := vm.vmm.GetMachine(vm.ElementName) if err != nil { return err diff --git a/vendor/modules.txt b/vendor/modules.txt index 2357910a2e..34d7fb2ad8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -286,7 +286,7 @@ github.com/containers/image/v5/transports github.com/containers/image/v5/transports/alltransports github.com/containers/image/v5/types github.com/containers/image/v5/version -# github.com/containers/libhvee v0.4.1-0.20230816135538-b81ee3f10e1e +# github.com/containers/libhvee v0.4.1-0.20230830164110-3777cdaa7db8 ## explicit; go 1.18 github.com/containers/libhvee/pkg/hypervctl github.com/containers/libhvee/pkg/kvp/ginsu