CentOS Stream 8
Sponsored Link

KVM : Configure SPICE Server2021/03/10

 
Configure Desktop Virtualization SPICE ( Simple Protocol for Independent Computing Environment ).
It's possible to connect to virtual machines from remote client computer.
[1] Install SPICE Server if it's not installed yet. (generally it's already installed with KVM for dependency)
[root@dlp ~]#
dnf -y install spice-server

[2] Edit existing virtual machine's configuration and start virtual machine with SPICE 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. By the way, if you'd like to use VNC instead of SPICE, replace [graphics type='spice' ***] to [graphics type='vnc' ***].
# edit configuration of VM

[root@dlp ~]#
virsh edit centos-st8
<domain type='kvm'>
  <name>centos-st8</name>
  <uuid>6847e863-be2d-4055-97b4-0eccd59f944d</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domm
ain/1.0">
      <libosinfo:os id="http://centos.org/centos-stream/8"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  .....
  .....
    # add like follows
    # set any password for [passwd=***] section for SPICE connection
    # specify an unique number for [slot='0x**']
    <graphics type='spice' port='5900' autoport='no' listen='0.0.0.0' passwd='password'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='32768' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' 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 centos-st8 XML configuration edited.

[root@dlp ~]#
virsh start centos-st8

Domain centos-st8 started
[3] If Firewalld is running, allow ports you use for SPICE.
[root@dlp ~]#
firewall-cmd --add-port=5900-5910/tcp --permanent

[root@dlp ~]#
firewall-cmd --reload

[4]
[5] By the way, if you'd like to enable SPICE on initial creating of virtual machine, specify like follows.
Then, it's possible to install Guest OS with SPICE that requires GUI installation like Windows without installing Desktop Environment on KVM Host computer.
If you'd like to use VNC, replace [spice] word to [vnc].
[root@dlp ~]#
virt-install \
--name Win2k19 \
--ram 6144 \
--disk path=/var/kvm/images/Win2k19.img,size=100 \
--vcpus 4 \
--os-variant win2k19 \
--network bridge=br0 \
--graphics spice,listen=0.0.0.0,password=password,keymap=ja \
--video qxl \
--cdrom /tmp/Win2019_JA-JP.ISO
Matched Content