mirror of
https://github.com/containers/podman.git
synced 2025-11-02 23:39:52 +08:00
Correct VM existance check on WSL
Replaces GetHyperVisorVMs() with Exists() to better abstract the underlying use-case and slightly imrpove efficiency. Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/containers/common/pkg/util"
|
||||
"github.com/containers/podman/v5/pkg/machine"
|
||||
"github.com/containers/podman/v5/pkg/machine/connection"
|
||||
machineDefine "github.com/containers/podman/v5/pkg/machine/define"
|
||||
@ -243,11 +242,11 @@ func VMExists(name string, vmstubbers []vmconfigs.VMProvider) (*vmconfigs.Machin
|
||||
}
|
||||
// Check with the provider hypervisor
|
||||
for _, vmstubber := range vmstubbers {
|
||||
vms, err := vmstubber.GetHyperVisorVMs()
|
||||
exists, err := vmstubber.Exists(name)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if util.StringInSlice(name, vms) { //nolint:staticcheck
|
||||
if exists {
|
||||
return nil, true, fmt.Errorf("vm %q already exists on hypervisor", name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user