Virtual machine image frame rate control method, network device and storage mediumTechnical Field
The present disclosure relates to the field of communications technologies, and in particular, to a method, a network device, and a storage medium for controlling an image frame rate of a virtual machine.
Background
The virtual machine (cloud desktop) is based on a virtual desktop infrastructure, and can host the desktop environment of a user to a high-performance server in the form of a cloud desktop, so that the user experience almost the same as that of a physical computer is provided for the user. The method is widely applied to the solution of the cloud desktop such as daily office, school teaching and the like.
When the image on the virtual machine (cloud desktop) is rapidly updated, if the image is sent to the client in a general compression coding mode, a large amount of bandwidth is occupied, and the problem of terminal decoding congestion is caused.
Disclosure of Invention
In order to overcome the problems in the related art, the present specification provides a virtual machine image frame rate control method, a network device, and a storage medium.
According to a first aspect of embodiments herein a virtual machine image frame rate control method,
saving a configuration file of the virtual machine, wherein the configuration file at least comprises the highest frame rate max _ fps of image transmission;
receiving a display card instruction of the virtual machine, and recording the instruction time of the display card;
analyzing the video card instruction to obtain an image of the virtual machine and a surface of the image;
judging whether the frame rate of the received images sent by the virtual machine is higher than a set maximum frame rate max _ fps;
if the frame rate is in the set range, sending the image to the client in a compression coding mode;
if the frame rate is higher than the set range, a timer is started, and the images are sent to the client in the full-screen streaming mode of the images at the time interval of 1/max _ fps.
Preferably, the configuration file further comprises a timeout time timeout for the timer to time the acquisition of the image,
if the time interval exceeds 1/max _ fps and no video card instruction sent by the virtual machine is received, starting a timer, and judging the difference between the current recording time of the timer and the time when the last video card instruction is received;
if the difference value is smaller than timeout, acquiring a full-screen streaming mode image of the image and sending the full-screen streaming mode image to the client;
if the difference is larger than or equal to timeout, the image is not updated, the timer is closed, and the image is sent to the client in a compression coding mode.
Preferably, under the condition that the difference value is less than timeout, the full-screen streaming mode image is transmitted to the client, and the timer is reset, and the time interval is 1/max _ fps.
Further, the step of judging whether the frame rate of the received image sent by the virtual machine is higher than the set maximum frame rate max _ fps comprises the following steps:
finding corresponding image data on the shared storage of the virtual machine through an image storage address in the surface;
and judging whether the frame rate of the currently found image is higher than the set highest frame rate max _ fps.
Preferably, the method comprises the steps of receiving a display card instruction of the virtual machine, establishing protocol connection with the virtual machine before recording the display card instruction time, and acquiring identification information of the virtual machine.
Further, the identification information includes at least ip and port information of the virtual machine.
The embodiment of the present application further provides a network device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the program to perform the above-mentioned method for controlling the image frame rate of the virtual machine.
Finally, the present embodiment also provides a storage medium, on which computer program instructions are stored, and the program instructions are executed by a processor to implement the above-mentioned method for controlling the image frame rate of the virtual machine.
The technical scheme provided by the embodiment of the specification can have the following beneficial effects:
in the embodiment of the present description, by setting the highest frame rate, the image adopts different image transmission modes at different frame rates. The high frame rate image is directly transmitted through a full screen stream mode, so that the problems of decoding blockage and delay blockage when the high frame rate image is transmitted to a client are solved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present specification and together with the description, serve to explain the principles of the specification.
FIG. 1 is a schematic diagram of networking of an embodiment of the present application;
FIG. 2 is a flowchart of a method for controlling a frame rate of a virtual machine according to the present application;
fig. 3 is a flowchart of sending an image when a virtual machine is not timed according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.
In order to solve the problems in the background art, the application provides a virtual machine image frame rate control method, and a client acquires image information on a virtual machine through a host. In the networking, a client needs to establish link connection with a host machine at first, the host machine needs to establish protocol connection with a virtual machine, and the host machine acquires identification information of the virtual machine. The host typically has multiple virtual machines (virtual machine 1, virtual machine 2, and virtual machine 3) hanging down, and the host is connected with multiple clients (client 1, client 2, and client 3), as in fig. 1. The embodiment of the present application takes an example where the client 1 requests to acquire an image on the virtual machine 1 through the host as an example. In addition, the protocol established between the host and the virtual machine in the above embodiment may be, for example, an existing RDP or spice protocol, or may be a custom protocol. Since it is not the point of the invention of the present application, it will not be described herein in detail. The host machine and each virtual machine client only have one protocol connection process, and the host machine and each virtual machine client are connected to the server side of the host machine through the process and used for image transmission. After the host machine and the virtual machine are connected through the protocol, the host machine obtains the identification information of the virtual machine, the identification information at least comprises ip and port information of the virtual machine, and one-to-one connection between a server side of the host machine and the progress of the virtual machine and image information interaction are achieved. The host machine stores configuration files of each virtual machine. The configuration file is mainly the highest frame rate max _ fps for sending the image, and the timeout time timeout for timer timing to acquire the image. And analyzing the display card instruction to obtain the image, the image storage address information and the like of the corresponding virtual machine.
As shown in fig. 2, the specific interaction process is as follows:
the client 1 requests the host machine for the image of the virtual machine 1, so that the host machine sends an image request to the virtual machine 1 after receiving the request;
the host machine receives a display card instruction of the virtual machine 1 and records the arrival time of the display card instruction;
the host machine analyzes the display card instruction to obtain the image of the corresponding virtual machine and the surface of the image; judging whether the frame rate of the received image transmitted from the virtual machine 1 is higher than the set highest frame rate max _ fps; if the frame rate is in the set range, the image is sent to the client 1 in a compression encoding mode; if the frame rate is higher than the set range, a timer is started, and the image is transmitted to the client 1 in the full-screen streaming mode of the image at a time interval of 1/max _ fps. It should be noted here that the full screen streaming mode refers to transmitting an image in the form of a full screen video. And the image transmitted by the general compression coding method is transmitted in the form of a common picture or a photo.
The surface in the application refers to a storage address of a host server for storing a current display sending image of a virtual machine. The storage address refers to the storage address of the image stored on the shared storage of all the down-hanging virtual machines of the host.
Because the virtual machine 1 may not send a video card instruction to the host at the set time interval of 1/max _ fps, starting a timer of a host server process, judging the difference between the current recording time of the timer and the time of receiving the last previous instruction, and if the difference is less than timeout, acquiring a full-screen streaming mode image of the image and sending the full-screen streaming mode image to the client 1; if the difference is greater than or equal to timeout, the image is not updated, the timer is closed, and the image is sent to the client 1 in a compression coding manner, as shown in fig. 3.
In the above embodiment, the method for determining whether the frame rate of receiving the image transmitted by the virtual machine 1 is higher than the set maximum frame rate max _ fps includes:
finding image data corresponding to the shared storage of all the virtual machines through the image storage address in the surface;
and judging whether the frame rate of the currently found image is higher than the set highest frame rate max _ fps.
According to the embodiment of the application, the highest frame rate is set, and different image transmission modes are adopted for the images at different frame rates. The high frame rate image is directly transmitted through a full screen stream mode, so that the problems of decoding blockage and delay blockage when the high frame rate image is transmitted to a client are solved.
The embodiment of the present application further provides a network device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the processor executes the computer program, the processor executes the method for controlling the image frame rate of the virtual machine according to the foregoing embodiment.
The embodiment of the present application further provides a storage medium, on which computer program instructions are stored, and the program instructions are executed by a processor to implement the method for controlling the image frame rate of the virtual machine according to the above embodiment.
It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.