Ubuntu 23.04
Sponsored Link

KVM : VNC connection Setting2023/04/27

 
Set VNC connection to connect to virtual machines with VNC.
[1] Edit existing virtual machine's configration 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, however, if you created virtual machine with graphics, Remove [<graphics>***] and [<video>***] sections in configration file.
# edit configration of VM

root@dlp:~#
virsh edit ubuntu2304
<domain type='kvm'>
  <name>ubuntu2304</name>
  <uuid>3a89f4ad-ce37-4b45-a172-202bc3d9681e</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://ubuntu.com/ubuntu/23.04"/>
    </libosinfo:libosinfo>

  .....
  .....

    # add like follows
    # set any password for [passwd=***] section for VNC connection
    # specify an uniq 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='qxl' ram='65536' vram='32768' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' 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 'ubuntu2304' XML configuration edited.

root@dlp:~#
virsh start ubuntu2304

Domain ubuntu2304 started
[2]
[3] By the way, if you'd like to enable VNC on initial creating of virtual machine, specify like follows.
Then, it's possible to install Guest OS 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 virtio \
--cdrom /home/Win2022_EN-US_20348.169.210806-2348.fe.iso
Matched Content