3.3. Performing Actions on Virtual Environments¶
Use virsh to manage virtual environments. By default virsh connects to the qemu:///system hypervisor used for virtual machines. To manage containers, connect to the vzct:///system hypervisor instead with --connect vzct:///system.
To start a virtual machine, use
virsh start. For example:# virsh start mylinuxvm Domain mylinuxvm started
To start a container, use the same command with the corresponding hypervisor. For example:
# virsh --connect vzct:///system start mylinuxct Domain mylinuxct started
Note
You may need to install the
prl-vzvncserver.x86_64package to be able to start containers.To connect to a running virtual environment via VNC, use the port you provided in the creation command in the
--graphicsoption, e.g.,port=5901.To connect to a running container, use
vzctl enter <CT_name_or_ID>.To stop a virtual environment, use either
virsh shutdown(graceful) orvirsh destroy(forced, which may corrupt virtual environment’s hard disks). For example:# virsh shutdown mylinuxvm Domain mylinuxvm is being shutdown # virsh --connect vzct:///system destroy mylinuxct Domain mylinuxct destroyed
To delete a stopped virtual environment, use
virsh undefine. This command will only delete the virtual environment’s configuration. The hard disks will not be deleted. For example:# virsh undefine mylinuxvm Domain mylinuxvm has been undefined