diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-29 09:52:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 09:52:14 -0400 |
commit | c01b1cbfcd205678af820d43b1966025e9c463e7 (patch) | |
tree | 0930fc2f331c00cc4564071326bb2121371388ae /cmd/podman | |
parent | e7e97956b4a0ab66e1f1f2b453745b38d21f0703 (diff) | |
parent | 53057d5c20b2abf7ffc672972cbc83018ba0ed6c (diff) | |
download | podman-c01b1cbfcd205678af820d43b1966025e9c463e7.tar.gz podman-c01b1cbfcd205678af820d43b1966025e9c463e7.tar.bz2 podman-c01b1cbfcd205678af820d43b1966025e9c463e7.zip |
Merge pull request #10170 from ashley-cui/machineone
[NO TESTS NEEDED] Check if another VM is running on machine start
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/machine/start.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/podman/machine/start.go b/cmd/podman/machine/start.go index d06e04f41..4334cfc0f 100644 --- a/cmd/podman/machine/start.go +++ b/cmd/podman/machine/start.go @@ -7,6 +7,7 @@ import ( "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/machine" "github.com/containers/podman/v3/pkg/machine/qemu" + "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -40,6 +41,18 @@ func start(cmd *cobra.Command, args []string) error { if len(args) > 0 && len(args[0]) > 0 { vmName = args[0] } + + // We only have qemu VM's for now + active, activeName, err := qemu.CheckActiveVM() + if err != nil { + return err + } + if active { + if vmName == activeName { + return errors.Wrapf(machine.ErrVMAlreadyRunning, "cannot start VM %s", vmName) + } + return errors.Wrapf(machine.ErrMultipleActiveVM, "cannot start VM %s. VM %s is currently running", vmName, activeName) + } switch vmType { default: vm, err = qemu.LoadVMByName(vmName) |