Virtual machine memory thermal transformation and distribution method, device and equipment, medium and program product
By obtaining resource information of virtual machines, physical machines and memory pools, determining the allocation reference data, and efficient allocation of virtual machine memory is solved, and the business bumps and low resource utilization caused by virtual machine migration in traditional technology are solved, and the utilization rate of memory resources is improved.
Patent Information
- Application Number
- CN202510348284.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-27
AI Technical Summary
When the local memory resources of the physical machine are insufficient, the traditional virtual machine is affected by virtual machine migration, causing business turbulence, resulting in low memory resource utilization and serious resource waste.
By obtaining the current demand resources of the target virtual machine, the current allocable resources of the physical machine, and the current allocable resources of the memory pool, if the demand resources do not exceed the total allocable resources, determine the allocation reference data, and obtain the allocable resources from the physical machine or memory pool to allocate them to the target virtual machine.
It realizes efficient allocation of virtual machine memory without interrupting business, improves the utilization rate of physical machine memory resources, and avoids resource waste.
Smart Images

Figure CN120216191A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and in particular, to a method, apparatus, device, medium, and program product for hot reallocation of virtual machine memory. Background Art
[0002] With the development of cloud computing technology, virtualization technology has become the core means to achieve flexible resource allocation. Users can obtain computing resources on demand by dynamically creating virtual machines. However, in traditional technologies, resource allocation for virtual machines usually relies on the local resources of physical machines.
[0003] However, when the local memory resources of a physical machine are insufficient, it is usually necessary to perform virtual machine migration to achieve resource expansion. However, virtual machine migration under high load is likely to cause service jitter, and the traditional virtual machine resource allocation mode is likely to cause a large amount of unallocated memory resources to remain in the physical machine, with low utilization rate and resulting in resource waste, which urgently needs to be solved. Summary of the Invention
[0004] Based on this, in order to solve the above technical problems, it is necessary to provide a method, apparatus, device, medium, and program product for hot reallocation of virtual machine memory. On the one hand, it can allocate memory for virtual machines more efficiently to avoid service state jitter on virtual machines; on the other hand, it can improve the utilization rate of physical machine memory resources.
[0005] In a first aspect, this application provides a method for hot reallocation of virtual machine memory, including:
[0006] Obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0007] If the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0008] Obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, according to the allocation reference data, and allocate the resources to be allocated to the target virtual machine.
[0009] In one embodiment, determining the allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine includes:
[0010] Determine the target resources of the target virtual machine according to the current required resources and the current shared resources of the target virtual machine; and
[0011] Determine the resource allocation ratio corresponding to the physical machine according to the currently allocable resources of the physical machine;
[0012] Determine the allocation reference data according to the resource allocation ratio and the target resources.
[0013] In one embodiment, the currently allocable resources include the currently allocable memory resources and the currently allocable Central Processing Unit (CPU) resources of the physical machine; correspondingly, determining the resource allocation ratio corresponding to the physical machine according to the currently allocable resources of the physical machine includes:
[0014] Use the ratio of the currently allocable memory resources of the physical machine to the currently allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine.
[0015] In one embodiment, the currently demanded resources include the currently demanded CPU resources; the currently shared resources include the currently shared CPU resources; the target resources include the target CPU resources; correspondingly, determining the target resources of the target virtual machine according to the currently demanded resources and the currently shared resources of the target virtual machine includes:
[0016] Use the sum of the currently demanded CPU resources and the currently shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine.
[0017] In one embodiment, the currently demanded resources include the currently demanded memory resources; the target resources include the target memory resources; correspondingly, determining the allocation reference data according to the resource allocation ratio and the target resources includes:
[0018] Use the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine;
[0019] Determine the allocation reference data according to the target allocable memory resources and the currently demanded memory resources of the target virtual machine.
[0020] In one embodiment, according to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine, including:
[0021] In the case where the allocation reference data indicates that the target allocable memory resources of the physical machine exceed the target memory resources, allocate memory resources for the target virtual machine based on the physical machine; wherein, the allocated memory resources are the currently demanded memory resources;
[0022] When the target allocable memory resources of the physical machine represented by the allocated reference data do not exceed the target memory resources, resources are allocated to the target virtual machine based on the physical machine and the memory pool; wherein, the memory resources allocated to the physical machine are the target allocable memory resources; the memory resources allocated to the memory pool are the difference between the current required memory resources and the target allocable memory resources.
[0023] In a second aspect, the present application further provides a virtual machine memory hot reallocation device, including:
[0024] An acquisition module, configured to acquire the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0025] A determination module, configured to, if the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0026] An allocation module, configured to acquire the resources to be allocated from the physical machine, or from the physical machine and the memory pool according to the allocation reference data, and allocate the resources to be allocated to the target virtual machine.
[0027] In a third aspect, the present application further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0028] Acquire the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0029] If the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0030] According to the allocation reference data, acquire the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0031] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0032] Acquire the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0033] If the current required resources do not exceed the sum of the currently allocable resources of the physical machine and the currently allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the currently allocable resources of the physical machine;
[0034] According to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0035] In a fifth aspect, the present application further provides a computer program product, including a computer program, which when executed by a processor implements the following steps:
[0036] Obtain the current required resources of the target virtual machine, the currently allocable resources of the physical machine where the target virtual machine is located, and the currently allocable resources of the memory pool corresponding to the physical machine;
[0037] If the current required resources do not exceed the sum of the currently allocable resources of the physical machine and the currently allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the currently allocable resources of the physical machine;
[0038] According to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0039] In the above virtual machine memory hot reallocation method, device, equipment, medium, and program product, in the case where the target virtual machine has a resource allocation requirement, by obtaining the current required resources of the target virtual machine, the currently allocable resources of the physical machine where the target virtual machine is located, and the currently allocable resources of the memory pool corresponding to the physical machine; and when the current required resources do not exceed the sum of the currently allocable resources of the physical machine and the currently allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the currently allocable resources of the physical machine; according to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine. In the above process, since a memory pool is configured for the physical machine, it is possible to allocate resources for the target virtual machine in combination with the memory pool, and thus it is possible to allocate memory for the target virtual machine more efficiently. Also, since in the scenario of allocating resources in combination with the physical machine and the memory pool, allocation reference data is determined according to the current required resources, the current shared resources of the target virtual machine, and the currently allocable resources of the physical machine, the allocation reference data can make the resource allocation more reasonable, and thus can improve the utilization rate of the physical machine memory resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] To more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the accompanying drawings required for the description of the embodiments of the present application or the related art. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0041] Figure 1 It is a schematic flow chart of the virtual machine memory hot reallocation method in an embodiment;
[0042] Figure 2 It is a schematic flow chart of the allocation reference data determination step in an embodiment;
[0043] Figure 3 It is a schematic flow chart of the allocation reference data determination step in another embodiment;
[0044] Figure 4 It is a schematic flow chart of the virtual machine memory hot reallocation method in another embodiment;
[0045] Figure 5 It is a structural block diagram of the virtual machine memory hot reallocation device in an embodiment;
[0046] Figure 6 It is an internal structure diagram of a computer device in an embodiment. Specific embodiments
[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the following further details the present application in combination with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] Before introducing the embodiments of the present application, it should be noted that virtualization technology is one of the core technologies of cloud computing. The server virtualized on the physical machine is called a virtual machine (Virtual Machine, VM), and users can obtain a virtual machine that meets their own configuration according to their own usage needs.
[0049] Hot reallocation generally refers to the process of dynamically allocating or adjusting resources for a virtual machine without interrupting services. This includes the dynamic allocation of CPU, memory, storage, and network resources.
[0050] In the cloud computing scenario, with the rapid improvement of processor performance, the bandwidth performance and capacity growth of the memory of a single physical machine have not kept up, resulting in memory becoming a bottleneck restricting computing performance. The resources that can be utilized for traditional virtual machine memory hot reallocation are the resources on the physical machine where the virtual machine is located. If the resources of the current physical machine are insufficient to support the reallocation requirements of the virtual machine, the virtual machine needs to be migrated to a physical machine that meets the resource requirements. However, in the case of high virtual machine load, hot migration will cause the business state on the virtual machine to jitter. In addition, memory is a key driver of performance and cost. Since the computing resource allocation range of the virtual machine is the physical machine resources, when all the cores of the server are leased (i.e., the virtual machines allocated to users) but the unallocated memory capacity still exists and cannot be leased, a large amount of memory resources are not fully utilized, and memory retention occurs in this case.
[0051] As an emerging interconnection technology, Compute Express Link (CXL) supports memory pooling, provides a way to expand the memory of a physical machine, thereby improving the capacity and bandwidth of the memory that a single physical machine can support, and can improve the utilization rate through memory pooling. CXL 2.0 introduces the concept of Multiple Logical Devices (MLD), allowing the resources of a single CXL memory device to be divided into multiple logical devices and allocated to different physical machines. Multiple physical machines can use the same CXL memory pool, and the CXL protocol allows the CXL memory to be dynamically mounted / unmounted to the physical machine at runtime. Virtualization software and the Linux kernel support the dynamic mounting / unmounting of physical machine memory by virtual machines.
[0052] In one embodiment, as Figure 1 shown, a method for hot reallocation of virtual machine memory is provided. In this embodiment, this method is exemplified by being applied to a terminal. It can be understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0053] S110, obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine.
[0054] Among them, the target virtual machine can be a virtual machine with current resource allocation requirements. The current required resources of the target virtual machine can include at least one of the current required CPU resources or the current required memory resources. The physical machine where the target virtual machine is located, that is, the current allocable resources of the host machine of the target virtual machine, can include at least one of the current allocable CPU resources or the current allocable memory resources. Correspondingly, the current allocable resources of the memory pool corresponding to the physical machine can also include at least one of the current allocable CPU resources or the current allocable memory resources.
[0055] It can be understood that the current required resources of the target virtual machine can be the difference between the target resources and the current shared resources. Among them, the target resources are used to represent the resources required by the target virtual machine in the current service processing scenario; the target resources can include at least one of the target CPU resources or the target memory resources. The current shared resources can include at least one of the current shared CPU resources or the current shared memory resources.
[0056] Based on this, in this embodiment, the current shared resources of the target virtual machine can be obtained, and the target resources of the target virtual machine, and the difference between the target resources and the current shared resources is used as the current required resources of the target virtual machine.
[0057] It can be understood that the current allocable resources are the difference between the initial resources and the allocated resources. Based on this, in this embodiment, the initial resources of the physical machine and the allocated resources of the physical machine can be obtained, and the difference between the initial resources and the allocated resources is used as the current allocable resources of the physical machine. Similarly, the initial resources of the memory pool and the allocated resources of the memory pool are obtained, and the difference between the initial resources and the allocated resources is used as the current allocable resources of the memory pool.
[0058] S120, if the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, then determine the allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine.
[0059] Among them, the allocation reference data is used to indicate how to perform resource allocation.
[0060] Exemplarily, in the case where the current required resources include the current required CPU resources, the current allocable resources of the physical machine include the current allocable CPU resources, and the current allocable resources of the memory pool include the current allocable CPU resources, the sum of the current allocable CPU resources of the physical machine and the current allocable CPU resources of the memory pool can be determined, and the size relationship between the sum and the current required CPU resources is judged. In the case where the sum is greater than the current required CPU resources, it is determined that resource allocation can be performed for the target virtual machine; otherwise, it is determined that resource allocation cannot be performed for the target virtual machine.
[0061] Exemplarily, when the current required resources include current required memory resources, the current allocable resources of the physical machine include current allocable memory resources, and the current allocable resources of the memory pool include current allocable memory resources, the sum value of the current allocable memory resources of the physical machine and the current allocable memory resources of the memory pool can be determined, and the magnitude relationship between the sum value and the current required memory resources can be judged. When the sum value is greater than the current required memory resources, it is determined that resources can be allocated to the target virtual machine; otherwise, it is determined that resources cannot be allocated to the target virtual machine.
[0062] Exemplarily, the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine can be input into a pre-trained allocation reference data determination model to obtain allocation reference data.
[0063] S130. According to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0064] Among them, the resources to be allocated can be resources that can be allocated to the target virtual machine.
[0065] Optionally, if the allocation reference data includes information indicating how many resources the physical machine can allocate to the target virtual machine, then based on the allocation reference data, obtain the resources to be allocated from the physical machine and allocate the resources to be allocated to the target virtual machine.
[0066] Optionally, if the allocation reference data includes both information indicating how many resources the physical machine can allocate to the target virtual machine and information indicating how many resources the memory pool can allocate to the target virtual machine, then based on the allocation reference data, obtain the resources to be allocated from the physical machine and the memory pool respectively, and allocate the resources to be allocated to the target virtual machine.
[0067] In the above virtual machine memory hot reallocation method, when there is a resource allocation requirement for the target virtual machine, the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine are obtained; and when the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, allocation reference data is determined according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine; according to the allocation reference data, the resources to be allocated are obtained from the physical machine, or from the physical machine and the memory pool, and the resources to be allocated are allocated to the target virtual machine. In the above process, since a memory pool is configured for the physical machine, the memory pool can be combined to allocate resources for the target virtual machine, and thus the memory can be allocated to the target virtual machine more efficiently. Also, since in the scenario of allocating resources by combining the physical machine and the memory pool, the allocation reference data is determined according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine, the allocation reference data can make the resource allocation more reasonable, and thus the utilization rate of the physical machine memory resources can be improved.
[0068] Based on the technical solutions of the above embodiments, the present application also provides an alternative embodiment. In this alternative embodiment, the process of determining the allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine is refined.
[0069] See Figure 2 The steps for determining the allocation reference data shown include:
[0070] S210, determine the target resources of the target virtual machine according to the current required resources and the current shared resources of the target virtual machine.
[0071] Among them, the current required resources include the current required CPU resources; the current shared resources include the current shared CPU resources; the target resources include the target CPU resources.
[0072] Specifically, in this embodiment, the sum of the current required CPU resources and the current shared CPU resources of the target virtual machine can be used as the target CPU resources of the target virtual machine.
[0073] S220, determine the resource allocation ratio corresponding to the physical machine according to the current allocable resources of the physical machine.
[0074] Among them, the resource allocation ratio is used to guide the physical machine to allocate resources.
[0075] In an alternative implementation manner, the current allocable resources of the physical machine can be input into a pre-trained resource allocation ratio determination model to obtain the resource allocation ratio corresponding to the physical machine.
[0076] In another alternative embodiment, the currently allocable resources include currently allocable memory resources and currently allocable CPU resources. Correspondingly, the ratio of the currently allocable memory resources of the physical machine to the currently allocable CPU resources of the physical machine can be used as the resource allocation ratio corresponding to the physical machine.
[0077] S230. Determine allocation reference data according to the resource allocation ratio and the target resources.
[0078] Exemplarily, the resource allocation ratio and the target resources can be input into a pre-trained allocation reference data determination model to obtain the allocation reference data.
[0079] Exemplarily, an allocation reference data determination formula can also be determined in advance, and the resource allocation ratio and the target resources are substituted into the allocation reference data determination formula to obtain the allocation reference data.
[0080] In the above embodiments, a specific method for determining the allocation reference data is given. In the process of determining the allocation reference data, considering the target resources of the target virtual machine and the resource allocation ratio corresponding to the physical machine can make the determined allocation reference data more reasonable in the scenario of instructing the physical machine to perform resource allocation, thereby achieving the effect of improving the utilization rate of the physical machine's memory resources.
[0081] Based on the technical solutions of the above embodiments, the present application also provides an alternative embodiment. In this alternative embodiment, the currently required resources include currently required memory resources; the target resources include target memory resources; in this case, the process of determining the allocation reference data according to the resource allocation ratio and the target resources is introduced in detail.
[0082] See Figure 3 The allocation reference data determination steps shown include:
[0083] S310. Use the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine.
[0084] Among them, the target allocable memory resources of the physical machine are used to represent the maximum amount of memory resources that the physical machine can allocate at the current moment.
[0085] S320. Determine the allocation reference data according to the target allocable memory resources and the currently required memory resources of the target virtual machine.
[0086] Exemplarily, in this embodiment, the allocation reference data can be determined according to the size relationship between the target allocable memory resources and the currently required memory resources of the target virtual machine.
[0087] It can be understood that when the target allocable memory resource is not less than the current required memory resource of the target virtual machine, there is no need to use the memory pool to allocate memory for the target virtual machine. Correspondingly, the allocation reference data only includes information indicating how much memory resource the physical machine can allocate for the target virtual machine.
[0088] When the target allocable memory resource is less than the current required memory resource of the target virtual machine, the resources that the physical machine can allocate for the target virtual machine cannot meet the memory usage requirements of the target virtual machine. Therefore, it is necessary to use the memory pool to allocate memory for the target virtual machine. Correspondingly, the allocation reference data not only includes information indicating how much memory resource the physical machine can allocate for the target virtual machine, but also includes information indicating how much memory resource the memory pool can allocate for the target virtual machine.
[0089] In the above embodiments, a detailed process for determining the allocation reference data according to the resource allocation ratio and the target resource is given, making the determination of the allocation reference data clearer and more rigorous.
[0090] Furthermore, when the allocation reference data indicates that the target allocable memory resource of the physical machine exceeds the target memory resource, the physical machine allocates memory resources for the target virtual machine; wherein, the allocated memory resource is the current required memory resource; when the allocation reference data indicates that the target allocable memory resource of the physical machine does not exceed the target memory resource, the physical machine and the memory pool allocate resources for the target virtual machine; wherein, the memory resource allocated by the physical machine is the target allocable memory resource; the memory resource allocated by the memory pool is the difference between the current required memory resource and the target allocable memory resource.
[0091] Based on the technical solutions of the above embodiments, the present application also provides an alternative embodiment. In this alternative embodiment, a virtual machine memory hot reallocation method provided by the present application is introduced in detail.
[0092] See Figure 4 The virtual machine memory hot reallocation method shown in
[0093] S401, obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0094] Wherein, the current required resources include the current required memory resource and the current required CPU resource, and the current required resources are the difference between the target resources and the current shared resources; the current allocable resources include the current allocable memory resource and the current allocable CPU resource, and the current allocable resources are the difference between the initial resources and the current allocated resources;
[0095] S402, Determine whether the currently required CPU resources exceed the currently allocable CPU resources of the physical machine. If so, execute S410; if not, execute S403;
[0096] S403, Determine whether the currently required memory resources exceed the sum of the currently allocable memory resources of the physical machine and the currently allocable memory resources of the memory pool. If so, execute S410; if not, execute S404;
[0097] S404, Use the sum of the currently required CPU resources and the currently shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine; and,
[0098] S405, Use the ratio of the currently allocable memory resources of the physical machine to the currently allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine;
[0099] S406, Multiply the resource allocation ratio by the target CPU resources to obtain the target allocable memory resources of the physical machine;
[0100] S407, Determine the allocation reference data based on the target allocable memory resources and the currently required memory resources of the target virtual machine;
[0101] Exemplarily, when the target allocable memory resources are not less than the currently required memory resources of the target virtual machine, there is no need to allocate memory for the target virtual machine using the memory pool. The determined allocation reference data is: the physical machine allocates memory resources for the target virtual machine, and the allocated memory resources are the currently required memory resources;
[0102] When the target allocable memory resources are less than the currently required memory resources of the target virtual machine, it is necessary to allocate memory for the target virtual machine using the memory pool. The determined allocation reference data is: the physical machine and the memory pool allocate memory resources for the target virtual machine, and the memory resources allocated by the physical machine are the target allocable memory resources; the memory resources allocated by the memory pool are the difference between the currently required memory resources and the target allocable memory resources;
[0103] S408, When the allocation reference data indicates that the target allocable memory resources of the physical machine exceed the target memory resources, allocate memory resources for the target virtual machine based on the physical machine;
[0104] Among them, the memory resources allocated by the physical machine are the currently required memory resources;
[0105] S409, When the allocation reference data indicates that the target allocable memory resources of the physical machine do not exceed the target memory resources, allocate resources for the target virtual machine based on the physical machine and the memory pool;
[0106] Among them, the memory resources allocated to the physical machine are the target allocable memory resources; the memory resources allocated to the memory pool are the difference between the current required memory resources and the target allocable memory resources;
[0107] S410, reject the memory allocation for the target virtual machine.
[0108] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.
[0109] Based on the same inventive concept, an embodiment of the present application also provides a virtual machine memory hot reallocation device for implementing the virtual machine memory hot reallocation method described above. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the virtual machine memory hot reallocation device provided below can refer to the limitations on the virtual machine memory hot reallocation method in the above text, and will not be repeated here.
[0110] In an exemplary embodiment, as Figure 5 shown, a virtual machine memory hot reallocation device is provided, including: an acquisition module 510, a determination module 520, and an allocation module 530, where:
[0111] The acquisition module 510 is configured to acquire the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0112] The determination module 520 is configured to, if the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0113] The allocation module 530 is configured to acquire the resources to be allocated from the physical machine, or from the physical machine and the memory pool, according to the allocation reference data, and allocate the resources to be allocated to the target virtual machine.
[0114] In one embodiment, the determination module 520 includes a first determination unit configured to determine the target resources of the target virtual machine according to the currently demanded resources and the current shared resources of the target virtual machine; and a second determination unit configured to determine the resource allocation ratio corresponding to the physical machine according to the currently allocable resources of the physical machine; and a third determination unit configured to determine the allocation reference data according to the resource allocation ratio and the target resources.
[0115] In one embodiment, the currently allocable resources include currently allocable memory resources and currently allocable CPU resources; correspondingly, the second determination unit is specifically configured to use the ratio of the currently allocable memory resources of the physical machine to the currently allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine.
[0116] In one embodiment, the currently demanded resources include currently demanded CPU resources; the current shared resources include currently shared CPU resources; the target resources include target CPU resources; correspondingly, the first determination unit is specifically configured to use the sum of the currently demanded CPU resources and the currently shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine.
[0117] In one embodiment, the currently demanded resources include currently demanded memory resources; the target resources include target memory resources; correspondingly, the third determination unit includes a first determination subunit configured to use the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine; and a second determination subunit configured to determine the allocation reference data according to the target allocable memory resources and the currently demanded memory resources of the target virtual machine.
[0118] In one embodiment, the allocation module 530 includes a first allocation unit configured to allocate memory resources for the target virtual machine based on the physical machine in the case where the allocation reference data indicates that the target allocable memory resources of the physical machine exceed the target memory resources; wherein, the allocated memory resources are the currently demanded memory resources; and a second allocation unit configured to allocate resources for the target virtual machine based on the physical machine and the memory pool in the case where the allocation reference data indicates that the target allocable memory resources of the physical machine do not exceed the target memory resources; wherein, the memory resources allocated by the physical machine are the target allocable memory resources; and the memory resources allocated by the memory pool are the difference between the currently demanded memory resources and the target allocable memory resources.
[0119] Each module in the above virtual machine memory hot reallocation device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above respective modules.
[0120] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in Figure 6 . The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a method for hot reconfiguration of virtual machine memory. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse, etc.
[0121] Those skilled in the art can understand that Figure 6 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0122] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:
[0123] Obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0124] If the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0125] Obtain the resources to be allocated from a physical machine or from both a physical machine and a memory pool according to the allocation reference data, and allocate the resources to be allocated to a target virtual machine.
[0126] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0127] Determine the target resources of the target virtual machine according to the current required resources and the current shared resources of the target virtual machine; and,
[0128] Determine the resource allocation ratio corresponding to the physical machine according to the current allocable resources of the physical machine;
[0129] Determine the allocation reference data according to the resource allocation ratio and the target resources.
[0130] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0131] Use the ratio of the current allocable memory resources of the physical machine to the current allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine.
[0132] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0133] Use the sum of the current required CPU resources and the current shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine.
[0134] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0135] Use the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine;
[0136] Determine the allocation reference data according to the target allocable memory resources and the current required memory resources of the target virtual machine.
[0137] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0138] In the case where the allocation reference data indicates that the target allocable memory resources of the physical machine exceed the target memory resources, allocate memory resources for the target virtual machine based on the physical machine; wherein, the allocated memory resources are the current required memory resources;
[0139] In the case where the allocation reference data indicates that the target allocable memory resources of the physical machine do not exceed the target memory resources, allocate resources for the target virtual machine based on the physical machine and the memory pool; wherein, the memory resources allocated by the physical machine are the target allocable memory resources; the memory resources allocated by the memory pool are the difference between the current required memory resources and the target allocable memory resources.
[0140] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0141] Obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0142] If the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0143] According to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0144] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0145] Determine the target resources of the target virtual machine according to the current required resources and the current shared resources of the target virtual machine; and,
[0146] Determine the resource allocation ratio corresponding to the physical machine according to the current allocable resources of the physical machine;
[0147] Determine the allocation reference data according to the resource allocation ratio and the target resources.
[0148] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0149] Take the ratio of the current allocable memory resources of the physical machine to the current allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine.
[0150] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0151] Take the sum of the current required CPU resources and the current shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine.
[0152] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0153] Take the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine;
[0154] Determine the allocation reference data according to the target allocable memory resources and the current required memory resources of the target virtual machine.
[0155] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0156] When the target allocable memory resources of the physical machine represented by the allocation reference data exceed the target memory resources, allocate memory resources for the target virtual machine based on the physical machine; wherein, the allocated memory resources are the current required memory resources;
[0157] When the target allocable memory resources of the physical machine represented by the allocation reference data do not exceed the target memory resources, allocate resources for the target virtual machine based on the physical machine and the memory pool; wherein, the memory resources allocated by the physical machine are the target allocable memory resources; the memory resources allocated by the memory pool are the difference between the current required memory resources and the target allocable memory resources.
[0158] In one embodiment, a computer program product is provided, including a computer program, which when executed by a processor, implements the following steps:
[0159] Obtain the current required resources of the target virtual machine, the current allocable resources of the physical machine where the target virtual machine is located, and the current allocable resources of the memory pool corresponding to the physical machine;
[0160] If the current required resources do not exceed the sum of the current allocable resources of the physical machine and the current allocable resources of the memory pool, determine the allocation reference data according to the current required resources, the current shared resources of the target virtual machine, and the current allocable resources of the physical machine;
[0161] According to the allocation reference data, obtain the resources to be allocated from the physical machine, or from the physical machine and the memory pool, and allocate the resources to be allocated to the target virtual machine.
[0162] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0163] Determine the target resources of the target virtual machine according to the current required resources and the current shared resources of the target virtual machine; and,
[0164] Determine the resource allocation ratio corresponding to the physical machine according to the current allocable resources of the physical machine;
[0165] Determine the allocation reference data according to the resource allocation ratio and the target resources.
[0166] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0167] Take the ratio of the current allocable memory resources of the physical machine to the current allocable CPU resources of the physical machine as the resource allocation ratio corresponding to the physical machine.
[0168] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0169] Use the sum of the current required CPU resources and the current shared CPU resources of the target virtual machine as the target CPU resources of the target virtual machine.
[0170] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0171] Use the product of the resource allocation ratio and the target CPU resources as the target allocable memory resources of the physical machine;
[0172] Determine allocation reference data based on the target allocable memory resources of the physical machine and the current required memory resources of the target virtual machine.
[0173] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0174] In the case where the allocation reference data indicates that the target allocable memory resources of the physical machine exceed the target memory resources, allocate memory resources for the target virtual machine based on the physical machine; wherein, the allocated memory resources are the current required memory resources;
[0175] In the case where the allocation reference data indicates that the target allocable memory resources of the physical machine do not exceed the target memory resources, allocate resources for the target virtual machine based on the physical machine and the memory pool; wherein, the memory resources allocated by the physical machine are the target allocable memory resources; the memory resources allocated by the memory pool are the difference between the current required memory resources and the target allocable memory resources.
[0176] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, a database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.
[0177] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope recorded in this application.
[0178] The above embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A method for hot-allocation of virtual machine memory, characterized in that: The method comprises: Obtaining currently required resources of the target virtual machine, currently allocatable resources of the physical machine where the target virtual machine is located, and currently allocatable resources of the memory pool corresponding to the physical machine; If the currently required resources do not exceed the sum of the currently allocatable resources of the physical machine and the currently allocatable resources of the memory pool, determining allocation reference data according to the currently required resources, the currently shared resources of the target virtual machine, and the currently allocatable resources of the physical machine; According to the allocation reference data, resources to be allocated are acquired from the physical machine, or from the physical machine and the memory pool, and the resources to be allocated are allocated to the target virtual machine.
2. The method according to claim 1, characterized in that The determining allocation reference data according to the currently required resources, the currently shared resources of the target virtual machine, and the currently allocatable resources of the physical machine includes: Determining target resources of the target virtual machine according to the currently required resources and the currently shared resources of the target virtual machine; and Determining a resource allocation ratio corresponding to the physical machine according to currently allocatable resources of the physical machine; Allocation reference data is determined according to the resource allocation ratio and the target resource.
3. The method according to claim 2, characterized in that The currently allocatable resources include currently allocatable memory resources and currently allocatable central processing unit (CPU) resources; accordingly, determining the resource allocation ratio corresponding to the physical machine according to the currently allocatable resources of the physical machine includes: The ratio of the currently allocatable memory resources of the physical machine to the currently allocatable CPU resources of the physical machine is used as the resource allocation ratio corresponding to the physical machine.
4. The method according to claim 2, characterized in that: The currently required resources include currently required CPU resources; the currently shared resources include currently shared CPU resources; the target resources include target CPU resources; accordingly, determining the target resources of the target virtual machine according to the currently required resources and the currently shared resources of the target virtual machine includes: The sum of the currently required CPU resources and the currently shared CPU resources of the target virtual machine is used as the target CPU resources of the target virtual machine.
5. The method according to claim 4, characterized in that The currently required resources include currently required memory resources; the target resources include target memory resources; accordingly, determining allocation reference data according to the resource allocation ratio and the target resources includes: The product of the resource allocation ratio and the target CPU resource is used as the target allocatable memory resource of the physical machine; Allocation reference data is determined according to the target allocatable memory resources and the current required memory resources of the target virtual machine.
6. The method according to claim 5, characterized in that The step of acquiring the resources to be allocated from the physical machine, or the physical machine and the memory pool, according to the allocation reference data, and allocating the resources to be allocated to the target virtual machine includes: In a case where the allocation reference data indicates that the target allocatable memory resources of the physical machine exceed the target memory resources, allocating memory resources to the target virtual machine based on the physical machine; wherein the allocated memory resources are the currently required memory resources; When the allocation reference data indicates that the target allocatable memory resources of the physical machine do not exceed the target memory resources, resources are allocated to the target virtual machine based on the physical machine and the memory pool; wherein the memory resources allocated to the physical machine are the target allocatable memory resources; and the memory resources allocated to the memory pool are the difference between the currently required memory resources and the target allocatable memory resources.
7. A virtual machine memory hot-allocation device, characterized in that: The device comprises: An acquisition module, used to acquire the current required resources of the target virtual machine, the current allocatable resources of the physical machine where the target virtual machine is located, and the current allocatable resources of the memory pool corresponding to the physical machine; a determination module, configured to determine allocation reference data according to the current demand resources, the current shared resources of the target virtual machine, and the current allocatable resources of the physical machine if the current demand resources do not exceed the sum of the current allocatable resources of the physical machine and the current allocatable resources of the memory pool; An allocation module is used to obtain resources to be allocated from the physical machine, or from the physical machine and the memory pool, according to the allocation reference data, and allocate the resources to be allocated to the target virtual machine.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.