mirror of
https://github.com/containers/podman.git
synced 2025-06-02 19:02:10 +08:00
Check if another VM is running on machine start
Only one VM can be up at a time. If another VM is running, or the current VM is running, error out on a podman machine start [NO TESTS NEEDED] Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
@ -519,3 +519,17 @@ func IsValidVMName(name string) (bool, error) {
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// CheckActiveVM checks if there is a VM already running
|
||||
func CheckActiveVM() (bool, string, error) {
|
||||
vms, err := GetVMInfos()
|
||||
if err != nil {
|
||||
return false, "", errors.Wrap(err, "error checking VM active")
|
||||
}
|
||||
for _, vm := range vms {
|
||||
if vm.Running {
|
||||
return true, vm.Name, nil
|
||||
}
|
||||
}
|
||||
return false, "", nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user