Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 7. Connecting to virtual machines
To interact with a virtual machine (VM) in RHEL 10, you need to connect to it by doing one of the following:
- For connecting to a VM graphical display in a graphical user interface, use the Virtual Machines pane in the RHEL web console.
-
If you need to interact with a VM graphical display without using the web console, use the
Virt Viewerapplication. - When a graphical display is not possible or not necessary, use an SSH terminal connection.
-
When the virtual machine is not reachable from your system by using a network, use the
virshconsole.
7.1. Connecting to virtual machines by using the web console Link kopierenLink in die Zwischenablage kopiert!
To connect to running KVM virtual machines, you can use the web console interface.
7.1.1. Opening a virtual machine graphical console in the web console Link kopierenLink in die Zwischenablage kopiert!
To view and interact with the graphical output of a selected virtual machine (VM) in the RHEL 10 web console, use the VNC console or a remote viewer tool.
Prerequisites
You have installed the RHEL 10 web console.
For instructions, see Installing and enabling the web console.
- The web console VM plug-in is installed on your system.
- Ensure that both the host and the VM support a graphical interface.
- The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
- Log in to the RHEL 10 web console.
In the interface, click the VM whose graphical console you want to view.
A new page opens with an Overview and a Console section for the VM.
Select in the console drop down menu.
The VNC console appears below the menu in the web interface.
The graphical console appears in the web interface.
Click
You can now interact with the VM console by using the mouse and keyboard in the same manner you interact with a real machine. The display in the VM console reflects the activities being performed on the VM.
NoteThe host on which the web console is running may intercept specific key combinations, such as Ctrl+Alt+Del, which prevents them from being sent to the VM.
To send such key combinations, click the menu and select the key sequence to send.
For example, to send the Ctrl+Alt+Del combination to the VM, click the and select the menu entry.
Optional: You can also display the graphical console of a selected VM in a remote viewer, such as Virt Viewer.
- Select in the console drop down menu.
Click .
The virt viewer,
.vv, file downloads.Open the file to launch Virt Viewer.
NoteYou can launch Virt Viewer from within the web console. Other VNC remote viewers can be launched manually.
Troubleshooting
- If clicking in the graphical console does not have any effect, expand the console to full screen. This is a known issue with the mouse cursor offset.
If launching the Remote Viewer in the web console does not work or is not optimal, you can manually connect with any viewer application by using the following protocols:
-
Address - The default address is
127.0.0.1. You can modify thevnc_listenparameter in/etc/libvirt/qemu.confto change it to the host’s IP address. - VNC port - 5901
-
Address - The default address is
7.1.2. Opening a virtual machine serial console in the web console Link kopierenLink in die Zwischenablage kopiert!
You can view the serial console of a selected virtual machine (VM) in the RHEL 10 web console. This is useful when the host machine or the VM is not configured with a graphical interface.
For more information about the serial console, see Opening a virtual machine serial console by using the command line interface.
Prerequisites
You have installed the RHEL 10 web console.
For instructions, see Installing and enabling the web console.
- The web console VM plug-in is installed on your system.
- The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
- Log in to the RHEL 10 web console.
In the pane, click the VM whose serial console you want to view.
A new page opens with an Overview and a Console section for the VM.
Select in the console drop down menu.
The graphical console appears in the web interface.
Optional: You can disconnect and reconnect the serial console from the VM.
- To disconnect the serial console from the VM, click .
- To reconnect the serial console to the VM, click .
7.2. Opening a virtual machine graphical console by using the command line Link kopierenLink in die Zwischenablage kopiert!
You can connect to a graphical console of a virtual machine (VM) by opening the VM in the Virt Viewer utility.
Prerequisites
- Your system and the VM that you are connecting to must support graphical displays.
- If the target VM is located on a remote host, you must have connection and root access privileges to the host.
-
Optional: If the target VM is located on a remote host, it is helpful to set up
libvirtand SSH for more convenient access to remote hosts. For instructions, see Setting up easier access to remote virtualization hosts. - The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
To connect to a local VM, use the following command and replace guest-name with the name of the VM you want to connect to:
# virt-viewer guest-nameTo connect to a remote VM, use the
virt-viewercommand with the SSH protocol. For example, the following command connects as root to a VM called guest-name, located on remote system 192.0.2.1. The connection also requires root authentication for 192.0.2.1.# virt-viewer --direct --connect qemu+ssh://root@192.0.2.1/system guest-nameSuccessful output:
root@192.0.2.1's password:
Verification
If the connection works correctly, the VM display is shown in the Virt Viewer window.
You can interact with the VM console by using the mouse and keyboard in the same manner you interact with a real machine. The display in the VM console reflects the activities being performed on the VM.
Troubleshooting
- If clicking in the graphical console does not have any effect, expand the console to full screen. This is a known issue with the mouse cursor offset.
7.3. Connecting to a virtual machine by using SSH Link kopierenLink in die Zwischenablage kopiert!
If you do not need to use the graphical display of a virtual machine (VM), you can interact with the VM through the command line using the SSH connection protocol.
Prerequisites
- You have network connection and root access privileges to the target VM.
- If the target VM is located on a remote host, you also have connection and root access privileges to that host.
Your VM network assigns IP addresses by
dnsmasqgenerated bylibvirt. This is the case for example inlibvirtNAT networks.Notably, if your VM is using one of the following network configurations, you cannot connect to the VM by using SSH:
-
hostdevinterfaces - Direct interfaces
- Bridge interfaces
-
The
libvirt-nsscomponent is installed and enabled on the VM’s host. If it is not, do the following:Install the
libvirt-nsspackage:# dnf install libvirt-nssEdit the
/etc/nsswitch.conffile and addlibvirt_guestto thehostsline:... passwd: compat shadow: compat group: compat hosts: files libvirt_guest dns ...
- The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
When connecting to a remote VM, SSH into its physical host first. The following example demonstrates connecting to a host machine
192.0.2.1by using its root credentials:# ssh root@192.0.2.1 root@192.0.2.1's password: Last login: Mon Sep 24 12:05:36 2021 root~#Use the VM’s name and user access credentials to connect to it. For example, the following connects to the
testguest1VM by using its root credentials:# ssh root@testguest1 root@testguest1's password: Last login: Wed Sep 12 12:05:36 2018 root~]#
Troubleshooting
If you do not know the VM’s name, you can list all VMs available on the host by using the
virsh list --allcommand:# virsh list --allExample output:
Id Name State ---------------------------------------------------- 2 testguest1 running - testguest2 shut off
7.4. Opening a virtual machine serial console by using the command line Link kopierenLink in die Zwischenablage kopiert!
To connect to the serial console of a virtual machine (VM), you can use the virsh console command. This is useful for example in the following situations:
- The VM does not provide VNC protocols, so it does not offer video display for GUI tools.
- The VM does not have a network connection, so it cannot be interacted with by using SSH.
Prerequisites
The GRUB boot loader on your host must be configured to use serial console. To verify, check that the
/etc/default/grubfile on your host contains theGRUB_TERMINAL=serialparameter.$ sudo grep GRUB_TERMINAL /etc/default/grub GRUB_TERMINAL=serialThe VM must have a serial console device configured, such as
console type='pty'. To verify, do the following:# virsh dumpxml vm-name | grep console <console type='pty' tty='/dev/pts/2'> </console>The VM must have the serial console configured in its kernel command line. To verify this, the
cat /proc/cmdlinecommand output on the VM should include console=<console-name>, where <console-name> is architecture-specific:For AMD64 and Intel 64:
ttyS0NoteThe following commands in this procedure use
ttyS0.# cat /proc/cmdline BOOT_IMAGE=/vmlinuz-6.12.0-0.el10_0.x86_64 root=/dev/mapper/rhel-root ro console=tty0 console=ttyS0,9600n8 rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgbIf the serial console is not set up properly on a VM, using virsh console to connect to the VM connects you to an unresponsive guest console. However, you can still exit the unresponsive console by using the Ctrl+] shortcut.
To set up serial console on the VM, do the following:
On the VM, enable the
console=ttyS0kernel option:# grubby --update-kernel=ALL --args="console=ttyS0"Clear the kernel options that might prevent your changes from taking effect.
# grub2-editenv - unset kernelopts- Reboot the VM.
The
serial-getty@<console-name>service must be enabled. For example, on AMD64 and Intel 64:# systemctl status serial-getty@ttyS0.service ○ serial-getty@ttyS0.service - Serial Getty on ttyS0 Loaded: loaded (/usr/lib/systemd/system/serial-getty@.service; enabled; preset: enabled)- The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
On your host system, use the
virsh consolecommand. The following example connects to the guest1 VM, if thelibvirtdriver supports safe console handling:# virsh console guest1 --safe Connected to domain 'guest1' Escape character is ^] Subscription-name Kernel 3.10.0-948.el7.x86_64 on an x86_64 localhost login:- You can interact with the virsh console in the same way as with a standard command-line interface.
7.5. Replacing the SPICE remote display protocol with VNC by using the command line Link kopierenLink in die Zwischenablage kopiert!
The SPICE remote display protocol is not supported on RHEL 10 hosts. If you have a virtual machine (VM) that is configured to use the SPICE protocol, you can replace the SPICE protocol with the VNC protocol by using the command line. Otherwise, the VM fails to start.
Prerequisites
- You have an existing VM that is configured to use the SPICE remote display protocol and is already shut-down.
- The VMs that you want to interact with are installed and started. For instructions, see Creating virtual machines and Starting virtual machines.
Procedure
On the host, run the following command, and replace `<vm-name>` with the name of the VM that you want to convert to VNC.
# virt-xml <vm-name> --edit --convert-to-vncSuccessful output:
Domain 'vm-name' defined successfullyImportantThis also removes certain SPICE devices from the VM, such as audio and USB passthrough, because they do not have a suitable replacement in the VNC protocol. For more information, see Considerations in adopting RHEL 9.
Verification
Inspect the configuration of the VM you converted, and make sure the graphics type is listed as
vnc.# virsh dumpxml -xml <vm-name> | grep "graphics"Successful output:
<graphics type='*vnc*' port='5900' autoport='yes' listen='127.0.0.1'>