Este contenido no está disponible en el idioma seleccionado.
Chapter 5. Starting virtual machines
To start a virtual machine (VM) in RHEL 10, you can use the command line interface or the web console GUI.
Prerequisites
- Before a VM can be started, it must be created and, ideally, also installed with an OS. See Creating virtual machines.
5.1. Starting a virtual machine by using the command line Copiar enlaceEnlace copiado en el portapapeles!
You can use the command line interface (CLI) to start a shut-down virtual machine (VM) or restore a saved VM. By using the CLI, you can start both local and remote VMs.
Prerequisites
- An inactive VM that is already defined.
- The name of the VM.
For remote VMs:
- The IP address of the host where the VM is located.
- Root access privileges to the host.
-
If you want to start a VM that uses the
systemconnection of libvirt, you must have root privileges or be in thelibvirtuser group on the host. For more information, see User-space connection types for virtualization.
Procedure
For a local VM, use the
virsh startutility.For example, the following command starts the demo-guest1 VM.
virsh start demo-guest1
# virsh start demo-guest1 Domain 'demo-guest1' startedCopy to Clipboard Copied! Toggle word wrap Toggle overflow For a VM located on a remote host, use the
virsh startutility along with the QEMU+SSH connection to the host.For example, the following command starts the demo-guest1 VM on the 192.0.2.1 host.
virsh -c qemu+ssh://root@192.0.2.1/system start demo-guest1
# virsh -c qemu+ssh://root@192.0.2.1/system start demo-guest1 root@192.0.2.1's password: Domain 'demo-guest1' startedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Starting virtual machines by using the web console Copiar enlaceEnlace copiado en el portapapeles!
If a virtual machine (VM) is in the shut off state, you can start it by using the RHEL 10 web console. You can also configure the VM to be started automatically when the host starts.
Prerequisites
You have installed the RHEL 10 web console.
For instructions, see Installing and enabling the web console.
- The web console VM plugin is installed on your system.
- An inactive VM that is already defined.
- The name of the VM.
-
If you want to start a VM that uses the
systemconnection of libvirt, you must have root privileges or be in thelibvirtuser group on the host. For more information, see User-space connection types for virtualization.
Procedure
In the interface, click the VM you want to start.
A new page opens with detailed information about the selected VM and controls for shutting down and deleting the VM.
Click .
The VM starts, and you can connect to its console or graphical output.
Optional: To configure the VM to start automatically when the host starts, toggle the
Autostartcheckbox in the Overview section.If you use network interfaces that are not managed by libvirt, you must also make additional changes to the systemd configuration. Otherwise, the affected VMs might fail to start, see starting virtual machines automatically when the host starts.
5.3. Starting virtual machines automatically when the host starts Copiar enlaceEnlace copiado en el portapapeles!
When a host with a running virtual machine (VM) restarts, the VM is shut down, and must be started again manually by default. To ensure a VM is active whenever its host is running, you can configure the VM to be started automatically.
Prerequisites
Procedure
Use the
virsh autostartutility to configure the VM to start automatically when the host starts.For example, the following command configures the demo-guest1 VM to start automatically.
virsh autostart demo-guest1
# virsh autostart demo-guest1 Domain 'demo-guest1' marked as autostartedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you use network interfaces that are not managed by
libvirt, you must also make additional changes to the systemd configuration. Otherwise, the affected VMs might fail to start.NoteThese interfaces include for example:
-
Bridge devices created by
NetworkManager -
Networks configured to use
<forward mode='bridge'/>
In the systemd configuration directory tree, create a
virtqemud.service.ddirectory if it does not exist yet.mkdir -p /etc/systemd/system/virtqemud.service.d/
# mkdir -p /etc/systemd/system/virtqemud.service.d/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
10-network-online.confsystemd unit override file in the previously created directory. The content of this file overrides the default systemd configuration for thevirtqemudservice.touch /etc/systemd/system/virtqemud.service.d/10-network-online.conf
# touch /etc/systemd/system/virtqemud.service.d/10-network-online.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following lines to the
10-network-online.conffile. This configuration change ensures systemd starts thevirtqemudservice only after the network on the host is ready.[Unit] After=network-online.target
[Unit] After=network-online.targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Bridge devices created by
Verification
View the VM configuration, and check that the autostart option is enabled.
For example, the following command displays basic information about the demo-guest1 VM, including the autostart option.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use network interfaces that are not managed by libvirt, check if the content of the
10-network-online.conffile matches the following output.cat /etc/systemd/system/virtqemud.service.d/10-network-online.conf [Unit] After=network-online.target
$ cat /etc/systemd/system/virtqemud.service.d/10-network-online.conf [Unit] After=network-online.targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow