This is a cache of https://docs.openshift.com/container-platform/4.2/cnv/cnv_users_guide/cnv-controlling-vm-states.html. It is a snapshot of the page at 2024-11-23T02:37:39.505+0000.
Controlling virtual machines states - Container-native virtualization <strong>user</strong>'s guide | Container-native virtualization | OpenShift Container Platform 4.2
×

With container-native virtualization, you can stop, start, and restart virtual machines from both the web console and the command-line interface (CLI).

Controlling virtual machines from the web console

You can also stop, start, and restart virtual machines from the web console.

Starting a virtual machine

You can start a virtual machine from the web console.

Procedure
  1. In the container-native virtualization console, click WorkloadsVirtual Machines.

  2. Start the virtual machine from this screen, which makes it easier to perform actions on multiple virtual machines in the one screen, or from the Virtual Machine Details screen where you can view comprehensive details of the selected virtual machine:

    • Click the Options menu kebab at the end of virtual machine and select Start Virtual Machine.

    • Click the virtual machine name to open the Virtual Machine Details screen and click Actions and select Start Virtual Machine.

  3. In the confirmation window, click Start to start the virtual machine.

When you start virtual machine that is provisioned from a URL source for the first time, the virtual machine is in the Importing state while container-native virtualization imports the container from the URL endpoint. Depending on the size of the image, this process might take several minutes.

Restarting a virtual machine

You can restart a running virtual machine from the web console.

Do not restart a virtual machine while it has a status of Importing. Restarting the virtual machine causes an error for it.

Procedure
  1. In the container-native virtualization console, click WorkloadsVirtual Machines.

  2. Restart the virtual machine from this screen, which makes it easier to perform actions on multiple virtual machines in the one screen, or from the Virtual Machine Details screen where you can view comprehensive details of the selected virtual machine:

    • Click the Options menu kebab at the end of virtual machine and select Restart Virtual Machine.

    • Click the virtual machine name to open the Virtual Machine Details screen and click Actions and select Restart Virtual Machine.

  3. In the confirmation window, click Restart to restart the virtual machine.

Stopping a virtual machine

You can stop a virtual machine from the web console.

Procedure
  1. In the container-native virtualization console, click WorkloadsVirtual Machines.

  2. Stop the virtual machine from this screen, which makes it easier to perform actions on multiple virtual machines in the one screen, or from the Virtual Machine Details screen where you can view comprehensive details of the selected virtual machine:

    • Click the Options menu kebab at the end of virtual machine and select Stop Virtual Machine.

    • Click the virtual machine name to open the Virtual Machine Details screen and click Actions and select Stop Virtual Machine.

  3. In the confirmation window, click Stop to stop the virtual machine.

CLI reference for controlling virtual machines

Use the following virtctl client utility and oc commands to change the state of the virtual machines and display lists of the virtual machines and the virtual machine instances that represent them.

When you run virtctl commands, you modify the virtual machines themselves, not the virtual machine instances that represent them in the web console.

start

Start a virtual machine.

Example: Start a virtual machine in the current project
$ virtctl start <example-vm>
Example: Start a virtual machine in a specific project
$ virtctl start <example-vm> -n <project_name>

restart

Restart a running virtual machine.

Example: Restart a virtual machine in the current project
$ virtctl restart <example-vm>
Example: Restart a virtual machine in a specific project
$ virtctl restart <example-vm> -n <project_name>

stop

Stop a running virtual machine.

Example: Stop a virtual machine in the current project
$ virtctl stop <example-vm>
Example: Stop a virtual machine in a specific project
$ virtctl stop <example-vm> -n <project_name>

list

List the virtual machines or virtual machine instances in a project. The virtual machine instances are abstractions that represent the virtual machines themselves.

Example: List the virtual machines in the current project
$ oc get vm
Example: List the virtual machines in a specific project
$ oc get vm -n <project_name>
Example: List the running virtual machine instances in the current project
$ oc get vmi
Example: List the running virtual machine instances in a specific project
$ oc get vmi -n <project_name>