KVM : Set VNC Connection2024/11/05 |
Set VNC connection to connect to virtual machines with VNC.
|
|
[1] | Edit existing virtual machine's configuration and start virtual machine with VNC like follows. The example on this site shows to create a virtual machine without graphics, so it's OK to change settings like follows, but if you created virtual machine with graphics, Remove [<graphics>***] and [<video>***] sections in configuration file. |
# edit the configuration of [fedora41] [root@dlp ~]# virsh edit fedora41 <domain type='kvm'> <name>fedora41</name> <uuid>9693933c-1caf-4f3a-a581-23807ce403aa</uuid> <metadata> <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0"> <libosinfo:os id="http://fedoraproject.org/fedora/40"/> </libosinfo:libosinfo> </metadata> ..... ..... # add like follows # set any password for [passwd=***] section # specify a unique number for [slot='0x**'] <graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0' passwd='password'> <listen type='address' address='0.0.0.0'/> </graphics> <video> <model type='virtio' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </memballoon> <rng model='virtio'> <backend model='random'>/dev/urandom</backend> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </rng> </devices> </domain> Domain fedora41 XML configuration edited.[root@dlp ~]# virsh start fedora41 Domain fedora41 started |
[3] | If Firewalld is running, allow ports you use for VNC. |
[root@dlp ~]# firewall-cmd --add-port=5900-5910/tcp [root@dlp ~]# firewall-cmd --runtime-to-permanent |
[4] | |
[5] | If you'd like to enable VNC on initial creating of virtual machine, specify like follows. Then, it's possible to install Systems with VNC that requires GUI Installation like Windows without installing Desktop Environment on KVM Host computer. |
[root@dlp ~]# virt-install \
--name Win2k22 \ --ram 6144 \ --disk path=/var/kvm/images/Win2k22.img,size=100 \ --vcpus=4 \ --os-variant=win2k22 \ --network bridge=br0 \ --graphics vnc,listen=0.0.0.0,password=password \ --video vga \ --cdrom /home/Win2022_EN-US_20348.169.210806-2348.fe.iso \ --boot uefi |
Sponsored Link |
|