Debian

How to Configure SPICE Server in Debian 10

The Simple Protocol for Independent Computing Environments  or SPICE is a protocol used to access and control  remote desktops of virtual machines.  It is based on client-server model, where  a server (SPICE server) is  installed on the  host machine and runs a guest VM to be accessed over the Internet. The guest VM is   remotely controlled by an client system running a Spice client.

QEMU, a open source machine emulator and virtualizer, uses SPICE server to provide remote desktop capabilities. QEMU executes the guest code directly on the host CPU. This improves performance QEMU itself uses KVM (Kernel-based Virtual Machine), a linux kernel module, to perform hardware virtualization.

Features of SPICE

  1. Spice supports transmission and handling of 2D graphic commands.
  2. Hardware Acceleration through GPU and CPU of client.
  3. Uses OpenGL for video streaming, giving a smoother user experience
  4. In order to retain the important aspects of an object being transferred   Spice uses lossless compression for images.
  5. In case of video compression, Spice employs lossy video compression for uncritical areas of videos. This saves a lot of bandwidth and improves Spice performance.
  6. Supports two mouse modes: server and client
  7. Supports seamless live VM migration between servers connected to a client.

The major components of Spice model are Spice Server, Spice Client and Spice Protocol.

The SPICE server runs inside the QEMU emulator. It uses the libspice-server1 package and  other dependencies to communicate with the remote client. It also manages authentication of client connections.

The Spice client is a utility that runs on client side. The client connects to remote guest VM desktop via Spice client. For this guide we will be using remote-viewer tool for accessing our guest VM.  The remote-viewer well be installed from the virt-viewer package.

Spice protocol  is a standard protocol for building communication path between the client and  the server side.

Environment Summary

Before we start building things it is necessary to understand the whole scenario. First thing is that we are working with a host machine, a guest virtual machine and a client machine. The host machine runs QEMU emulator on which we will launch the guest VM. The client machine will be used to connect to the  guest virtual machine.  The client system can be the host system itself for simplicity, but in our case it is a different PC running Ubuntu 20.04.

 Overall Summary:

  1. Our Host machine(Spice Server) is Debian 10(Buster), running Qemu emulator. IP: 192.168.1.7
  2. Guest VM  is Ubuntu 18.04, running inside Qemu emulator of above Host Machine.
  3. Client Machine is a Ubuntu 20.04 and a android mobile running a spice client software called as “aSPICE: Secure Spice Client”.

Prerequisites:

  1. A Debian 10(Buster) installed host machine.
  2. Hardware virtualization enabled in HOST.
  3. Basic knowledge of virtualization in linux operating system.

Notes: This is a long process in which multiple machines are running on different systems, so please be careful and run commands only on the right machine.

Steps to be performed on Host Machine i.e. Debian 10(Buster)

Step 1.  Enter the following command to execute commands with the super user’s privileges:

$ sudo su

Step 2. Update the repositories and packages on host machine i.e. Debian 10(Buster) before installing Spice Server on it:

# apt update && apt upgrade -y

Step 3. Install the following dependencies and packages required for running the Spice Server:

# apt install -y qemu-kvm libvirt-daemon-system bridge-utils virt-manager gir1.2-spiceclientgtk-3.0

Step 4. Now we have to launch a guest VM(Ubuntu 18.04)  inside virtual machine manager. Follow the following steps:

# virt-manager

This will open up the Virtual Machine Manager on the host machine i.e. our Debian 10(Buster).

a) Inside Virtual Machine Manager menu select File-> New Virtual Machine.

b) Select source of install as local media and click ‘Forward’ button.

Now browse for the .iso image of the OS to install as a guest VM. As mentioned earlier, we are selecting  Ubuntu 18.04 as our guest VM:

c) In next window, select the RAM size and number of CPUs:

d) Now create a storage for your virtual machine:

e) The next window will show you the details of your machine. Keep the network selection to NAT device.

f) Activate the virtual network when prompted.


Now proceed with normal process of installing your selected guest OS.

Step 5. After installing the guest OS, go to the Virtual Machine Manager and select Virtual Machine Details  as shown below:

A new window will open up showing the details of our selected guest VM(Ubuntu 18.04).

You can change the name and other configuration of your guest VM like RAM, number of CPUs etc from here.

Step 6. Now go to the option “Display Spice” and inside “Address” text-box select the option “All interfaces”. This will help us to view our guest VM on all over LAN device running spice client utility.

Click apply to save the changes.

Note: You will need to restart your guest OS for applying certain changes.

g) Now start the virtual machine from  Virtual Machine Manager main window as shown below:


Now this complete our host machine configuration for installing Spice Server. We have also launched a guest VM inside Qemu emulator installed on host machine.

Steps to be performed on Client Machine (Ubuntu 20.04)

The client machine requires a spice client installed on it for viewing the guest VM. Follow the following steps on Client VM (Ubuntu 20.04).

Step 1. Update the repositories and packages on client System:

$ sudo apt update && sudo apt upgrade -y

Step 2. Now install the following required packages for running spice client:

$ sudo apt install virt-viewer -y

Step 3. Now  to open the remote viewer, run the following command. The remote viewer tool is installed from the virt-viewer package.

$ sudo remote-viewer

A new small window will open up as shown below. Enter the IP address of the host machine and port of spice server.


If you have correctly followed up to this step, you should see the screen of guest VM(Ubuntu 18.04) on the client VM(Ubuntu 20.04) as here:

Spice Client for Mobile Device (Android)

We can also use a spice client on an android device for viewing our guest VM.  Just follow the steps below:

1. Go to play store and download the app “aSPICE: Secure Spice Client”.

2. Now open the app and click PC icon on top right to add a connection.


3. Enter the IP address of the  host machine Debian 10(Buster) upon which  guest VM is running. Save the configration.


4. A icon will appear on main window showing the guest VM. Now click on this icon to lauch the guest vm as shown below:


This completes our today’s guide of installing spice server on Debian 10(Buster). Hope you have enjoyed the guide. Please do not forget to share this guide with others.

About the author

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn
.