Red Hat spice entry

Source: Internet
Author: User
Tags quic
1. Introduction

Spice (simple protocol for independent computing environments)-simple protocol for Independent Computing Environment

Spice is an open Remote Computing solution that allows clients to access remote desktop and devices (such as keyboards, mouse, audio, and USB ). With spice, we can access remote machines like local computers, so that intensive CPU and GPU work can be transferred from the client to remote high-performance machines. Spice applies to LAN and WAN without compromising user experience

The spice project provides a solution for interacting with virtual desktops and is fully open-source. The spice project can process Virtual Devices (back-end) and Front-end. VDI (Virtual Device interfaces) is used between the frontend and backend to interact with each other.

2. Basic Architecture

Spice consists of three basic parts: Spice protocol, spice server and spice client.

2.1 graphic commands Flow

Displays the basic architecture of spice and graphic command data streams transmitted between guest and client.

When a user application on Guest OS requests the OS graphics engine to perform a rendering operation. The graphics engine sends commands to the qxl driver. The qxl driver converts OS commands to qxl commands and pushes them to the commands ring buffer of the qxl device. Commands ring is a queue in qxl device. Libspice retrieves command data from this commands ring and adds it to the graphics command tree. The display tree contains a group of operation commands. The execution of these commands will generate the display content. This tree can optimize the commands that will be overwritten. It is also used to detect video data streams. When a command is sent from the libspice sending queue to the client, the sending command is converted to the spice protocol message, and the command is removed from the sending queue and tree.

When libspice no longer needs a command, it is pushed to the release ring. The driver uses this queue to release corresponding command resources.

When the client receives a command from libspice, the client uses this command to update the display.

2.2 agent commands Flow

Spice proxy is a software module in guest. Spice server and spice client use a proxy to execute work in the guest context, such as configuring guest display settings. Shows the process in which Spice client and server communicate with devices through the VDI driver. Message includes the client's guest display configuration information, server's mouse movement information, and proxy configuration response. The driver uses input/output rings to communicate with the VDI port device. The information generated by the client and server is written to the same write queue in the service, and then written to VDI.
The output buffer ring of the port device. The Message Port determines whether messages are processed by the server or pushed to the client.

2.3 spice Client

Spice cross-platform client is an end user interface

2.3.1 client Basic Structure

2.3.2 client classes

The following describes the key spice client classes. To have a clear cross-platform structure, spice defines a common interface and places platform-related implementations in a parallel directory. This generic interface is platform class, which defines many low-level services, such as timer and cursor operations.

Application

Is a main class, including clients, monitos and screens. This class implements common application functions: Command Line parsing, main loop, time processing, mouse event redirection, full screen switching, and so on.

2.3.2.1 Channels

The client and service are disconnected through channels. Each channel type corresponds to a specific data type. Each channel uses a dedicated TCP port, which can be secure or insecure. On the client, each channel has a dedicated thread for processing, so we can set a separate priority for each channel to achieve different QoS.

Redclient

Is the main channel. It has all other instantiation channels, and can control them (creation, connection, disconnection, etc.), and process control, configuration, and migration.

Available channels include:

Main-implemented by redclient

Displaychannel-process graphical commands, images, and data streams

Inputschannel-keyboard and mouse events

Cursorchannel-pointer device location, display and cursor shape.

Playbackchannel-receives audio from the server and then plays it on the client.

Recordchannel-recording on the client side

2.3.2.2 screens and windows

Screenlayer-Screen Layer is bound to a specific screen to provide operations on the rectangular area. Layer is Z-order

Redscreen-implement the screen logic, control the window, and use screen layers to display its content

Reddrawable-platform-specific implementation of basic pixmap. It supports basic rendering operations.

2.4 spice Server

Spice server is implemented through libspice and VDI library. VDI provides a standard method to publish virtual interfaces. This allows other software components to interact with these virtual devices.

On the one hand, the server uses the spice protocol to communicate with remote clients, and on the other hand, it interacts with the VDI Host application.

For the purpose of remote display, server maintains a command sequence and a tree to manage the dependencies and overwrites of the current object. The qxl command is processed and converted to the spice protocol and then sent to the client.


2.4.1 Server Structure

The Server communicates with the client through channels. Each channel type corresponds to a specific type of data. Each channel uses a dedicated TCP port. The channel of the server and the channel of the client are corresponding, including main, inputs, display, cursor playback and record.

The main and input channels are used for control. The display and cursor channels are controlled by the red worker thread of each display. Audio Playback and record channels have their own processing functions. Libspice communicates with VDI host applications and various functional interfaces, such as agent, keryboard, and record.

As shown in, spice Server includes the following main components:

2.4.1.1 red Server

Server itself, used to listen to client connection requests, accept connections and use them to communicate. Responsible for the following tasks:

1. Manage Channels

Owns or manages channels (registration, logout, and close)

Notify the channels of the client activity so that the client can create them

Main and input channels management

Link Creation

Socket operations and Link Management

Process SSL and bills

2. VDI Interface

3. Migration Process Collaboration

4. process user commands

5. Communicate with guest angent

2.4.1.2 graphics Subsystem

Unlike other subsystems in SPICE, the graphics subsystem runs in parallel through proprietary threads on the server. This structure makes the qemu stream and input graphics command processing and rendering independent, thus consuming a lot of CPU resources. Displays the structure of the spice server graphics subsystem. The red server instantiates a dispatcher with a qxl interface. dispatcher creates red worker for this qxl interface. worker processes commands from three sources: 1. synchronous qxl device command, 2. red server commands,
3. asynchronous qxl device commands. 1 and 2 are distributed by dispatcher through socket, and 3 by worker from qxl device rings.

2.5 spice Protocol

Spice protocol is used for communication between client and server, such as transmitting graphical objects, keyboard and mouse events, cursor information, audio playback and recording, and control commands. For more information, see spice.

2.6 qxl Device
2.7 qxl guest driver
2.8 spice agent

The spice agent is an optional component used to enhance user experience and perform jobs for guest. For example, when the client mouse mode is used, the agent inserts the mouse position and status to guest. In addition, it can be used to configure guest display settings. Future functions include copying objects from guest or pasting objects to guest.

2.9 vdiport device and driver

Spice protocol supports communication channels between client and server proxy. When qemu is used, the spice agent resides on the guest. VDI port is a qemu PCI device used to communicate with the agent using a specific proxy protocol.

3 features
3.1 graphic commands

Spice supports the transmission and processing of 2D graphics commands (3D graphics commands are not supported yet), while other remote desktop solutions generally use framebuffer updates. Qxl device commands are independent from common platforms, so both Windows and X drivers can use them.

3.2 Hardware acceleration

The basic spice client rendering is performed through Cario, and Cario itself is an independent library of cross-platform devices. Cario provides vector graphics primitives for 2D plotting. Hardware acceleration is an additional rendering mode, which is implemented through the client GPU rather than the software. In Linux, hardware acceleration is implemented through OpenGL, and in Windows is GDI. Hardware acceleration has the following features:

  • High-performance rendering-with OpenGL, spice client can render faster. Stretching with hardware is much more efficient than stretching with a large amount of software operations. Therefore, spice can provide a better user experience.
  • Reduce client CPU usage-the client can use the reduced CPU time to perform other work, such as audio

Unlike Cario, Cario is a completely independent software library, while OpenGL is a hardware library that relies on drivers and hardware implementation. Therefore, spice may encounter incorrect rendering or client host crash. In addition, although OpenGL is standard, the hardware and driver implementations of various vendors may be different. Therefore, spice may display different rendering outputs on different GPUs, which have different performance performances. In addition, some devices do not support OpenGL.

3.3 Image Compression

Spice provides several image compression algorithms that can be selected during initialization and can be dynamically modified at runtime. QuIC is a spice proprietary Image Compression tool based on the sfalic algorithm. The LZ algorithm is another choice. QuIC and LZ are both local algorithms. Global LZ is another spice proprietary algorithm that uses LZ and a historical-based Global dictionary. Glz uses the repetitive pattern in the image to reduce network traffic, which is important for Remote Desktop running in the WAN environment. Spice provides an automatic selection mode for each image compression, and the LZ/glz and QuIC compression algorithms are enlightening for image attributes. Generally, it is better to use LZ/glz for artificial images, while for real images, use QuIC.

3.4 Video Compression

Spice uses lossless compression algorithms for images to avoid loss of key Display object information. However, because the video stream may be the main consumer of bandwidth, each frame in the video is a separate image. In addition, these images are not critical data. Therefore, spice uses lossy compression for these video streams. Spice server uses the motion JPEG algorithm to encode the region where the video is updated. This mechanism saves a lot of bandwidth and improves spice performance, especially on the WAN network. Of course, in some cases, heuristic behavior may lead to low-quality images.

3.5 caching

Spice enables high-speed client image caching to avoid redundant transmission. Caching can apply any data sent to the client, including pixmaps, pallettes, and cursors. Each image has a unique ID and cache prompt. Inconsistent images have different IDs, while identical images share the same ID. pixmap cache in all the displays. The cache is defined by each link, and the server and client are completely synchronized, that is, at every moment

3.6 mouse Mode

Spice supports two mouse modes: server and client. The mouse mode can be dynamically changed and negotiated between the client and server.

  • Server Mode-use the qemu PS/2 mouse simulator to enable the mouse in guest. Once the user clicks the mouse in the spice client window, the client mouse is captured and set to invisible. The client sends the mouse to the server. Therefore, the client will return to the center of the window after each move. In this mode, the server controls the mouse position on the screen, so it keeps synchronizing the location on the client and guest. However, problems may occur on the WAN or server with heavy loads, and the mouse cursor may seem dull or unresponsive.
  • Client mode-the client mouse is not captured and the guest cursor is not displayed. The client sends the absolute coordinates of the mouse movement to the server. The guest agent scales the coordinates according to the guest desktop scale and inserts the corresponding coordinates. For a single monitor, you can use the client mouse to register an absolute positioning device through the VDI Host application without an agent. In this case, spice server is responsible for scaling the coordinates. The client mode is suitable for Wan and high-load servers, because the cursor motion is smooth and the response is good. However, the cursor may occasionally lose synchronization (location and shape are inconsistent). Client mouse cursor by guest
    Mouse cursor.
More than 3.7 monitors

Spice supports any number of monitors, limited by guest, the number of client and server. monitors, and their Ram size are set when the VM is loaded. Spice allows you to automatically configure the resolution and display settings of the guest Monitor Based on the client machine parameters. This is achieved through a client-to-Guest Agent Command.

3.10 event migration

VM migration between servers is seamless for connected clients. The complete connection status, including the opened channel and cursor, will be restored from the source to the target machine.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.