Virtual machine control method and device, computer equipment and storage medium

By adjusting the polling time threshold of the virtual machine and optimizing the pause and resume strategy of the virtual machine according to the change rate of the recovery time, the problem of low processing efficiency caused by frequent switching of virtual machines is solved, and processing efficiency and resource utilization are improved.

CN120631504APending Publication Date: 2025-09-12NEW H3C CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510725818.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

The frequent switching of virtual machines during virtual machine exit and re-entry is very costly, resulting in inefficient processing and poor user experience.

Method used

By receiving the current pause instruction of the virtual machine, checking whether a new task is obtained according to the polling time threshold, determining the recovery duration, and adjusting the polling time threshold based on the change rate of the recovery duration, the virtual machine's pause and resume strategy can be dynamically adjusted to reduce unnecessary virtual machine exit and re-entry operations.

Benefits of technology

It effectively improves the processing efficiency of virtual machines, reduces the possibility of virtual machine exit, and improves resource utilization and Polling success rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631504A_ABST
    Figure CN120631504A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of virtualization, and discloses a virtual machine control method and device, computer equipment and a storage medium, and the method comprises the steps: receiving a current pause instruction of a virtual machine, and checking whether a new task of the virtual machine is obtained or not according to a current polling time threshold value; under the condition that the new task of the virtual machine is obtained, determining the current recovery duration corresponding to the current pause instruction according to the duration from the time when the current pause instruction is received to the time when the new task is obtained; determining the change rate of the recovery duration according to the current recovery duration and the historical recovery duration corresponding to the plurality of historical pause instructions; on the basis of the current polling time threshold value, the polling time threshold value is adjusted according to the change rate; wherein if the change rate is a positive value, the polling time threshold value is increased, and if the change rate is a negative value, the polling time threshold value is reduced. According to the invention, while the resource utilization rate is ensured, the success rate of Pollling is effectively improved, and the possibility of executing virtual machine exit is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtualization technology, and in particular to a control method, device, computer equipment and storage medium for a virtual machine. Background Art

[0002] The process from virtual machine exit (vm_exit) to virtual machine re-entry (vm_entry) involves multiple overheads, including maintaining and restoring the virtual machine state and CPU (Central Processing Unit) register state, switching CPU modes, switching kernel scheduling, and refreshing and switching memory page tables. These operations require thousands of instruction cycles, and frequent switching incurs huge overhead and large latency, affecting virtual machine processing efficiency and poor user experience. Summary of the Invention

[0003] In view of this, the present invention provides a virtual machine control method, apparatus, computer equipment, and storage medium to reduce the probability of executing a virtual machine exit while ensuring resource utilization.

[0004] In a first aspect, the present invention provides a method for controlling a virtual machine, comprising:

[0005] Receive a current pause instruction of the virtual machine, and check whether a new task of the virtual machine is obtained according to a current polling time threshold;

[0006] After receiving the current pause instruction, in the case of obtaining a new task for the virtual machine, determining a current resume duration corresponding to the current pause instruction based on a time duration between receiving the current pause instruction and obtaining the new task; wherein, if the time duration between receiving the current pause instruction and obtaining the new task exceeds a preset maximum polling time, setting the current resume duration to a calibration value, the calibration value being less than a minimum value of historical resume durations within a preset historical time period;

[0007] Determining a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding to the plurality of historical pause instructions;

[0008] Based on the current polling time threshold, the polling time threshold is adjusted according to the change rate; wherein, when the change rate is a positive value, the polling time threshold is increased, and when the change rate is a negative value, the polling time threshold is decreased.

[0009] In some optional implementations, after receiving the current pause instruction, in a case where a new task of the virtual machine is acquired, determining the current resume duration corresponding to the current pause instruction based on a time duration between receiving the current pause instruction and acquiring the new task includes:

[0010] After receiving the current pause instruction, if a new task of the virtual machine is obtained within the preset maximum polling time, the duration from receiving the current pause instruction to obtaining the new task is used as the current resume duration corresponding to the current pause instruction.

[0011] In some optional implementations, determining the change rate of the recovery duration based on the current recovery duration and multiple historical recovery durations corresponding to multiple historical pause instructions includes:

[0012] The current recovery time and the number index of the historical recovery time corresponding to the multiple historical pause instructions are used as the coordinates of the first direction, and the current recovery time and the multiple historical recovery time are used as the coordinates of the second direction. The recovery time is linearly fitted to determine the rate of change of the recovery time.

[0013] In some optional embodiments, performing linear fitting on the recovery time to determine the rate of change of the recovery time includes:

[0014] According to the weighted least squares method, based on the weight of the current recovery time and the weights of the multiple historical recovery times, the current recovery time and the multiple historical recovery times are linearly fitted to determine the rate of change of the recovery time. The weight of the current recovery time is greater than the weight of each of the historical recovery times, and the weights of the multiple historical recovery times increase in chronological order.

[0015] In some optional implementations, the adjustment value of the polling time threshold is positively correlated with the change rate.

[0016] In some optional implementations, adjusting the polling time threshold based on the current polling time threshold and according to the change rate includes:

[0017] The adjusted value of the polling time threshold is determined according to the preset adjustment step size and the change rate of the polling time threshold; and the adjusted value of the polling time threshold is added to the current polling time threshold to obtain the adjusted polling time threshold.

[0018] In some optional implementations, adjusting the polling time threshold based on the current polling time threshold and according to the change rate includes:

[0019] When the current recovery duration is a calibrated value and the change rate is zero, the polling time threshold is adjusted to a preset default threshold.

[0020] In some optional implementations, checking whether a new task of the virtual machine is acquired according to the current polling time threshold includes:

[0021] Trigger the timer;

[0022] Regularly checking whether a new task of the virtual machine is obtained; if the timer does not reach the current polling time threshold, if no new task of the virtual machine is obtained, entering a low power consumption state; if a new task of the virtual machine is obtained, resuming the operation of the virtual machine and executing the step of determining the current resumption duration;

[0023] If no new task of the virtual machine is obtained when the timer reaches the current polling time threshold, the virtual machine exit action is executed and the new task of the virtual machine is waited for until the new task of the virtual machine is obtained, and the step of determining the current recovery duration is executed.

[0024] In a second aspect, the present invention provides a virtual machine control device, comprising:

[0025] An instruction receiving module is used to receive the current pause instruction of the virtual machine and check whether a new task of the virtual machine is obtained according to the current polling time threshold;

[0026] a duration determination module, configured to, after receiving the current pause instruction and, in the case of acquiring a new task for the virtual machine, determine a current resume duration corresponding to the current pause instruction based on a duration between receiving the current pause instruction and acquiring the new task; wherein, if the duration between receiving the current pause instruction and acquiring the new task exceeds a preset maximum polling time, setting the current resume duration to a calibration value, the calibration value being less than a minimum value of historical resume durations within a preset historical time period;

[0027] a processing module, configured to determine a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding one-to-one to a plurality of historical pause instructions;

[0028] The adjustment module is used to adjust the polling time threshold based on the current polling time threshold according to the change rate; wherein, when the change rate is a positive value, the polling time threshold is increased, and when the change rate is a negative value, the polling time threshold is decreased.

[0029] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to thereby execute the control method of the virtual machine of the first aspect or any corresponding embodiment thereof.

[0030] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for controlling a virtual machine according to the first aspect or any corresponding embodiment thereof.

[0031] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method for controlling a virtual machine according to the first aspect or any corresponding embodiment thereof.

[0032] The present invention determines the corresponding recovery duration based on the time from receiving the pause instruction to obtaining the new task, and obtains the change rate of the recovery duration based on the fitting of multiple recovery durations. The polling time threshold is adaptively adjusted based on the change rate. This not only avoids severe jitter of the polling time threshold, but also makes the adjusted polling time threshold closer to the polling time threshold before adjustment. While ensuring resource utilization, it effectively improves the success rate of Polling and reduces the possibility of executing virtual machine exit. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0034] Figure 1 2. Schematic diagram of state transition of suspend polling according to an embodiment of the present invention;

[0035] Figure 2 is a flow chart of a method for controlling a virtual machine according to an embodiment of the present invention;

[0036] Figure 3 is a flow chart of another virtual machine control method according to an embodiment of the present invention;

[0037] Figure 4 is a detailed flowchart of a method for controlling a virtual machine according to an embodiment of the present invention;

[0038] Figure 5 is a structural block diagram of a control device for a virtual machine according to an embodiment of the present invention;

[0039] Figure 6 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.

[0041] For the convenience of description, some terms involved in this embodiment are first explained. These explanations are intended to make the embodiments of this application easier to understand and should not be regarded as limiting the scope of protection claimed in this application.

[0042] (1) Virtual Machine: A logical server simulated by virtualization software. Usually, a physical server can be used to create multiple virtual machines, each of which also runs an operating system.

[0043] (2) Virtualization: This is a technology that enables multiple operating systems or applications to run on the same physical hardware by abstracting hardware resources (such as CPU, memory, storage, and network). For example, virtualization of a physical CPU can implement vCPU (virtual processor). The main purpose of virtualization is to improve resource utilization, provide flexibility, and provide isolation. Virtualization is usually implemented by a software layer called a virtual machine monitor (VMM), which is responsible for managing the operation of virtual machines.

[0044] (3) VMM: Virtual Machine Monitor (VMM), also known as Hypervisor, is a core component of virtualization technology. It is a software or firmware that sits between the underlying hardware and the virtual machine, responsible for managing the operation, resource allocation, and isolation of the virtual machine.

[0045] The main functions of VMM include: creating and destroying virtual machines; allocating and managing the computing resources (CPU, memory, storage, network) required by virtual machines; providing isolation between virtual machines to ensure security; and enabling interaction between virtual machines and underlying hardware.

[0046] (4) VM_EXIT: This is a term widely used to describe virtual machine exit events in virtualized environments. In hardware virtualization, VM_EXIT refers to the process of switching from guest mode to host mode. When a virtual CPU (vCPU) performs certain operations or an event occurs, VM_EXIT may be triggered, switching to host mode to allow the hypervisor to handle these events.

[0047] (5) VM_ENTRY: A term used to describe a virtual machine entry event. In a hardware virtualization environment, it is the process of switching a virtual processor from host mode to guest mode. This process is in contrast to VM_EXIT, which transfers control from the virtual machine to the hypervisor, while VM_ENTRY returns control from the hypervisor to the virtual machine.

[0048] According to one embodiment of the present invention, one optimization direction for improving vCPU utilization is to reduce the number of switching between vm_exit and vm_entry during virtual machine operation. This can be achieved based on a Halt Polling optimization method.

[0049] Specifically, suppose a virtual machine is used for a while and then stopped for a while. When stopped, it executes vm_exit, and when it is used again, it executes vm_entry. Halt Polling, however, means that when a virtual machine is stopped, KVM (Kernel-based Virtual Machine), a kernel-based virtualization technology, does not execute vm_exit first. Instead, it polls for a period of time, executing a low-power instruction. When the virtual machine is used again, it resumes operation without the overhead of executing vm_exit and then vm_entry.

[0050] The principle of Halt Polling is to let the vCPU execute fake tasks (low-power instructions) for a period of time instead of directly giving the vCPU to other processes (executing vm_exit will release the corresponding vCPU); if the virtual machine has a new task during the Polling time, the vCPU can be used directly without switching from vm_exit to vm_entry, thereby reducing the consumption of vm_exit.

[0051] Schematic diagram of the state transition of the virtual machine Halt Polling, for details, see Figure 1 shown.

[0052] Halt Polling is provided with a polling time threshold. To adapt to changes in virtual machines, it is generally necessary to be able to dynamically adjust the polling time threshold.

[0053] A Halt Polling algorithm works as follows: a polling time threshold (halt_poll_ns) is set for the vCPU (a nanosecond threshold). If a VM has no tasks to process, it notifies the KVM via a HALT instruction (HLT). Upon receiving the HALT instruction, the KVM executes polling for the halt_poll_ns time. If the VM has tasks within the polling time, it resumes operation, and the halt_poll_ns polling time threshold remains unchanged.

[0054] If the virtual machine has no tasks within the Polling time, KVM releases the vCPU and executes vm_exit; if a new task is scheduled back to the virtual machine within a period of time, KVM multiplies the polling time threshold halt_poll_ns by a preset multiple (usually multiplied by 2); conversely, if the virtual machine still has no new tasks after a period of time, the polling time threshold halt_poll_ns is reduced, for example, to the initial value, to shorten the waiting time of Halt Polling.

[0055] Although this method can dynamically adjust the polling threshold, it can cause significant fluctuations in the polling threshold, impacting the effectiveness of Halt Polling. For example, if the polling threshold drops rapidly, subsequent polling times will be exceeded, significantly reducing the Halt Polling success rate in the short term.

[0056] An embodiment of the present invention provides a method for controlling a virtual machine, which determines the recovery duration corresponding to the resumption of a task after each suspension of the virtual machine, and determines how to adjust the polling time threshold based on the rate of change of the recovery duration. While ensuring that the polling time threshold meets basic requirements, the polling time threshold can be adjusted slightly, which is beneficial to improving the success rate of subsequent polling.

[0057] According to an embodiment of the present invention, an embodiment of a method for controlling a virtual machine is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0058] In this embodiment, a method for controlling a virtual machine is provided, which can be applied to a terminal or server supporting virtual machine technology, and specifically to a virtual machine monitor, such as KVM. Figure 2 is a flow chart of a method for controlling a virtual machine according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps.

[0059] Step S201: receiving a current pause instruction of a virtual machine, and checking whether a new task of the virtual machine is obtained according to a current polling time threshold.

[0060] In this embodiment, the virtual machine monitor supports Halt Polling and pre-sets a polling time threshold. When no tasks need to be executed in the virtual machine, a corresponding pause instruction, such as an HLT instruction, can be issued. Upon receiving this pause instruction, the virtual machine monitor enters a pause polling mode, i.e., Halt Polling, to perform corresponding processing to check whether a new task has been acquired for the virtual machine. For example, within the current polling time threshold, the monitor actively queries whether a new task has been acquired for the virtual machine through polling. If the polling time exceeds the current polling time threshold, the monitor executes the virtual machine exit action and then passively waits for a new task to be acquired for the virtual machine.

[0061] A virtual machine can initiate pause commands multiple times, and the polling time threshold is dynamically adjustable. This means the specific value of the polling time threshold may vary at different times or under different circumstances. For ease of description, the pause command initiated by the virtual machine is referred to as the current pause command, and the polling time threshold set at that time is referred to as the current polling time threshold.

[0062] Step S202: After receiving the current pause instruction, if a new task of the virtual machine is acquired, the current resume duration corresponding to the current pause instruction is determined based on the time between receiving the current pause instruction and acquiring the new task. If the time between receiving the current pause instruction and acquiring the new task exceeds a preset maximum polling time, the current resume duration is set to a calibration value. The calibration value is less than the minimum value of the historical resume durations within a preset historical time period.

[0063] In this embodiment, after receiving the current pause instruction, in addition to performing polling, the virtual machine monitor also waits for a new task corresponding to the virtual machine. If a new task is received for the virtual machine, it indicates that the virtual machine has completed task recovery. The duration of task recovery for the virtual machine at this time is the duration from receiving the current pause instruction to obtaining the new task. The new task is the task that resumes the virtual machine's operation and is also the first task received after the current pause instruction.

[0064] Based on the time from the receipt of the current pause instruction to the acquisition of the new task, the resumption time corresponding to the current pause instruction, i.e., the current resumption time, is determined. The current resumption time is positively correlated with the aforementioned time (i.e., the time from the receipt of the current pause instruction to the acquisition of the new task), i.e., the longer the time from the receipt of the current pause instruction to the acquisition of the new task, the longer the current resumption time.

[0065] In addition, a maximum polling time is pre-set in this embodiment, and the dynamically adjusted polling time threshold must not exceed the maximum polling time. If the time between receiving the current pause instruction and obtaining the new task exceeds the maximum polling time, it means that the time required for the virtual machine to resume the task at this time is too long. Continuing to increase the polling time threshold will cause the vCPU to be occupied for a long time, and the utilization rate of processing resources will be low. Therefore, it is necessary to lower the polling time threshold at this time. In this case, the current recovery time is set to a calibration value, which is a smaller value, to achieve the effect of reducing the polling time threshold.

[0066] In particular, there may be multiple historical pause instructions within a preset time period, and the corresponding recovery duration, i.e., the historical recovery duration, can be determined based on each historical pause instruction. In this embodiment, the minimum value of the multiple historical recovery durations within the preset historical time period can be determined, and the calibration value of the current recovery duration is less than the minimum value of these historical recovery durations. That is, when the duration of the virtual machine's resumption of operation exceeds the maximum polling time, the current recovery duration is set to a smaller value, so that the multiple recovery durations can show a downward trend as a whole, that is, the rate of change of the recovery duration is negative, which facilitates the subsequent determination of an appropriate polling time threshold.

[0067] Step S203 : determining a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding one-to-one to a plurality of historical pause instructions.

[0068] In this embodiment, the virtual machine may initiate a pause instruction multiple times, that is, before the current pause instruction, there may be a previous pause instruction, that is, a historical pause instruction; for the previous historical pause instruction, the recovery time corresponding to the historical pause instruction, that is, the historical recovery time, can also be determined based on the process from step S201 to step S202.

[0069] It is understandable that the historical resumption duration corresponding to the historical pause instruction may be determined based on the duration from when the historical pause instruction is received to when the new task is first acquired.

[0070] The current recovery time and multiple historical recovery times represent the recovery times corresponding to different moments. Therefore, a linear fit is performed based on these recovery times (including the current recovery time and multiple historical recovery times) to determine the rate of change of the recovery time. The rate of change can indicate whether the recovery time has increased or decreased, or the rate of increase or decrease of the recovery time.

[0071] The historical pause instruction used to determine the recovery duration change rate may be a pause instruction within the aforementioned preset historical time period, to ensure that the set calibration value does not exceed the minimum value of each historical recovery duration. For example, the calibration value is less than the minimum value of the multiple historical recovery durations used to determine the recovery duration change rate.

[0072] Step S204 , based on the current polling time threshold, adjust the polling time threshold according to the change rate; wherein, if the change rate is a positive value, increase the polling time threshold, and if the change rate is a negative value, decrease the polling time threshold.

[0073] In this embodiment, the rate of change of the recovery time indicates the change of the recovery time. If the recovery time is increasing (the rate of change is a positive value), it means that the virtual machine recovery task requires a longer time. Therefore, the polling time threshold is appropriately increased at this time to ensure that new tasks of the virtual machine can be received within the Polling time, avoiding the execution of vm_exit, thereby improving the success rate of Polling.

[0074] On the contrary, if the recovery time is getting shorter (the rate of change is negative), it means that the virtual machine recovery task only takes a shorter time. Therefore, the polling time threshold should be appropriately reduced at this time to ensure the success rate of Polling while avoiding the possibility of occupying more processing resources due to a larger polling time threshold.

[0075] In addition, if the change rate is negative, the recovery time may exceed the maximum polling time. In this case, even if the polling time threshold is increased, Polling will still likely fail, that is, no new tasks for the virtual machine can be obtained within the Polling time. Therefore, adaptively reducing the polling time threshold can reduce the occupancy of processing resources and release vCPU resources more quickly for use by other virtual machines.

[0076] Based on the principles of statistics and locality, there is a higher probability that the future operation status of the virtual machine is close to the most recent status. Therefore, when adjusting the polling time threshold, it is adjusted based on the current polling time threshold so that the adjusted polling time threshold is close to the previous polling time threshold (that is, the current polling time threshold here). This not only avoids large fluctuations in the polling time threshold but also ensures the success rate of polling.

[0077] For example, if the change rate is a positive value, then a certain duration is added to the current polling time threshold to obtain an adjusted polling time threshold, that is, a larger polling time threshold; if the change rate is a negative value, then a certain duration is reduced based on the current polling time threshold to obtain an adjusted polling time threshold, that is, a smaller polling time threshold.

[0078] The virtual machine control method provided in this embodiment determines the corresponding recovery duration according to the time from receiving the pause instruction to obtaining the new task, and obtains the change rate of the recovery duration based on the fitting of multiple recovery durations. The polling time threshold is adaptively adjusted based on the change rate. This not only avoids severe jitter of the polling time threshold, but also makes the adjusted polling time threshold closer to the polling time threshold before adjustment. While ensuring resource utilization, it effectively improves the success rate of Polling and reduces the possibility of executing virtual machine exit.

[0079] In this embodiment, a method for controlling a virtual machine is provided, which can be applied to a terminal or server supporting virtual machine technology, and specifically to a virtual machine monitor, such as KVM. Figure 3 is a flow chart of a method for controlling a virtual machine according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps.

[0080] Step S301: Receive the current pause instruction of the virtual machine, and check whether a new task of the virtual machine is obtained according to the current polling time threshold.

[0081] For details, please see Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.

[0082] Optionally, the above step S301 of “checking whether a new task of the virtual machine is obtained according to the current polling time threshold” specifically includes steps A1 to A3.

[0083] Step A1: trigger a timer.

[0084] Step A2, regularly check whether new tasks of the virtual machine are obtained; if no new tasks of the virtual machine are obtained when the timer does not reach the current polling time threshold, enter a low power consumption state; if new tasks of the virtual machine are obtained, resume the operation of the virtual machine and execute the step of determining the current resumption time.

[0085] Step A3: If no new task of the virtual machine is obtained when the timer reaches the current polling time threshold, the virtual machine exit action is executed and a new task of the virtual machine is waited for. When a new task of the virtual machine is obtained, the step of determining the current recovery duration is executed.

[0086] In this embodiment, after receiving the current pause instruction of the virtual machine, the system enters the Halt Polling mode, in which case the vCPU of the virtual machine is not released and the system enters a low power consumption state.

[0087] Specifically, after receiving the current pause instruction of the virtual machine, a timer is triggered, which is used to determine whether the timing has reached the current polling time threshold. If the timer has not reached the current polling time threshold, a polling method is used to periodically check whether a new task for the virtual machine has been obtained, for example, by polling to check whether an interrupt event indicating that the virtual machine has triggered a new task has been obtained. If no new task for the virtual machine has been obtained, an instruction for entering a low-power state, such as a rep nop instruction (a low-power pause instruction), is executed to control the vCPU corresponding to the virtual machine to enter a low-power state, and polling is continued.

[0088] If the timer has not reached the current polling time threshold and a new task for the virtual machine is obtained, that is, a new task for the virtual machine is obtained within the polling time, the virtual machine is directly resumed without executing vm_exit. Then, step S302 is continued.

[0089] Conversely, if no new tasks are obtained for the virtual machine before the timer reaches the current polling time threshold, that is, if no new tasks are obtained for the virtual machine within the polling time, the virtual machine exit action (vm_exit) is executed, which releases the vCPU corresponding to the virtual machine; the virtual machine monitor continues to wait for new tasks for the virtual machine. If the virtual machine monitor obtains a new task after the polling time, it needs to execute the virtual machine entry action (vm_entry) and reallocate the vCPU to the virtual machine. Furthermore, step S302 is also continued to determine the current recovery duration.

[0090] Step S302: After receiving the current pause instruction, if a new task of the virtual machine is acquired, the current resume duration corresponding to the current pause instruction is determined based on the time between receiving the current pause instruction and acquiring the new task. If the time between receiving the current pause instruction and acquiring the new task exceeds a preset maximum polling time, the current resume duration is set to a calibration value. The calibration value is less than the minimum value of the historical resume durations within a preset historical time period.

[0091] For details, please see Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.

[0092] Optionally, the above-mentioned step S302 "after receiving the current pause instruction, in the case of obtaining a new task for the virtual machine, determine the current recovery duration corresponding to the current pause instruction based on the time from receiving the current pause instruction to obtaining the new task" specifically includes: after receiving the current pause instruction, if a new task for the virtual machine is obtained within the preset maximum polling time, the time from receiving the current pause instruction to obtaining the new task will be used as the current recovery duration corresponding to the current pause instruction.

[0093] In this embodiment, a maximum polling time, max_halt_poll, is pre-set. After receiving the current halt instruction, the virtual machine monitor waits for a new task to resume the virtual machine. If a new task is obtained within the maximum polling time, the duration between receiving the current halt instruction and obtaining the new task is used as the current resumption duration. This setting is simple, does not require complex calculations, and can accurately represent changes in the resumption duration.

[0094] Furthermore, if no new task for the virtual machine is obtained after the maximum polling time max_halt_poll, the current recovery duration can be directly set to a calibration value, such as 0, i.e., current recovery duration = 0. Alternatively, the system can continue to wait for a new task for the virtual machine, and then set the current recovery duration to the calibration value after obtaining a new task. This embodiment is not limited to this.

[0095] Step S303 : determining a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding one-to-one to a plurality of historical pause instructions.

[0096] Specifically, the above step S303 of “determining the change rate of the recovery duration according to the current recovery duration and multiple historical recovery durations corresponding to multiple historical pause instructions” includes step S3031.

[0097] Step S3031, using the current recovery time and the number index of historical recovery times corresponding to multiple historical pause instructions as the coordinates of the first direction, and using the current recovery time and multiple historical recovery times as the coordinates of the second direction, linear fitting is performed on the recovery time to determine the rate of change of the recovery time.

[0098] In this embodiment, for a certain virtual machine, its various pause instructions are triggered one after another, and accordingly, there is a sequence of sequence for each recovery duration. Therefore, based on the sequence of the recovery duration, the number index (index) corresponding to each recovery duration can be determined. The number index is used to indicate which pause instruction the recovery duration corresponds to.

[0099] By using the index of the number of pause instructions as the coordinate in the first direction, such as the horizontal coordinate, and the recovery time itself as the coordinate in the second direction, such as the vertical coordinate, a linear fit can be performed on the recovery time to calculate the change in the recovery time with the number of pause instructions, that is, the rate of change of the recovery time.

[0100] For example, if a linear fit is required based on five recovery durations, in addition to the current recovery duration, the recovery durations corresponding to four historical pause instructions are also required. Following the order of the pause instructions, the frequency indexes of the four historical recovery durations are 1, 2, 3, and 4, respectively, while the frequency index of the current recovery duration is 5. This allows the construction of five two-dimensional arrays: (1, first historical recovery duration), (2, second historical recovery duration), (3, third historical recovery duration), (4, fourth historical recovery duration), and (5, current recovery duration). By performing a linear fit based on these five two-dimensional arrays, the rate of change of the recovery duration can be determined.

[0101] Among them, the recovery time required for linear fitting can be recorded based on a queue (such as a first-in-first-out queue), and the head of the queue is the latest recovery time, that is, the current recovery time; after each update of the polling time threshold, the historical recovery time at the tail of the queue can be discarded, and the current recovery time also becomes a historical recovery time; when the latest recovery time is determined later, the latest recovery time is written to the head of the queue, so that linear fitting can be performed based on multiple recovery times recorded in the queue.

[0102] Optionally, in step S3031, "performing linear fitting on the recovery time to determine the rate of change of the recovery time" may specifically include: according to the weighted least squares method, based on the weight of the current recovery time and the weights of multiple historical recovery times, performing linear fitting on the current recovery time and multiple historical recovery times to determine the rate of change of the recovery time, the weight of the current recovery time is greater than the weight of each historical recovery time, and the weights of multiple historical recovery times increase in chronological order.

[0103] In this embodiment, increasing weights are assigned to each recovery duration in chronological order. Since the current recovery duration is the latest recovery duration, it has the largest weight. For example, the weights of the five recovery durations are weight[] = {0.1, 0.2, 0.3, 0.4, 0.5}, meaning that the weight of the latest current recovery duration is 0.5. It is understood that the specific values ​​of these weights can be determined based on actual conditions.

[0104] Based on multiple recovery time periods with weights, a linear fit is performed on these recovery time periods using the weighted least squares method to calculate the corresponding change rate k. Specifically, the change rate k is: Among them, w represents the weight of the recovery time, x represents the number index corresponding to the recovery time, and y represents the specific value of the recovery time.

[0105] In this embodiment, weights are set for each recovery duration, and the current recovery duration has the largest weight, which can more effectively extract the recent change rate of the recovery duration. The calculated change rate k can more accurately characterize the recent change trend of the recovery duration, which is conducive to more accurate adjustment of the polling time threshold.

[0106] Step S304 , based on the current polling time threshold, adjust the polling time threshold according to the change rate; wherein, if the change rate is a positive value, increase the polling time threshold, and if the change rate is a negative value, decrease the polling time threshold.

[0107] For details, please see Figure 2 Step S204 of the illustrated embodiment will not be described in detail here.

[0108] In some optional embodiments, the adjustment value of the polling time threshold is positively correlated with the rate of change. That is, the greater the rate of change k, the greater the adjustment value of the polling time threshold. The adjustment value of the polling time threshold refers to the degree of change in the polling time threshold, i.e., the adjustment value is the difference between the polling time threshold after adjustment and the polling time threshold before adjustment (i.e., the current polling time threshold).

[0109] Optionally, the above step S304 of “adjusting the polling time threshold according to the change rate based on the current polling time threshold” includes step B1 and step B2.

[0110] Step B1: determining an adjustment value of the polling time threshold according to a preset adjustment step size and the change rate of the polling time threshold.

[0111] Step B2: Based on the current polling time threshold, increase the adjustment value of the polling time threshold to obtain an adjusted polling time threshold.

[0112] In this embodiment, a preset step size for adjusting the polling time threshold, namely, a preset adjustment step size halt_poll_deta_ns, is also preset. This preset adjustment step size halt_poll_deta_ns can be a fixed value. After calculating the rate of change k of the recovery duration, the adjustment value of the polling time threshold can be determined based on the preset adjustment step size halt_poll_deta_ns and the rate of change k. When the rate of change is positive, the adjustment value is also positively correlated with the preset adjustment step size halt_poll_deta_ns.

[0113] The change rate k can be used as an adjustment factor for the preset adjustment step size halt_poll_deta_ns. This means multiplying the change rate k by the preset adjustment step size halt_poll_deta_ns to obtain the adjusted polling time threshold. This adjusted polling time threshold is then added to the current polling time threshold to adjust the polling time threshold, resulting in the adjusted polling time threshold.

[0114] Specifically, halt_poll_ns(old) represents the current polling time threshold, and halt_poll_ns(new) represents the adjusted polling time threshold, then: halt_poll_ns(new)=halt_poll_ns(old)+k×halt_poll_deta_ns.

[0115] In this embodiment, the polling time threshold halt_poll_ns is adjusted by presetting the adjustment step halt_poll_deta_ns, so that the adjustment range of the polling time threshold will not be too large; and the change rate k is used as the adjustment multiplier of the adjustment step halt_poll_deta_ns, so that the polling time threshold halt_poll_ns to be used next time can be adaptively adjusted based on the change rate k, thereby ensuring that the adjusted polling time threshold halt_poll_ns has a higher probability of acquiring a new task within the Polling time, thereby ensuring the success rate of Polling.

[0116] Optionally, the above step S304 “adjusting the polling time threshold according to the change rate based on the current polling time threshold” may further include step B3.

[0117] Step B3: When the current recovery time is the calibrated value and the change rate is zero, the polling time threshold is adjusted to a preset default threshold.

[0118] In this embodiment, if the rate of change k is 0, the polling time threshold halt_poll_ns can remain unchanged, that is, the adjusted value of the polling time threshold is 0. However, if the rate of change k = 0 and the current recovery duration is the calibration value, it indicates that there is a high probability that the duration of the virtual machine's recovery operation has exceeded the maximum polling time max_halt_poll multiple times in a row. In this case, the polling time threshold halt_poll_ns can continue to remain unchanged, but it is easy to occupy processing resources. Therefore, in this embodiment, the polling time threshold halt_poll_ns is adaptively adjusted; that is, only when the current recovery duration is not the calibration value or the rate of change k is not zero, is the adjusted polling time threshold determined based on the above steps B1 and B2.

[0119] If the current recovery duration is the calibrated value and the change rate is zero, the polling time threshold halt_poll_ns is adjusted to the preset default threshold, which can be the initial value or the minimum value of the polling time threshold halt_poll_ns, such as 1000 ns, etc., to avoid the problem of occupying too much processing resources due to the large polling time threshold halt_poll_ns and affecting the resource utilization rate.

[0120] Figure 4 A detailed flowchart of the control method of the virtual machine is shown, as Figure 4 shown, the method includes the following steps.

[0121] Step S401, initialize max_halt_poll, halt_poll_ns, halt_poll_deta_ns, weight, and queue Queue.

[0122] Among them, halt_poll_ns represents the polling time threshold, max_halt_poll represents the maximum polling time, and halt_poll_deta_ns represents the preset adjustment step size.

[0123] Step S402, KVM obtains the pause instruction.

[0124] Step S403, whether to enter Halt Polling; if so, continue to step S404, otherwise continue to step S408.

[0125] In some cases, it is not allowed to perform pause polling processing on the virtual machine. In this case, it will not enter Halt Polling, that is, directly execute vm_exit. For this situation, the corresponding recovery duration of this pause instruction may not be calculated. That is, only the situation where it resumes after entering Halt Polling needs to calculate the recovery duration. Of course, the recovery duration of this pause instruction can also be calculated and updated to the queue Queue for linear fitting. This embodiment does not limit this.

[0126] Step S404, record the polling start time start, and calculate the polling end time stop. It can be understood that stop = start + halt_poll_ns. This polling start time start is also the time when the pause instruction is received. [[ID=2,6]]

[0127] Step S405, whether the current time is less than stop. That is, judge whether the current time exceeds the polling time threshold halt_poll_ns; if the current time < stop, continue to step S406, otherwise continue to step S408.

[0128] Step S406: Execute a low power instruction. The low power instruction is used to control the corresponding vCPU to enter a low power state.

[0129] Step S407: Whether the virtual machine resumes execution, that is, whether a new task of the virtual machine is received, if so, proceed to step S410, otherwise, re-execute step S405.

[0130] Step S408: Execute vm_exit, i.e., execute the virtual machine exit action, which releases the vCPU for use by other virtual machines, and then proceeds to step S409.

[0131] Step S409: Check whether the virtual machine has resumed execution. This is similar to step S407 and will not be repeated here. If the virtual machine has resumed execution, the process proceeds to step S410; otherwise, the process waits, for example, repeating step S409.

[0132] Step S410: Use the current time - start as WaitedTime.

[0133] Among them, WaitedTime represents the recovery time, that is, WaitedTime = current time - start. It can be understood that the "current time" here is the time when the virtual machine resumes execution, which is also the time when the new task is received.

[0134] Step S411: Check whether the WaitedTime is greater than max_halt_poll. If so, proceed to step S412; otherwise, proceed to step S413.

[0135] Step S412: WaitedTime is set to 0. This is conducive to making the polling time threshold halt_poll_ns enter a downward trend.

[0136] Step S413: Add the WaitedTime to the head of the queue. At this time, the oldest data in the queue will also be removed.

[0137] Step S414: Calculate the change rate k of the recovery time based on the multiple data in the queue Queue.

[0138] Specifically, linear fitting is performed based on the weighted least squares method to determine the change rate k of the recovery time.

[0139] Step S415: Update halt_poll_ns.

[0140] Wherein, halt_poll_ns=halt_poll_ns+k×halt_poll_deta_ns, that is, halt_poll_ns+k×halt_poll_deta_ns is used as the updated polling time threshold halt_poll_ns.

[0141] After that, this process ends. When a new pause instruction of the virtual machine is obtained again, step S402 is continued.

[0142] The control method for the virtual machine provided in this embodiment is that the polling time threshold after adjustment is closer to the polling time threshold before adjustment, which effectively improves the success rate of Polling while ensuring resource utilization, and can receive new tasks of the virtual machine within the Polling time, reducing the overhead caused by the frequent switching of the virtual machine due to the execution of vm_exit and vm_entry. By using the number index of the recovery time for linear fitting, the rate of change of the recovery time can be determined simply and conveniently; by setting appropriate weights for each recovery time, the calculated rate of change k can more accurately characterize the recent change trend of the recovery time, which is conducive to more accurate adjustment of the polling time threshold. This embodiment can improve the computing performance of virtualized virtual machines and the density of virtual machines that can run on a single server, thereby improving the experience and performance of virtual machines, reducing costs, and significantly improving the competitiveness of products.

[0143] This embodiment also provides a virtual machine control device for implementing the above-mentioned embodiments and preferred implementations. Details already described will not be repeated. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.

[0144] This embodiment provides a control device for a virtual machine, such as Figure 5 Shown, including:

[0145] The instruction receiving module 501 is used to receive the current pause instruction of the virtual machine and check whether a new task of the virtual machine is obtained according to the current polling time threshold;

[0146] The duration determination module 502 is configured to, after receiving the current pause instruction and, in the case of acquiring a new task for the virtual machine, determine a current resume duration corresponding to the current pause instruction based on the duration between receiving the current pause instruction and acquiring the new task; wherein, if the duration between receiving the current pause instruction and acquiring the new task exceeds a preset maximum polling time, set the current resume duration to a calibration value, the calibration value being less than a minimum value of historical resume durations within a preset historical time period;

[0147] A processing module 503 is configured to determine a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding to a plurality of historical pause instructions;

[0148] The adjustment module 504 is configured to adjust the polling time threshold based on the current polling time threshold according to the change rate; if the change rate is positive, the polling time threshold is increased; and if the change rate is negative, the polling time threshold is decreased.

[0149] In some optional implementations, after receiving the current pause instruction, the duration determination module 502, when acquiring a new task of the virtual machine, determines the current resume duration corresponding to the current pause instruction based on the duration between receiving the current pause instruction and acquiring the new task, including:

[0150] After receiving the current pause instruction, if a new task of the virtual machine is obtained within the preset maximum polling time, the duration from receiving the current pause instruction to obtaining the new task is used as the current resume duration corresponding to the current pause instruction.

[0151] In some optional implementations, the processing module 503 determines the change rate of the recovery duration based on the current recovery duration and multiple historical recovery durations corresponding to multiple historical pause instructions, including:

[0152] The current recovery time and the number index of the historical recovery time corresponding to the multiple historical pause instructions are used as the coordinates of the first direction, and the current recovery time and the multiple historical recovery time are used as the coordinates of the second direction. The recovery time is linearly fitted to determine the rate of change of the recovery time.

[0153] In some optional implementations, the processing module 503 performs linear fitting on the recovery time to determine the rate of change of the recovery time, including:

[0154] According to the weighted least squares method, based on the weight of the current recovery time and the weights of the multiple historical recovery times, the current recovery time and the multiple historical recovery times are linearly fitted to determine the rate of change of the recovery time. The weight of the current recovery time is greater than the weight of each of the historical recovery times, and the weights of the multiple historical recovery times increase in chronological order.

[0155] In some optional implementations, the adjustment value of the polling time threshold is positively correlated with the change rate.

[0156] In some optional implementations, the adjusting module 504 adjusts the polling time threshold based on the current polling time threshold and according to the change rate, including:

[0157] The adjusted value of the polling time threshold is determined according to the preset adjustment step size and the change rate of the polling time threshold; and the adjusted value of the polling time threshold is added to the current polling time threshold to obtain the adjusted polling time threshold.

[0158] In some optional implementations, the adjusting module 504 adjusts the polling time threshold based on the current polling time threshold and according to the change rate, including:

[0159] When the current recovery duration is a calibrated value and the change rate is zero, the polling time threshold is adjusted to a preset default threshold.

[0160] In some optional implementations, the instruction receiving module 501 checks whether a new task of the virtual machine is obtained according to the current polling time threshold, including:

[0161] Trigger the timer;

[0162] Regularly checking whether a new task of the virtual machine is obtained; if the timer does not reach the current polling time threshold, if no new task of the virtual machine is obtained, entering a low power consumption state; if a new task of the virtual machine is obtained, resuming the operation of the virtual machine and executing the step of determining the current resumption duration;

[0163] If no new task of the virtual machine is obtained when the timer reaches the current polling time threshold, the virtual machine exit action is executed and the new task of the virtual machine is waited for until the new task of the virtual machine is obtained, and the step of determining the current recovery duration is executed.

[0164] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0165] The control device of the virtual machine in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0166] The embodiment of the present invention also provides a computer device having the above Figure 5 A control device of a virtual machine is shown.

[0167] See also Figure 6 , Figure 6 is a structural diagram of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of a GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.

[0168] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.

[0169] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0170] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0171] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.

[0172] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0173] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.

[0174] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.

[0175] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations should all be included in the scope of protection of the present invention.

Claims

1. A method for controlling a virtual machine, characterized in that: The method comprises: Receive a current pause instruction of the virtual machine, and check whether a new task of the virtual machine is obtained according to a current polling time threshold; After receiving the current pause instruction, in the case of obtaining a new task for the virtual machine, determining a current resume duration corresponding to the current pause instruction based on a time duration between receiving the current pause instruction and obtaining the new task; wherein, if the time duration between receiving the current pause instruction and obtaining the new task exceeds a preset maximum polling time, setting the current resume duration to a calibration value, the calibration value being less than a minimum value of historical resume durations within a preset historical time period; Determining a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding to the plurality of historical pause instructions; Based on the current polling time threshold, the polling time threshold is adjusted according to the change rate; wherein, when the change rate is a positive value, the polling time threshold is increased, and when the change rate is a negative value, the polling time threshold is decreased.

2. The method according to claim 1, characterized in that After receiving the current pause instruction, in a case where a new task of the virtual machine is acquired, determining a current resume duration corresponding to the current pause instruction based on a time duration between receiving the current pause instruction and acquiring the new task includes: After receiving the current pause instruction, if a new task of the virtual machine is obtained within the preset maximum polling time, the duration from receiving the current pause instruction to obtaining the new task is used as the current resume duration corresponding to the current pause instruction.

3. The method according to claim 1, characterized in that The determining the change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding to a plurality of historical pause instructions includes: The current recovery time and the number index of the historical recovery time corresponding to the multiple historical pause instructions are used as the coordinates of the first direction, and the current recovery time and the multiple historical recovery time are used as the coordinates of the second direction. The recovery time is linearly fitted to determine the rate of change of the recovery time.

4. The method according to claim 3, characterized in that The linear fitting of the recovery time to determine the rate of change of the recovery time includes: According to the weighted least squares method, based on the weight of the current recovery time and the weights of the multiple historical recovery times, the current recovery time and the multiple historical recovery times are linearly fitted to determine the rate of change of the recovery time. The weight of the current recovery time is greater than the weight of each of the historical recovery times, and the weights of the multiple historical recovery times increase in chronological order.

5. The method according to claim 1, characterized in that The adjustment value of the polling time threshold is positively correlated with the change rate.

6. The method according to claim 5, characterized in that The step of adjusting the polling time threshold based on the current polling time threshold and according to the change rate includes: Determining an adjustment value of the polling time threshold according to a preset adjustment step size of the polling time threshold and the change rate; On the basis of the current polling time threshold, the adjustment value of the polling time threshold is increased to obtain the adjusted polling time threshold.

7. The method according to any one of claims 1 to 5, characterized in that The step of adjusting the polling time threshold based on the current polling time threshold and according to the change rate includes: When the current recovery duration is a calibrated value and the change rate is zero, the polling time threshold is adjusted to a preset default threshold.

8. The method according to claim 1, characterized in that The checking whether a new task of the virtual machine is obtained according to the current polling time threshold includes: Trigger the timer; Regularly checking whether a new task of the virtual machine is obtained; if the timer does not reach the current polling time threshold, if no new task of the virtual machine is obtained, entering a low power consumption state; if a new task of the virtual machine is obtained, resuming the operation of the virtual machine and executing the step of determining the current resumption duration; If no new task of the virtual machine is obtained when the timer reaches the current polling time threshold, the virtual machine exit action is executed and the new task of the virtual machine is waited for until the new task of the virtual machine is obtained, and the step of determining the current recovery duration is executed.

9. A virtual machine control device, characterized in that: The device comprises: An instruction receiving module is used to receive the current pause instruction of the virtual machine and check whether a new task of the virtual machine is obtained according to the current polling time threshold; a duration determination module, configured to, after receiving the current pause instruction and, in the case of acquiring a new task for the virtual machine, determine a current resume duration corresponding to the current pause instruction based on a duration between receiving the current pause instruction and acquiring the new task; wherein, if the duration between receiving the current pause instruction and acquiring the new task exceeds a preset maximum polling time, setting the current resume duration to a calibration value, the calibration value being less than a minimum value of historical resume durations within a preset historical time period; a processing module, configured to determine a change rate of the recovery duration according to the current recovery duration and a plurality of historical recovery durations corresponding one-to-one to a plurality of historical pause instructions; The adjustment module is used to adjust the polling time threshold based on the current polling time threshold according to the change rate; wherein, when the change rate is a positive value, the polling time threshold is increased, and when the change rate is a negative value, the polling time threshold is decreased.

10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the control method of the virtual machine according to any one of claims 1 to 8 by executing the computer instructions.

11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the virtual machine control method according to any one of claims 1 to 8.