Application virtualization method, system, medium and product based on SPICE protocol
Through the application virtualization method based on SPICE protocol, the problem of centralized management and deployment of applications in the cloud desktop scenario of Linux system is solved, the localized running and display of remote applications is realized, the flexibility of application deployment is improved, and it is suitable for different applications. The end users of the system.
Patent Information
- Application Number
- CN202410740982.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-11
Smart Images

Figure CN118312269B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to an application virtualization method, system, medium and product based on the SPICE protocol. Background Art
[0002] With the development of cloud computing, cloud desktop platforms have been widely used, simplifying the work of desktop delivery and reducing the burden of PC management and operation and maintenance on enterprises. The concepts of virtualization and cloud desktops are gradually being understood and accepted by users.
[0003] Application virtualization technology is a further development of desktop virtualization technology and is one of the development trends of virtualized application types in the future. Application virtualization separates the user's PC operating system and application program for flexible management, provides a virtual operating environment for the application program, and abstracts the application program's dependence on the underlying system and hardware, thereby solving problems such as version incompatibility and management difficulties. For example, users can use the same application program on operating systems such as Windows, UOS, and Kylin without installing the application program.
[0004] The current application virtualization technology is mainly developed around the freerdp framework proposed by Microsoft. It intercepts commands from applications in Windows based on the rdp remote protocol and forwards them to the terminal user layer for processing and finally displays them graphically in the local window, so that applications in the remote windows server can run on the local terminal (the terminal system can be a windows system, Linux system, Android system or macos, etc.) without the user noticing.
[0005] However, domestic operating system desktops are mainly based on Linux. There is no mature application virtualization solution for cloud desktop scenarios of Linux systems, which allows end users to use them without installing specific applications, thereby meeting the centralized management and deployment of similar Linux system applications. Summary of the invention
[0006] The purpose of the present invention is to provide an application virtualization method, system, medium and product based on the SPICE protocol. A server based on the Linux system can also realize centralized installation / management of remote applications in a remote display scenario equipped with the SPICE protocol, and the user terminal can locally display and use remote applications.
[0007] In order to achieve the above objectives, the following problems need to be solved:
[0008] (1) How to know which application the end user needs to launch and at what resolution;
[0009] (2) After the remote application is started, how to isolate the application window screen from the remote server desktop system screen where the application is installed so that the application window screen that needs to be forwarded can be transmitted separately;
[0010] (3) How to obtain the application screen and transmit it through the SPICE protocol, as well as the update mechanism of the application screen.
[0011] Therefore, the technical solution of the present invention is achieved in this way:
[0012] An application virtualization method based on the SPICE protocol, running on a server side, includes:
[0013] S1. Communicate with the client through the SPICE protocol, receive and parse the application name and resolution size that need to be started transmitted by the client;
[0014] S2, start Xvfb to create a virtual screen corresponding to the resolution size; start the application corresponding to the obtained application name, and specify it to run on the virtual screen;
[0015] S3, acquiring the image data on the virtual screen based on the Xlib interface, and transmitting the image data to the client for display through the display channel of the SPICE protocol;
[0016] S4. The client's operation information is passed to the application through the X server, and the event events of the application's response operation are monitored and processed through the thread function, and transmitted to the client for display.
[0017] Furthermore, in step S1, a spice server is set on the server side to communicate with the spice gtk on the client side.
[0018] Furthermore, the server passes the information for the TCP / IP connection to the spice server, creates a TCP / IP socket connection, and adds monitoring of the socket connection through the watch_add interface to continuously monitor the connection request from the client.
[0019] Furthermore, the thread function in step S4 is created through pthread_create() and is used to monitor the event events transmitted by xserver.
[0020] Another aspect of the present invention further provides an application virtualization system based on the SPICE protocol, including an application forwarding service program running on a server side, wherein the application forwarding service program includes:
[0021] SPICE communication module: communicates with the client through the SPICE protocol, receives and parses the application name and resolution size that need to be started transmitted by the client;
[0022] Virtual display module: start Xvfb to create a virtual screen corresponding to the resolution size; start the application corresponding to the obtained application name and specify it to run on the virtual screen;
[0023] Display channel module: obtains the image data on the virtual screen based on the Xlib interface, and transmits it to the client for display through the display channel of the SPICE protocol;
[0024] Event monitoring module: The client's operation information is passed to the application through the X server, and the event events of the application response operation are monitored and processed through the thread function, and transmitted to the client for display.
[0025] Furthermore, in the SPICE communication module, a spice server is set to communicate with the spice gtk of the client.
[0026] Furthermore, in the SPICE communication module, the TCP / IP connection information transmitted by the receiving server is given to spiceserver, a TCP / IP socket connection is created, and monitoring of the socket connection is added through the watch_add interface to continuously monitor the connection requests from the client.
[0027] Furthermore, the thread function in the event monitoring module is created through pthread_create() and is used to monitor the event events transmitted by the xserver.
[0028] The present invention also provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the above-mentioned application virtualization method based on the SPICE protocol.
[0029] The present invention also provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the above-mentioned application virtualization method based on the SPICE protocol is implemented.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] The present invention can easily realize application virtualization of remote Linux servers based on the existing SPICE remote protocol framework, that is, localized operation and display of application programs of remote Linux servers. In view of the cross-platform compatibility of the SPICE protocol, it can be applied to end users of different systems to use this feature, which greatly reduces the burden of enterprise application deployment and management on personal PCs and improves the flexibility of application deployment. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 Schematic diagram of the system architecture of an embodiment of the present invention.
[0033] Figure 2 It is a schematic diagram of a flow chart of an embodiment of the present invention.
[0034] Figure 3 It is a flowchart of an application forwarding service program according to an embodiment of the present invention. DETAILED DESCRIPTION
[0035] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0036] First, some explanations of abbreviations and key terms:
[0037] SPICE: SPICE (Simple Protocol for Independent Computing Environment) is the latest open source cloud desktop transmission protocol based on KVM virtual machines. It is mainly used in RedHat desktop virtualization and provides a solution for interacting with cloud desktops. Clients can access cloud desktops and use local devices (such as keyboards, USB, etc.) through this protocol. The spice server is provided to the backend in the form of a library and communicates with the spice client through the spice protocol; spice gtk is a spice client project developed based on gtk, which implements remote connection and window display based on the spice protocol.
[0038] Xvfb: is a display server that implements the X11 display service protocol. Unlike other display servers, Xvfb performs all graphics operations in memory without the need for any display device.
[0039] Xlib: Xlib is a client library written in C language, which contains functions for communicating with X server. Programmers can use it directly for programming without understanding the underlying X protocol.
[0040] The design concept of the present invention is to realize application virtualization based on SPICE protocol, so that the application can actually run on the remote server under Linux system and be displayed and used locally on the user terminal.
[0041] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0042] Based on the design idea of the present invention, the present invention mainly introduces the application forwarding service program developed based on spiceserver into the remote Linux server, and modifies the spice gtk and client of the user terminal to meet the corresponding requirements. The specific architecture is as follows Figure 1 shown.
[0043] Based on the above architecture, the specific method in this embodiment is as follows Figure 2 As shown, including:
[0044] Step 1: The client is modified to support the transmission of the application name and the resolution size at which the application needs to be started to the application forwarding service program on the server.
[0045] The specific changes include:
[0046] a. Add a list on the client connection interface to display the applications on the remote Linux server that support forwarding.
[0047] b. Add a structure in the client spice gtk to record the application name + resolution, and encapsulate it to pass the data to the spice server using mainchannel. When the client starts, extract the information into the structure according to the user's selection.
[0048] c. When starting the connection, select an application that supports forwarding. At this time, the corresponding selected application name will be obtained, and then the display resolution information of the terminal will be obtained through the general interface and stored in the above structure. After the main channel of the spice server establishes a connection with the client, the structure information is packaged and transmitted to the spice server in the form of a message through the main channel, and then further transmitted to the application forwarding service program, which parses the received message information and performs subsequent processing.
[0049] Step 2: The server starts the application forwarding service program.
[0050] As mentioned above, the application forwarding service program is developed based on the spice server and is started and run on the server side.
[0051] Step 3: The terminal user starts the modified SPICE client, specifies the startup application name and resolution size; this step can be started in the form of an application icon encapsulating the corresponding startup command link, and the user only needs to click the application icon to respond to the startup connection of the SPICE client.
[0052] Step 4: The application forwarding service program will continuously monitor the connection requests from the terminal and perform subsequent processing according to the requests;
[0053] The implementation method of the continuous monitoring is as follows:
[0054] The application forwarding service program will include the relevant calls of the spice server. The application forwarding service program will serve as the server end of the SPICE protocol transmission, and the client spice gtk of the user terminal will serve as the client end of the SPICE protocol transmission. When the application forwarding service program is started, it will initialize the spice server, pass the server address, port and other information used for TCP / IP connection to the spice server, create a TCP / IP socket connection, and add monitoring of this socket through the watch_add interface. When a client spice gtk tries to establish a connection with the spiceserver, it will notify and call the corresponding function to complete the connection request and establish a connection. The spice client can communicate normally with the application forwarding service program.
[0055] The connection request processing process is as follows Figure 3 As shown, including:
[0056] Step 4.1: The application forwarding service program monitors the connection request from the client spice gtk and establishes a connection.
[0057] Step 4.2: After the connection is successfully established, the application forwarding service program parses the application name and resolution information to be started, and starts Xvfb to create a virtual screen of the corresponding resolution size.
[0058] Step 4.3: The application forwarding service program starts the application corresponding to the obtained application name and specifies to run it on the virtual screen created in step 4.2.
[0059] Step 4.4: The application forwarding service program obtains the image data on the virtual screen based on the Xlib interface, and transmits it to the client for display through the SPICE display channel (existing native channel), such as a window display area of the virtual application appears on the client's screen, displaying the image data of the application.
[0060] Step 4.5: The application forwarding service program processes the client operation information transmitted by SPICE, such as input / tablet / keyboard related information, so that the user's mouse / keyboard, etc. matches the application operation.
[0061] Because the mouse / keyboard device is actually plugged into the user terminal computer, that is, the client side of spice gtk, when the user operates the mouse / keyboard device, if the window display area of the virtual application is operated, the operation information of the mouse / keyboard will be captured, and the operation information such as the coordinates of the mouse movement and keyboard information will be transmitted to the remote Linux server where the application is located through the path of spice gtk-->spice server-->application forwarding service program, and finally transmitted to the application through the server's x server, and the application will respond to the mouse / keyboard movement and key operations.
[0062] Step 4.6: The application forwarding service program monitors and processes events from the X server through thread functions, including cursor, application image data changes, window resize, etc.
[0063] This step is to display the updated data in the terminal display window from the path of application->x server->application forwarding service program->spice server->spice gtk after the cursor pattern and screen change after the application responds to the user's operation. The details are as follows:
[0064] When the application forwarding service program starts, it creates a thread function through pthread_create() to monitor the event events transmitted by the X server.
[0065] This thread uses while ((ev = xcb_wait_for_event())) as the loop condition and keeps listening to the event messages from the xserver, such as monitoring the cursor changes, image changes, window size changes, etc. of the entire screen.
[0066] When the cursor changes, the cursor processing function needs to be called to pass the image data and coordinates of the cursor change area through the cursor channel of the spice server to the spice client for updating.
[0067] When the image changes, the image data and coordinates of the changed area are also transmitted to the spice client through the display channel of the spice server for updating.
[0068] When the window size changes, the previously created surface resources are destroyed, and new surface resources of the same window size are recreated to update and display the data.
[0069] Step 5: After the terminal user closes the window of the virtual application, the application forwarding service program disconnects the service connection, closes the application, clears the virtual screen created by Xvfb, and releases resources.
[0070] Through the above steps, centralized installation / management of remote applications based on the SPICE transmission protocol can be achieved, and end users can locally display and use remote applications.
[0071] The above-mentioned embodiments are only preferred implementations of the present invention, and are only used to help understand the method and core ideas of the present application. The protection scope of the present invention is not limited to the above-mentioned embodiments. All technical solutions under the idea of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. An application virtualization method based on SPICE protocol, It is characterized in that Set up the application forwarding service program, running on the server side, including: S1. Set up the spice server, communicate with the client's spice gtk through the SPICE protocol, receive and parse to obtain the application name and resolution size to be started transmitted by the client; S2, start Xvfb to create a virtual screen corresponding to the resolution size; start the application corresponding to the obtained application name, and specify it to run on the virtual screen; S3, acquiring the image data on the virtual screen based on the Xlib interface, and transmitting the image data to the client for display through the display channel of the SPICE protocol; S4. The client's operation information is passed to the application through the X server, and the event events of the application's response operation are monitored and processed through the thread function, and transmitted to the client for display.
2. The application virtualization method based on the SPICE protocol according to claim 1, It is characterized in that The server passes the information for TCP / IP connection to spice server, creates a TCP / IP socket connection, and adds monitoring of the socket connection through the watch_add interface, continuously monitoring the connection request from the client.
3. The application virtualization method based on the SPICE protocol according to claim 1, It is characterized in that The thread function in step S4 is created through pthread_create() and is used to monitor the event transmitted by the x server.
4. An application virtualization system based on SPICE protocol, It is characterized in that The application forwarding service program includes: SPICE communication module: set up spice server, communicate with the client's spice gtk through SPICE protocol, receive and parse to obtain the application name and resolution size to be started transmitted by the client; Virtual display module: start Xvfb to create a virtual screen corresponding to the resolution size; start the application corresponding to the obtained application name and specify it to run on the virtual screen; Display channel module: obtains the image data on the virtual screen based on the Xlib interface, and transmits it to the client for display through the display channel of the SPICE protocol; Event monitoring module: The client's operation information is passed to the application through the X server, and the event events of the application response operation are monitored and processed through the thread function, and transmitted to the client for display.
5. The application virtualization system based on the SPICE protocol according to claim 4, It is characterized in that In the SPICE communication module, the TCP / IP connection information transmitted by the receiving server is given to the spice server, a TCP / IP socket connection is created, and the monitoring of the socket connection is added through the watch_add interface to continuously monitor the connection requests from the client.
6. The application virtualization system based on the SPICE protocol according to claim 4, It is characterized in that The thread function in the event monitoring module is created through pthread_create() and is used to monitor the event events transmitted by the x server.
7. A computer-readable storage medium storing a computer program. It is characterized in that The computer program is used to execute the application virtualization method based on the SPICE protocol as described in any one of claims 1 to 3.
8. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the application virtualization method based on the SPICE protocol as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Method and system for achieving automatic adaption of virtual desktop screen resolution on Android terminal
CN104516703A
Desktop resolution adaptive realization system and method for virtual machine RFB protocol
CN107256153A
Method for optimizing virtual desktop transmission based on FPGA
CN110018873A
Three-dimensional image transmission method and device based on kunpeng processor
CN111190675A
Method for adaptively adjusting resolution of cloud desktop
CN113254130A
