Disclosure of Invention
The application aims to provide a method, a device and equipment for displaying a virtual machine desktop and a readable storage medium, which can improve the display performance of the virtual machine desktop on the basis of being compatible with various CPU architectures.
In order to solve the technical problem, the application provides the following technical scheme:
a virtual machine desktop display method is applied to a virtual machine and comprises the following steps:
acquiring the picture change content of the virtual machine by using an operating system;
generating an operation command corresponding to the screen change content by using the operation system;
writing the operation command into a shared memory device by using the operation system;
and reading the operation command from the shared memory device in a timing or real-time manner by using a service module, and sending the operation command to a client so that the client can perform desktop rendering and display by using the operation command.
Preferably, the acquiring, by using the operating system, the screen change content of the virtual machine includes:
and acquiring the screen change content of the virtual machine by using an X11 display driver in the operating system.
Preferably, the acquiring, by using an X11 display driver in the operating system, the screen change content of the virtual machine includes:
and acquiring the picture change content of the virtual machine by using a virtual display driver in the X11 display driver.
Preferably, the generating, by the operating system, an operation command corresponding to the screen change content includes:
generating an operation command which is in accordance with virtual display equipment simulated by a virtual machine simulator and corresponds to the picture change content by utilizing the operation system;
correspondingly, the reading the operation command from the shared memory device in a timing or real-time manner by using the service module includes:
and utilizing the service module simulated by the virtual machine simulator to read the operation command from the shared memory equipment simulated by the virtual machine simulator in a timing or real-time manner.
Preferably, the generating, by using the operating system, an operating command corresponding to the screen change content and conforming to a virtual display device simulated by a virtual machine simulator includes:
generating a display command and/or a cursor command which is in accordance with QXL virtual display equipment simulated by the virtual machine simulator and corresponds to the picture change content by utilizing the operating system;
determining the display command and/or the cursor command as the operation command.
Preferably, the reading, in real time or in real time, the operation command from the shared memory device simulated by the virtual machine simulator by using the service module simulated by the virtual machine simulator includes:
reading the operation command from the shared memory device in a timing or real-time manner by utilizing a VDI (virtual device interface) simulated by the virtual machine simulator;
and sending the operation command to the client by utilizing a service module simulated by the virtual machine simulator.
Preferably, the sending the operation command to the client by using the service module simulated by the virtual machine simulator includes:
and sending the operation command to the client through the SPICE protocol by utilizing a service module simulated by the virtual machine simulator.
Preferably, before writing the operation command into the shared memory device by using the operating system, the method further includes:
judging whether the operating system and the service module have network communication connection or not;
if so, sending the operation command to the service module by using the network communication connection, and sending the operation command to a client by using the service module so that the client can perform desktop rendering and display by using the operation command;
and if not, executing the step of writing the operation command into the shared memory equipment by using the operating system.
Preferably, the operation command is a QXL command.
A virtual machine desktop display device, comprising:
a virtual machine simulator and an operating system with a display driver;
the virtual machine simulator is used for simulating a service module and shared memory equipment;
the display driver is used for acquiring the picture change content of the virtual machine, generating an operation command corresponding to the picture change content, and writing the operation command into the shared memory device;
the service module is used for reading the operation command from the shared memory device in a timing or real-time manner and sending the operation command to a client so that the client can perform desktop rendering and display by using the operation command.
An electronic device, comprising:
a memory for storing a computer program;
and the processor is used for realizing the steps of the virtual machine desktop display method when executing the computer program.
A readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described virtual machine desktop display method.
The method provided by the embodiment of the application is applied to the virtual machine and comprises the following steps: acquiring the picture change content of the virtual machine by using an operating system; generating an operation command corresponding to the screen change content by using an operation system; writing an operation command into the shared memory equipment by using an operating system; and the service module is used for reading the operation command from the shared memory device in a timing or real-time manner and sending the operation command to the client so that the client can perform desktop rendering and display by using the operation command.
In the application, firstly, an operating system is used for obtaining the screen change content of the virtual machine, generating an operation command corresponding to the screen change content, and writing the operation command into the shared memory device. Then, the service module is used for directly reading the operation command from the shared memory device in a timing or real-time mode and sending the operation command to the client. The client can be enabled to perform desktop rendering and display based on the operation command. Therefore, in the application, the screen change content of the virtual machine can be read from the shared memory device, and the subsequent rendering and display can be realized based on the operation command without additionally simulating the virtual display device, so that the method can be applied to various CPU architectures such as an ARM architecture and an MIPS architecture. Meanwhile, the service module directly reads the operation command from the shared storage device, so as to send the operation command to the client. Thus, the operating system of the virtual machine need not communicate with the service module, nor with the client network. That is, the display image data of the virtual machine is transmitted to the service module through the shared device, and further transmitted to the client by the service module, which has no requirement on the network of the virtual machine itself and the operating system in the virtual machine. Therefore, the desktop display performance of the virtual machine can be improved on the basis of being compatible with various CPU architectures.
Accordingly, embodiments of the present application further provide a device, an apparatus, and a readable storage medium corresponding to the virtual machine desktop display method, which have the technical effects described above and are not described herein again.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method for displaying a desktop of a virtual machine in an embodiment of the present application, where the method may be applied to a virtual machine with any architecture, where the virtual machine includes an operating system and a service module. The method comprises the following steps:
s101, acquiring the screen change content of the virtual machine by using the operating system.
The virtual machine may be any virtual machine virtualized by any physical host by using a virtualization technology.
Specifically, the upper and lower frames of the display screen of the virtual machine can be captured by the operating system, and the display change content can be obtained by a comparison method. For how to capture the display frame of the virtual machine and perform the display frame comparison operation, reference may be made to RDP and VNC, which is not described in detail herein.
In consideration of the above, a large amount of operations are caused by the manner of obtaining the picture change content through the display frame comparison operation, which may affect the desktop display performance of the virtual machine. Preferably, in this embodiment, in order to omit the additional display frame comparison operation, the screen change content may be acquired directly by using the X11 display driver in the virtual machine operating system. In a specific implementation process, acquiring the picture change content of the virtual machine may specifically include: and acquiring the screen change content of the virtual machine by using the X11 display driver. Where X11 is a graphics framework on the Linux system, different display devices can be supported by loading different display drivers.
For ease of understanding, the following explanation is made with respect to x 11.
Generally, for X11, it is composed of xserver and xclient, where xserver manages hardware settings related to display on the host (e.g., video card, hard disk, mouse, etc.), and it is responsible for drawing and displaying screen images and informing xclient of actions of input settings (e.g., keyboard, mouse). An Xclient (i.e., an application) is primarily responsible for the handling of events (i.e., the logic of a program).
For example, if the user clicks the left mouse button, because the mouse is managed by xserver, xserver captures the mouse click action, and then it tells xclient about the action, because xclient is responsible for the program logic, then xclient can tell xserver: please draw a circle at the mouse click position. And finally, responding to the request of the xclient by the xserver, and drawing and displaying a circle at the position clicked by the mouse.
Because the xclient and the xserver can clearly know where the image drawing needs to be carried out, namely the xclient and the xserver can clearly know the picture change content, the picture change content can be directly obtained based on the X11 display drive, so that the display frame comparison operation is omitted, and the desktop display performance of the virtual machine is improved.
In the present application, in order to more quickly and efficiently acquire the screen change content of the virtual machine, a virtual display driver (xspecce) may be added to the X11 display driver. That is to say, acquiring the screen change content of the virtual machine by using the X11 display driver in the operating system may further specifically include: the screen change content of the virtual machine is acquired by using a virtual display driver among the X11 display drivers. Specifically, in this further preferred embodiment, X11 shows that each part in the driver is responsible for the following transactions:
xclient: the application program in the Linux virtual machine is connected to the xserver and then responsible for responding to the operation of the user and updating the picture;
xserver: the display service program in the Linux virtual machine is responsible for transmitting the input event to the xclient and rendering the drawing instruction;
xslice: and the virtual display driver in the xserver is responsible for acquiring the picture change of the virtual machine at regular time or in real time and constructing the picture change into a QXL command to be written into the shared memory device.
That is, the following steps are performed from the generation of the screen inside the virtual machine to the acquisition of the screen change content:
when the xclient program interface changes, sending a drawing instruction to the xserver;
the xserver renders the drawing instruction to form a final virtual machine picture;
and the xspic monitors the change of the virtual machine picture and acquires the picture change content at regular time or in real time.
After the frame change content is obtained, step S102 is executed.
S102, an operation command corresponding to the screen change content is constructed by using the operation system.
The operation command may be specifically a command that the client can render and display the screen change content on its display interface based on the operation command. Wherein the operation command may be a QXL command.
Preferably, in order to effectively recognize and execute the operation command between the virtualized service module and the client, the step S102 constructs the operation command corresponding to the screen change content, which may specifically include generating, by using an operating system, the operation command corresponding to the screen change content and conforming to the virtual display device simulated by the virtual machine simulator.
That is, when generating the operation command, it is necessary to specifically refer to a command format supported by the virtual display device simulated by the virtual simulator.
Preferably, if the virtual display device is a QXL virtual display device, generating a display command and/or a cursor command corresponding to the screen change content and conforming to the QXL virtual display device simulated by the virtual simulator by using the operating system; the display command and/or the cursor command are determined as the operation command. That is, the operation command is a QXL command, specifically, a display command or a cursor command, or both a cursor command and a display command. The QXL virtual display device is a virtual display device under QEMU (quick simulator), and is combined with the drive in the virtual machine, so that efficient display image transmission can be provided.
S103, writing the operation command into the shared memory device by using the operating system.
After the operation command is generated, the operation command may be written to the shared content device.
The shared memory device may be modeled by a virtual simulator, which may be specifically a QUEM. QUEM is a virtual simulator that simulates a physical machine and can provide device simulation such as CPU, memory, disk, network card, etc.
In order to avoid confusion, if N virtual machines are virtualized in one host, and the N virtual machines all participate in the desktop display of the virtual machines, each virtual machine of the N virtual machines may set its corresponding shared memory device.
And S104, reading the operation command from the shared memory device in a timing or real-time manner by using the service module, and sending the operation command to the client so that the client can perform desktop rendering and display by using the operation command.
After the operating system writes the operating command into the shared memory device, the operating command can be read from the shared memory device at regular time or in real time by using the service module, and then the operating command is sent to the client. The client and the service module may specifically communicate based on a port number corresponding to a virtual machine to which the service module belongs and an IP address of a physical host to which the virtual machine belongs.
After receiving the operation command, the client can perform desktop rendering and display by using the operation command.
Preferably, in order to facilitate the service module to read the operation command in the shared storage device, a VDI interface may be simulated by using the virtual machine simulator, so as to be used by the service module in the virtual machine. That is, the step of using the service module simulated by the virtual machine simulator in step S104 to read the operation command from the shared memory device simulated by the virtual machine simulator in a timed or real-time manner may specifically include:
step one, using a VDI interface simulated by a virtual machine simulator to read an operation command from the shared memory device in a timing or real-time manner.
The VDI interface may be specifically an interface provided by xspy-display, and the xspy-display, i.e., QEMU internal module, can provide a VDI interface for spice-server, and can implement reading and releasing operations of a display command and a cursor command in the QXL command.
And step two, the service module simulated by the virtual machine simulator is used for sending the operation command to the client.
Further, in order to improve the transmission efficiency of the service module and the client, the transmission can be performed based on the SPICE protocol. That is, the second step of sending the operation command to the client by using the service module simulated by the virtual machine simulator, may specifically include: and sending the operation command to the client through the SPICE protocol by utilizing the service module simulated by the virtual machine simulator. That is, the service module may be specifically a SPICE-server, which is an SPICE service module running inside QEMU and is responsible for fetching QXL commands and sending the QXL commands to SPICE clients.
Among other things, spice Protocol for Independent Computing environment can be used to deploy virtual desktops on service modules and remote computers such as desktops and thin client devices. It is similar to other rendering protocols for remote desktop management.
The client can be specifically a SPICE-client which is a SPICE client running on the thin client and is responsible for receiving the QXL command sent by the service module, rendering and displaying the QXL command to a user.
In an embodiment of the present application, before step S103 is executed, the virtual machine and the network condition inside the virtual machine may be further determined, so as to determine which display manner is selected. Specifically, the following steps may be performed:
judging whether a network communication connection exists between an operating system and a service module;
if so, sending the operation command to a service module by using network communication connection, and sending the operation command to a client by using the service module so that the client can perform desktop rendering and display by using the operation command;
and step three, if not, executing the step of writing the operation command into the shared memory equipment by using the operating system.
That is, if there is a network communication connection between the operating system and the service module, the operating command can be directly sent to the service module through the network communication connection, and if there is no network communication connection between the operating system and the access module, the steps S103 to S104 are executed.
The method provided by the embodiment of the application is applied to the virtual machine and comprises the following steps: acquiring the picture change content of the virtual machine by using an operating system; generating an operation command corresponding to the screen change content by using an operation system; writing an operation command into the shared memory equipment by using an operating system; and the service module is used for reading the operation command from the shared memory device in a timing or real-time manner and sending the operation command to the client so that the client can perform desktop rendering and display by using the operation command.
In the application, firstly, an operating system is used for obtaining the screen change content of the virtual machine, generating an operation command corresponding to the screen change content, and writing the operation command into the shared memory device. Then, the service module is used for directly reading the operation command from the shared memory device in a timing or real-time mode and sending the operation command to the client. The client can be enabled to perform desktop rendering and display based on the operation command. Therefore, in the application, the screen change content of the virtual machine can be read from the shared memory device, and the subsequent rendering and display can be realized based on the operation command without additionally simulating the virtual display device, so that the method can be applied to various CPU architectures such as an ARM architecture and an MIPS architecture. Meanwhile, the service module directly reads the operation command from the shared storage device, so as to send the operation command to the client. Thus, the operating system of the virtual machine need not communicate with the service module, nor with the client network. That is, the display image data of the virtual machine is transmitted to the service module through the shared device, and further transmitted to the client by the service module, which has no requirement on the network of the virtual machine itself and the operating system in the virtual machine. Therefore, the desktop display performance of the virtual machine can be improved on the basis of being compatible with various CPU architectures.
In order to make those skilled in the art better understand the virtual machine desktop display method provided in the embodiments of the present application, the following description is provided for the virtual machine desktop display method in combination with the related art and a specific application scenario of the virtual machine desktop display method.
The remote access virtual machine solutions include SPICE, RDP, VNC, etc., and the following mainly describes the principle of obtaining the display content of the virtual machine and the corresponding disadvantages.
The RDP and the VNC acquire the display content of the virtual machine in a mode that the whole screen content is captured at regular time inside the virtual machine and then compared with the previous captured screen image to find a difference area. The difference area is the area of the screen that needs to be updated at this time. Then the region of the frame image is encoded, compressed and transmitted to the client for display. It can be seen that such schemes as RDP and VNC have: the performance overhead is large: the whole screen content is obtained regularly, and the performance overhead for content comparison is high, which can cause poor user experience; the network of the virtual machine needs to be communicated with the network of the client, that is, the image content intercepted by the RDP and the VNC needs to be sent to the client for rendering through the network.
The SPICE scheme mainly obtains images through QEMU simulated QXL display equipment, the virtual machine internal display driver writes image content needing to be updated into the QXL device, and an SPICE server (the same as the service module in the above) reads display content in the QXL device through an interface provided by QEMU, so that changed display content can be obtained. The SPICE scheme relies on QXL virtual machine equipment of QEMU, and the QXL virtual machine equipment can only be used in a virtual machine under an X86 framework at present and cannot be used in a virtual machine under ARM or MIPS.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating an embodiment of a method for displaying a desktop of a virtual machine.
Wherein, xclient: the application program in the Linux virtual machine is connected to the xserver and then responsible for responding to the operation of the user and updating the picture;
xserver: the display service program in the Linux virtual machine is responsible for transmitting the input event to the xclient and rendering the drawing instruction;
xslice: the virtual display driver in the xserver is responsible for acquiring the picture change of the virtual machine at regular time or in real time and constructing the picture change into a QXL command to be written into the shared memory device;
ivshmem: the shared memory device virtualized by the QEMU is responsible for sharing the QXL command between the Linux virtual machine and the QEMU;
xslice-display: the QEMU internal module provides a VDI interface for the spice-server and realizes the reading and releasing operations of the QXL display command and the cursor command;
spice-server: the SPICE server running inside the QEMU is responsible for taking out the QXL command and sending the QXL command to the SPICE client;
spice-client: and the SPICE client running on the thin client is responsible for receiving the QXL command sent by the server, rendering and displaying the QXL command to the user.
Generating a screen from the inside of the virtual machine to the client display, and going through the following steps:
step 1, when an xclient program interface changes, sending a drawing instruction to an xserver;
step 2, the xserver renders the drawing instruction to form a final virtual machine picture;
step 3, the xspec monitors the change of the virtual machine picture, converts the picture change into a QXL command in a timed or real-time manner and writes the QXL command into the shared memory;
step 4, the spice-server calls an interface provided by the xsspice-display and reads a QXL command in the shared memory;
step 5, the spice-server constructs the QXL command into a message of a display channel and a cursor channel and sends the message to the spice-client;
step 6, reading the channel message sent by the server by the spice-client, and rendering the channel message to the local
Therefore, the method for displaying the desktop of the virtual machine provided by the embodiment of the application can acquire the change of the display content by realizing the X11 virtual display drive, and then transmit the image data through a shared memory device of the QEMU, so that the transmission efficiency of the display data can be remarkably improved and the user experience can be optimized by combining the image data and the QEMU. The main advantages are that:
the compatibility is good: the display driver of the X11 can be used for acquiring changed display contents without extra QEMU simulation of virtual display equipment, and the display driver can be suitable for platforms with various CPU architectures, including chips such as ARM and MIPS.
The performance is high: when the display content is drawn, the X11 only draws the area which needs to be redrawn, and the changed display content can be acquired by the X11 virtual display driver without performing additional display frame comparison operation. Meanwhile, display data can be efficiently transmitted to the server for processing through the QEMU shared memory device.
The network of virtual machines need not communicate with the client network: the display image data of the virtual machine is transmitted to the virtualization platform server through the QEMU sharing device for coding processing, and finally transmitted to the client, and no requirement is made on the network of the virtual machine.
Corresponding to the above method embodiments, the present application further provides a virtual machine desktop display apparatus, and the virtual machine desktop display apparatus described below and the virtual machine desktop display method described above may be referred to in a corresponding manner.
Referring to fig. 3, the virtual machine desktop display apparatus includes:
a virtual machine simulator 101 and an operating system 102 with a display driver 103;
the virtual machine simulator is used for simulating the service module 104 and the shared memory device 105;
the display driver is used for acquiring the picture change content of the virtual machine, generating an operation command corresponding to the picture change content, and writing the operation command into the shared memory device;
and the service module is used for reading the operation command from the shared memory device in a timing or real-time manner and sending the operation command to the client so that the client can perform desktop rendering and display by using the operation command.
The device provided by the embodiment of the application is applied to a virtual machine and comprises the following components: acquiring the picture change content of the virtual machine by using an operating system; generating an operation command corresponding to the screen change content by using an operation system; writing an operation command into the shared memory equipment by using an operating system; and the service module is used for reading the operation command from the shared memory device in a timing or real-time manner and sending the operation command to the client so that the client can perform desktop rendering and display by using the operation command.
In the application, firstly, an operating system is used for obtaining the screen change content of the virtual machine, generating an operation command corresponding to the screen change content, and writing the operation command into the shared memory device. Then, the service module is used for directly reading the operation command from the shared memory device in a timing or real-time mode and sending the operation command to the client. The client can be enabled to perform desktop rendering and display based on the operation command. Therefore, in the application, the screen change content of the virtual machine can be read from the shared memory device, and the subsequent rendering and display can be realized based on the operation command without additionally simulating the virtual display device, so that the method can be applied to various CPU architectures such as an ARM architecture and an MIPS architecture. Meanwhile, the service module directly reads the operation command from the shared storage device, so as to send the operation command to the client. Thus, the operating system of the virtual machine need not communicate with the service module, nor with the client network. That is, the display image data of the virtual machine is transmitted to the service module through the shared device, and further transmitted to the client by the service module, which has no requirement on the network of the virtual machine itself and the operating system in the virtual machine. Therefore, the desktop display performance of the virtual machine can be improved on the basis of being compatible with various CPU architectures.
In an embodiment of the present application, the display driver is specifically an X11 display driver, that is, the virtual machine desktop display device acquires the screen change content of the virtual machine by using the X11 display driver. Further, the screen change content of the virtual machine is acquired by using a virtual display driver among the X11 display drivers.
In a specific embodiment of the present application, an operating system is used to generate an operating command corresponding to a frame change content and conforming to a virtual display device simulated by a virtual machine simulator; and utilizing the service module simulated by the virtual machine simulator to read the operation command from the shared memory device simulated by the virtual machine simulator in a timing or real-time manner.
In a specific embodiment of the application, an operating system is utilized to generate a display command and/or a cursor command which is in accordance with QXL virtual display equipment simulated by a virtual machine simulator and corresponds to the picture change content; the display command and/or the cursor command are determined as the operation command.
In a specific embodiment of the present application, a VDI interface simulated by a virtual machine simulator is used to read an operation command from a shared memory device in a timed or real-time manner; and sending the operation command to the client by using the service module simulated by the virtual machine simulator.
In one embodiment of the present application, the service module simulated by the virtual machine simulator is used to send the operation command to the client through the SPICE protocol.
In a specific embodiment of the present application, it is determined whether a network communication connection exists between an operating system and a service module;
if so, sending the operation command to the service module by using the network communication connection, and sending the operation command to the client by using the service module so that the client can perform desktop rendering and display by using the operation command;
and if not, executing the step of writing the operation command into the shared memory device by using the operating system.
In one embodiment of the present application, the operation command is a QXL command.
Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device, and the electronic device described below and the virtual machine desktop display method described above may be referred to in a corresponding manner.
Referring to fig. 4, the electronic device includes:
a memory 332 for storing a computer program;
and a processor 322, configured to implement the steps of the virtual machine desktop display method of the foregoing method embodiment when executing the computer program.
Specifically, referring to fig. 5, a specific structural diagram of an electronic device provided in this embodiment is shown, where the electronic device may generate a larger difference due to different configurations or performances, and may include one or more processors (CPUs) 322 (e.g., one or more processors) and a memory 332, where the memory 332 stores one or more computer applications 342 or data 344. Memory 332 may be, among other things, transient or persistent storage. The program stored in memory 332 may include one or more modules (not shown), each of which may include a sequence of instructions operating on a data processing device. Still further, the central processor 322 may be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
The electronic device 301 may also include one or more power sources 326, one or more wired or wireless network interfaces 350, one or more input-output interfaces 358, and/or one or more operating systems 341.
The steps in the virtual machine desktop display method described above may be implemented by the structure of the electronic device.
Corresponding to the above method embodiment, an embodiment of the present application further provides a readable storage medium, and a readable storage medium described below and a virtual machine desktop display method described above may be referred to in correspondence.
A readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the virtual machine desktop display method of the above-described method embodiment.
The readable storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various other readable storage media capable of storing program codes.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.