Virtual machine resource management method and device, equipment and storage medium
By recording and comparing the incremental information of the virtual machine hot expansion request, the problem of inaccurate expansion of virtual machine resources in the cloud environment is solved, and resources are accurately managed without affecting the business, improving the accuracy of the expansion process.
Patent Information
- Application Number
- CN202510521935.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-01
AI Technical Summary
In a cloud environment, when the virtual machine CPU or memory specifications do not meet the business requirements, the existing technology cannot increase the CPU or memory online without affecting the business, resulting in inaccurate resource utilization during the hot expansion process, which may lead to failure of expansion.
By obtaining the virtual machine's hot expansion request, record resource increment information, including specification increments and topological increments, compare to determine whether to perform expansion requests, and manage resource updates during the expansion process to ensure the accuracy of resource utilization.
It realizes accurate management of virtual machine resource expansion without affecting the business, avoids the problems of inaccurate resource utilization and failure in expansion, and improves the resource management accuracy of the thermal expansion process.
Smart Images

Figure CN120407082A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual machine management, and particularly to a method, device, equipment and storage medium for virtual machine resource management. Background Art
[0002] In a cloud environment, the specifications of a virtual machine's CPU (Central Processing Unit) or memory may not meet the business requirements, and some industry customers expect to increase the CPU or memory size without affecting the business. Currently, the OpenStack (an open-source cloud computing management platform) community supports the function of changing specifications (resize, the virtual machine resource adjustment function), but it requires shutting down the virtual machine, which will cause business interruption. Since the qemu 2.6.0 (open-source virtual machine monitor and simulator) version, it has supported the hot addition of CPU and memory, but the OpenStack (an open-source project that provides a framework for creating and managing public and private cloud infrastructure) community does not have the function of online increasing the CPU and memory of a virtual machine.
[0003] Since hot expansion is somewhat similar to the resize function in the community in terms of process, in most implementations, the resource management in the resize process is directly reused in the hot expansion process. In this way, during hot expansion, problems such as insufficient resources leading to expansion failure and inaccurate resource occupancy may occur.
[0004] It can be seen that how to ensure the accuracy of each resource during the hot expansion of a virtual machine is a problem to be solved in this field. Summary of the Invention
[0005] The purpose of the embodiments of the present invention is to provide a method, device, equipment and storage medium for virtual machine resource management, which can solve the problem of inaccurate resource occupancy during virtual machine expansion.
[0006] To solve the above technical problems, in a first aspect, the embodiments of the present invention provide a method for virtual machine resource management, including:
[0007] Obtain a hot expansion request for the current resources of a virtual machine, and record the resource increment information corresponding to the hot expansion request; the resource increment information includes the specification increment information and the topology increment information of the resources;
[0008] Compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determine whether to execute the hot expansion request based on the comparison result;
[0009] Manage and update the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information.
[0010] Optionally, recording the resource increment information corresponding to the hot expansion request includes:
[0011] Determining the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the difference between the expanded resources corresponding to the hot expansion request and the current resources;
[0012] Recording the specification increment information and the topology increment information respectively by using the pre-set specification increment attributes and topology increment attributes.
[0013] Optionally, determining the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the difference between the expanded resources corresponding to the hot expansion request and the current resources includes:
[0014] [[ID=I3]]Determining the specification increment information of the resources corresponding to the hot expansion request according to the resource differences between the expanded resource information corresponding to the hot expansion request and the current resources in terms of the number of processors, memory size, and disk size;
[0015] Determining the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources.
[0016] Optionally, determining the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources includes:
[0017] Calculating the specification increment information and the number of topology nodes corresponding to the current resources to determine the node increment information corresponding to each topology node;
[0018] Determining the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node from the target resource information according to the node increment information;
[0019] Determining the topology increment information of the resources corresponding to the hot expansion request based on the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node.
[0020] Optionally, comparing the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information includes:
[0021] Comparing the number of processors, memory size, disk size, and the specification increment information in the target resource information of the remaining resources of the host corresponding to the virtual machine to obtain corresponding first comparison results;
[0022] Compare the number of processors, memory size, disk size of the host node corresponding to each of the topology nodes in the target resource information, and the topology increment information, to obtain corresponding second comparison results; the host node is the topology node of the host, corresponding to fixed resources, and the resources corresponding to the topology node of the virtual machine are a subset of the fixed resources;
[0023] Correspondingly, determining whether to execute the hot expansion request based on the comparison result includes:
[0024] Judge whether the relationship between the remaining resources characterized by the first comparison result and the second comparison result and the target incremental resources corresponding to the resource incremental information satisfies a preset allocation condition; the preset allocation condition indicates that the target incremental resources are a subset of the remaining resources;
[0025] If the relationship between the remaining resources characterized by the first comparison result and / or the second comparison result and the target incremental resources corresponding to the resource incremental information does not satisfy the preset allocation condition, then prohibit the execution of the hot expansion request;
[0026] If both the first comparison result and the second comparison result indicate that the relationship between the remaining resources and the target incremental resources corresponding to the resource incremental information satisfies the preset allocation condition, then allow the execution of the hot expansion request.
[0027] Optionally, managing and updating the remaining resources based on the execution situation of the hot expansion request and in combination with the resource incremental information includes:
[0028] If the hot expansion request is executed successfully or it is not allowed to execute the hot expansion request, then clear the resource incremental information;
[0029] If the execution of the hot expansion request fails, then perform a resource rollback and release operation on the virtual machine based on the resource incremental information.
[0030] Optionally, during the execution of the hot expansion request, it further includes:
[0031] If the hot expansion request represents configuring a processor binding policy, then use the processors corresponding to the corresponding host node that match the specification incremental information to establish a processor binding relationship with the virtual machine, and manage and update the remaining resources according to the processor binding relationship.
[0032] In a second aspect, the present invention provides a virtual machine resource management device, including:
[0033] An incremental recording module, configured to obtain a hot expansion request for the current resources of a virtual machine and record resource increment information corresponding to the hot expansion request; the resource increment information includes specification increment information of resources and topology increment information of resources;
[0034] A resource comparison module, configured to compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determine whether to execute the hot expansion request based on the comparison result;
[0035] A resource management module, configured to manage and update the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information.
[0036] In a third aspect, the present invention provides an electronic device, including:
[0037] A memory, configured to store a computer program;
[0038] A processor, configured to execute the computer program to implement the steps of the virtual machine resource management method as described above.
[0039] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the virtual machine resource management method as described above are implemented.
[0040] It can be seen from the above technical solutions that this application first obtains a hot expansion request for the current resources of a virtual machine and records resource increment information corresponding to the hot expansion request; the resource increment information includes specification increment information of resources and topology increment information of resources; then compares the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determines whether to execute the hot expansion request based on the comparison result; and then manages and updates the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information. In this way, when this application obtains a hot expansion request, it can record the resource increment information of the hot expansion request relative to the current resources of the virtual machine; then, when comparing the resource increment information with the target resource information of the remaining resources of the host and executing the hot expansion request based on the comparison result, it can achieve accurate occupation or release management and update of specification information and topology information according to the resource increment information, and can improve the resource occupation accuracy during the hot expansion process. Description of the Drawings
[0041] To more clearly illustrate the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0042] Figure 1 Flowchart of a virtual machine resource management method disclosed in this application;
[0043] Figure 2 Flowchart of a specific virtual machine resource management method disclosed in this application;
[0044] Figure 3 Schematic diagram of resources before, during, and after expansion disclosed in this application;
[0045] Figure 4 Another schematic diagram of resources before, during, and after expansion disclosed in this application;
[0046] Figure 5 Flowchart of a cloud platform virtual machine resource adjustment method disclosed in this application;
[0047] Figure 6 Schematic diagram of the structure of a virtual machine resource management device disclosed in this application;
[0048] Figure 7 Schematic diagram of the structure of an electronic device disclosed in this application. Detailed implementation manners
[0049] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present invention.
[0050] The terms "including" and "having" in the specification of the present invention and the above drawings, as well as any variations related to "including" and "having", are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.
[0051] To enable those skilled in the art to better understand the solution of the present invention, the following will further elaborate on the present invention in conjunction with the drawings and specific implementation manners.
[0052] As Figure 1 shown, the embodiments of this application disclose a virtual machine resource management method, including:
[0053] Step S11: Obtain a hot expansion request for the current resources of the virtual machine, and record the resource increment information corresponding to the hot expansion request; the resource increment information includes the specification increment information of the resources and the topology increment information of the resources.
[0054] In this application, the hot expansion request for the current resources of the virtual machine is used to indicate that the virtual machine is to be expanded, and there is corresponding resource change information; at this time, the specification increment information of the corresponding resources in the virtual machine specification and the topology increment information in the virtual machine topology relationship can be recorded according to this hot expansion request. It can be understood that the topology information in the virtual machine records the binding relationship between the resource information of the virtual machine and the resource information corresponding to the topology information of the host; for example, the NUMA (Non Uniform Memory Access) topology relationship, where there are a fixed number of processors and memories on each topology node.
[0055] In a specific embodiment, the recording of the resource increment information corresponding to the hot expansion request may include: determining the specification increment information and the topology increment information of the resources corresponding to the hot expansion request according to the difference between the resources after expansion corresponding to the hot expansion request and the current resources; using the pre-set specification increment attribute and topology increment attribute to record the specification increment information and the topology increment information respectively. Specifically, there are resources after expansion corresponding to the hot expansion request, and the corresponding resource increment information can be determined according to the difference between the resources after expansion and the current resources of the virtual machine; it can be understood that the resource increment on the specification of the virtual machine is recorded as the rule increment information, and the resource increment on the topology relationship of the virtual machine is recorded as the topology increment information; moreover, in this application, the rule increment information and the topology increment information can be recorded respectively through the pre-set table attributes, that is, the specification increment attribute and the topology increment attribute, for use in the expansion process.
[0056] In another specific embodiment, determining the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the differences between the expanded resources corresponding to the hot expansion request and the current resources may include: determining the specification increment information of the resources corresponding to the hot expansion request according to the resource differences between the expanded resource information corresponding to the hot expansion request and the current resources in terms of the number of processors, memory size, and disk size; and determining the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources. Specifically, the specification information of a virtual machine may include the number of processors, memory size, and disk size; for a hot expansion request of a virtual machine, there is expanded resource information of the virtual machine, and according to the differences between the expanded resource information and the current resources of the virtual machine, the specification increment information of the resources corresponding to the hot expansion request can be obtained through comparison; further, the topology relationship corresponding to the virtual machine changes with the change of the resource information of the virtual machine, that is, according to the specification increment information of the resources before and after expansion and the number of topology nodes of the virtual machine itself, the topology increment information of the resources of the virtual machine before and after expansion is determined.
[0057] In yet another specific embodiment, determining the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources may include: calculating the specification increment information and the number of topology nodes corresponding to the current resources to determine the node increment information corresponding to each topology node; determining the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node from the target resource information according to each piece of node increment information; and determining the topology increment information of the resources corresponding to the hot expansion request based on the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node. Specifically, the resource increment before and after expansion in a virtual machine can be evenly divided according to the number of topology nodes, so that the node increment information corresponding to each topology node of the virtual machine can be calculated; further, the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to the corresponding topology node can be determined from the target resource information corresponding to the remaining resources of the host according to the node increment information of each node; correspondingly, combining the resource specification information that needs to be added corresponding to the topology node itself, the topology increment information of the corresponding topology node can be obtained. For example, if a virtual machine corresponds to two topology nodes and the number of processor cores before and after expansion increases by 80, then according to the equal division principle, the number of processor cores to be added corresponding to each topology node is 40; combining the remaining resources of the host, the list of processors that need to be added corresponding to each topology node can be further determined.
[0058] Step S12: Compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determine whether to execute the hot expansion request based on the comparison result.
[0059] In this application, when a hot expansion request for a virtual machine is obtained, it is necessary to consider whether the remaining resources of the host are sufficient to support the expansion operation of the virtual machine; the resource increment information corresponding to the hot expansion request can be compared with the target resource information of the remaining resources of the host, and it is determined whether the expansion operation of the virtual machine can be executed according to the corresponding comparison result.
[0060] In a specific embodiment, the comparison between the target resource information of the remaining resources of the host corresponding to the virtual machine and the resource increment information may include: comparing the number of processors, memory size, disk size in the target resource information of the remaining resources of the host corresponding to the virtual machine with the specification increment information to obtain corresponding first comparison results; comparing the number of processors, memory size, disk size of the host nodes corresponding to each topology node in the target resource information with the topology increment information to obtain corresponding second comparison results; the host node is a topology node of the host, corresponding to fixed resources, and the resources corresponding to the topology node of the virtual machine are a subset of the fixed resources; correspondingly, determining whether to execute the hot expansion request based on the comparison results includes: judging whether the relationship between the remaining resources characterized by the first comparison result and the second comparison result and the target increment resources corresponding to the resource increment information meets a preset allocation condition; the preset allocation condition characterizes that the target increment resources are a subset of the remaining resources; if the first comparison result and / or the second comparison result characterizes that the relationship between the remaining resources and the target increment resources corresponding to the resource increment information does not meet the preset allocation condition, the hot expansion request is prohibited from being executed; if both the first comparison result and the second comparison result characterize that the relationship between the remaining resources and the target increment resources corresponding to the resource increment information meets the preset allocation condition, the hot expansion request is allowed to be executed. Specifically, in the process of comparing the remaining resources of the host with the resource increment before and after the expansion of the virtual machine, the comparison involves the number of processors, memory size and disk size, and the first comparison result between resource specifications can be obtained; correspondingly, for the comparison of topology information, the number of processors, memory size and disk size of each topology node corresponding to the virtual machine and the host node are compared, and the comparison result between topology information can be obtained, denoted as the second comparison result. Further, in the process of determining whether to execute the expansion operation of the virtual machine according to the comparison results, both resource specifications and topology information need to be considered, that is, whether both the first comparison result and the second comparison result characterize that the expansion operation of the virtual machine is satisfied; if there is a situation where it is not satisfied, the virtual machine expansion cannot be executed, and corresponding prompt information (such as prompt information indicating insufficient processor resources, etc.) can be triggered; when both comparison results characterize that the preset allocation condition is satisfied, the hot expansion operation of the virtual machine is allowed to be executed.
[0061] Step S13, manage and update the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information.
[0062] In this application, through the above steps, the specification increment information and topology increment information of resources can be combined to determine whether to execute the hot expansion request of the virtual machine; then, based on the execution situation of the hot expansion request, the remaining resources of the host can be managed and updated in combination with the previously recorded resource increment information; through this resource increment information, the resource status can be accurately updated, and it is also convenient to perform resource rollback to release resources.
[0063] In a specific embodiment, the managing and updating of the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information may include: if the hot expansion request is successfully executed or the execution of the hot expansion request is not allowed, the resource increment information is cleared; if the execution of the hot expansion request fails, a resource rollback and release operation is performed on the virtual machine based on the resource increment information. Specifically, after the hot expansion request of the virtual machine is successfully executed or directly not allowed to be executed, the recorded resource increment information is meaningless and the corresponding resource increment information can be directly cleared; correspondingly, if the hot expansion request of the virtual machine fails, at this time, it is necessary to restore the virtual machine to the state before expansion while ensuring accurate resource management; specifically, a resource rollback and release operation can be performed on the virtual machine through the resource increment information to avoid inaccurate resource occupation.
[0064] In another specific embodiment, during the execution of the hot expansion request, it may further include: if the hot expansion request represents a configured processor binding policy, a processor binding relationship is established between the virtual machine and the corresponding processor of the corresponding host node that matches the specification increment information, and the remaining resources are managed and updated according to the processor binding relationship. Specifically, during the execution of the hot expansion request of the virtual machine, the binding relationship between the processor in the host resources and the virtual machine can be constructed in combination with the configured processor binding policy; a processor binding relationship can be established between the virtual machine and the corresponding processor of the host node that matches the specification increment information, and the remaining resources of the host are updated according to the processor binding relationship; it can be understood that the host resources can be accurately updated by combining the specification increment information of the resources before and after the expansion of the virtual machine, and the physical processor of the newly added processor of the virtual machine can be bound to the host according to the processor binding policy on the premise of ensuring accurate resource management.
[0065] It can be seen that when the present application obtains a thermal expansion request, it can record the resource increment information of the thermal expansion request relative to the current resources of the virtual machine; then, based on the comparison between the resource increment information and the target resource information of the remaining resources of the host, and when executing the thermal expansion request based on the comparison result, it can realize the accurate occupation or release management update of the specification information and topology information according to the resource increment information; it realizes the unified management of the resources for thermal expansion, and can avoid problems such as inaccurate resource occupation and host over-allocation after thermal expansion; and the resource management process of this solution can be applied to complex scenarios such as processor expansion or contraction, binding, etc., improving the usability of virtual machine resource adjustment.
[0066] As Figure 2 shown, an embodiment of the present application discloses a virtual machine resource management method, including:
[0067] It should be noted that the migration table is used to record migration records, the migration_context table is used to record the information in the middle process of thermal expansion or migration, the instance_extra table is used to record some additional information during the virtual machine migration process, such as the original specification of the virtual machine, the target specification, etc., and the compute_nodes table is used to record the total amount and usage of host resources. In a specific embodiment, assume that the original specification of the virtual machine vm1 is f1 (4C8G, indicating 4 processors and 8G of memory), the specified target specification for thermal expansion is f2 (6C12G), the resource increment is delta_f (2C4G), the original numa topology of the virtual machine is old_numa, the NUMA topology increment is delta_numa, and the new numa topology of the virtual machine is new_numa. Denote usage_from_instance as the host resources occupied by the virtual machine according to the specification; usage_from_instance_numa as the host NUMA topology resources occupied according to the virtual machine NUMA topology. The resource occupation situations in the stages before, during, and after the expansion are as Figure 3 shown. In another specific embodiment, assume that the number of NUMA nodes in the original NUMA topology of the virtual machine is 2, and old_numa, delta_numa during the expansion process, and the final new_numa of the virtual machine are as Figure 4 shown; among them, for each NUMA node in the virtual machine, it can be denoted as cell, and each node includes a node name (Identity, id), a list of processors corresponding to the node (cpuset), and the corresponding memory (memory).
[0068] It is understandable that when the hot expansion feature of the virtual machine is enabled, the NUMA topology of the virtual machine is regenerated. Taking the example that there are two NUMA nodes in the virtual machine NUMA topology, assuming that the number of CPU cores of the host is 96 and the original number of CPU cores of the virtual machine is 16, according to the principle of equal CPU distribution, the CPUs to be hot-inserted are evenly distributed on two NUMA (node 0 and node 1). That is, the list of CPUs to be hot-inserted on virtual machine NUMA 0 is 16, 18, 20, …, 94; the list of CPUs to be hot-inserted on NUMA 1 is 17, 19, 21, …, 95, denoted as addable_cpu_map = [[16, 18, 20, …, 94], [17, 19, 21, …, 95]], as shown below:
[0069] <numa>
[0070] <cell id="0" cpus="0,2,4,6,8,10,12,14,16,18,20,…94" / >
[0071] <cell id="1" cpus="1,3,5,7,9,11,13,15,17,19,21,…95" / >
[0072] < / numa>
[0073] Further, during the resource management (claim) process of hot expansion, add a delta_flavor attribute to the instance_extra table to record the specification increment information during the hot expansion process; then, based on the specification increment information, detect whether the remaining number of CPUs on the host meets the following conditions: If the number of CPUs in the target specification - the number of CPUs in the source specification > the remaining number of CPUs on the host, return an error indicating insufficient CPU. And based on the specification increment information, it can also be detected whether the remaining memory on the host meets the following conditions: If the memory size in the target specification - the memory size in the source specification > the remaining memory size on the host, return an error indicating insufficient memory. It can also detect whether the remaining disk capacity on the host meets the following conditions: If the disk size in the target specification - the disk size in the source specification > the remaining disk size on the host, return an error indicating insufficient disk capacity. Correspondingly, for the resources on the host NUMA node, further comparison is required; specifically, add a delta_numa_topology attribute to the migration_context table to record the resource increment of the virtual machine NUMA topology during the expansion process; set old_numa_topology as the NUMA topology of the virtual machine before hot expansion, claimed_numa_topology is used to record the target NUMA topology of the virtual machine after expansion, host_topology is the NUMA topology of the host where the virtual machine is located, and delta_numa_topology is used to record the increment of the virtual machine NUMA topology during the hot expansion process. The original numa topology of the virtual machine is old_numa, claimed_numa is the target topology of the virtual machine, with the initial value equal to old_numa, delta_numa is the topology increment of numa during the virtual machine expansion, the original specification of the virtual machine is f1, the target specification of the virtual machine is f2, the specification increment is delta_f, the number of added CPUs of the virtual machine is C, the increased memory size of the virtual machine is M, and the number of NUMA nodes in the virtual machine NUMA topology is N.
[0074] Furthermore, for each NUMA node in the claimed_numa_topology, denoted as cell, let the NUMA node in the host NUMA topology where this cell is located be denoted as CELL, and the corresponding NUMA node in the delta_numa_topology be denoted as delta_cell, and then apply for resources according to the following rules:
[0075] a. Calculate the list of CPUs to be added on this cell according to the equal distribution principle, denoted as added_cpus, which is the first C / N CPUs in the addable_cpu_map[I];
[0076] b. Calculate the memory size to be added to this cell according to the equal distribution principle, denoted as add_mem, which is M / N;
[0077] c. If add_mem is greater than the remaining memory of the host CELL, or the length of added_cpus is greater than the remaining CPUs of the host CELL, return an error indicating insufficient NUMA resources of the host; otherwise, execute d.
[0078] d. Update the memory size and CPU list of the cell, that is, add M / N of memory to the original memory of the cell; and consider the following situations:
[0079] If it is CPU expansion: add the added_cpus list to the original CPU list of the cell;
[0080] If it is CPU contraction: subtract the last C / N CPUs from the original CPU list of the cell.
[0081] e. Update the CPU and memory size in delta_cell, that is, the memory of delta_cell is equal to add_mem; and consider the following situations:
[0082] If it is CPU expansion: set the vCPU list of delta_cell to added_cpus;
[0083] If it is CPU contraction: set the vCPU list of delta_cell to an empty list.
[0084] f. Check whether the host meets the CPU binding requirements according to the following rules:
[0085] (1). If the CPU binding policy is not configured for the hot expansion target specification, set the CPU binding policy and CPU binding relationship of the cell and delta_cell to be empty; otherwise, execute (2).
[0086] (2). If the number of unbound CPUs in the CELL is less than C / N, return an error indicating insufficient NUMA resources of the host; otherwise, execute (3).
[0087] (3). Find the first C / N unbound CPUs from the CELL and update the CPU binding relationship of the cell and delta_cell.
[0088] After that, update the table attributes. Specifically, update the old_numa_topology attribute of migration_context to the old_numa_topology attribute of the virtual machine, update the new_numa_topology attribute of migration_context to the claimed_numa_topology obtained by the above logic, and update the delta_numa_topology attribute of migration_context to the delta_numa_topology obtained by the above logic.
[0089] Furthermore, the NUMA topology attributes in the compute_nodes table can be updated using the delta_numa_topology attribute in the migration_context updated in the previous step (including updating the newly added CPU usage, newly added memory usage, and newly added CPU binding relationship in the NUMA topology); update the memory and CPU usage in the compute_nodes table using the specification increment; update the NUMA topology attribute of the virtual machine using the new_numa_topology attribute in the migration_context.
[0090] It can be understood that if the hot expansion is successfully executed, the attributes in the migration_context can be cleared, the status of the migration table can be set to end, and the hot expansion is completed. Correspondingly, in the case of hot expansion failure, the resources of the virtual machine need to be rolled back; specifically, roll back the new_numa_topology attribute in the migration_context to the old_numa_topology; set the record status of the migration table to error, and subtract the resource occupancy from the NUMA topology attributes in the compute_nodes table using the delta_numa_topology in the migration_context (including subtracting the newly added CPU usage, subtracting the newly added memory usage, and subtracting the newly added CPU binding relationship); subtract the corresponding memory and CPU usage from the compute_nodes table using the specification increment; clear the attributes in the migration_context; set the migration status to error; and end the hot expansion failure.
[0091] In a specific embodiment, the hot adjustment function of virtual machine resources in the cloud platform is fully implemented as Figure 5As shown in the figure; among them, the source host includes the target host (virtual host); the cloud platform is used to implement the thermal management of the host resources; the thermal adjustment request for the target host resources is sent through the interface component, and the resource update and allocation are carried out through the task scheduling component and the scheduling component; resource allocation and binding are carried out during the thermal adjustment process of the target host. For the specific resource management process, reference can be made to the above-mentioned embodiments.
[0092] It can be seen that when the present application obtains a thermal expansion request, it can add a delta_flavor attribute to the instance_extra table to record the incremental specification information of the virtual machine during the thermal expansion process, including the increased number of CPUs, the increased memory size, and the increased disk size; and use this to implement the method for accurate occupancy and rollback release of host resources; and a new delta_numa_topology attribute is added to the migration_context table to record the incremental NUMA topology of the virtual machine during the thermal expansion process, including CPU and memory increments, and CPU binding relationship increments; and use this attribute to implement the method for accurate occupancy and rollback release of NUMA topology resources at each stage; further, CPU binding can be performed while ensuring accurate resource management, adapting to different scenarios such as expansion and contraction, and improving the usability of the thermal adjustment of virtual machine resources.
[0093] As Figure 6 shown, an embodiment of the present application discloses a virtual machine resource management device, including:
[0094] An incremental recording module 11, configured to obtain a thermal expansion request for the current resources of the virtual machine, and record the resource increment information corresponding to the thermal expansion request; the resource increment information includes the specification increment information of the resources and the topology increment information of the resources;
[0095] A resource comparison module 12, configured to compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determine whether to execute the thermal expansion request based on the comparison result;
[0096] A resource management module 13, configured to manage and update the remaining resources based on the execution situation of the thermal expansion request and in combination with the resource increment information.
[0097] It can be seen that when the present application obtains a thermal expansion request, it can record the resource increment information of the thermal expansion request relative to the current resources of the virtual machine; then, based on the comparison between the resource increment information and the target resource information of the remaining resources of the host, and when executing the thermal expansion request based on the comparison result, it can realize the accurate occupancy or release management update of the specification information and the topology information according to the resource increment information, and can improve the accuracy of resource occupancy during the thermal expansion process.
[0098] In a specific embodiment, the incremental recording module 11 may include:
[0099] An incremental determination sub-module, configured to determine the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the difference between the expanded resources corresponding to the hot expansion request and the current resources;
[0100] An incremental recording unit, configured to record the specification increment information and the topology increment information by using the pre-set specification increment attribute and topology increment attribute respectively.
[0101] In another specific embodiment, the incremental determination sub-module may include:
[0102] A specification increment determination unit, configured to determine the specification increment information of the resources corresponding to the hot expansion request according to the resource differences between the expanded resource information corresponding to the hot expansion request and the current resources in terms of the number of processors, memory size, and disk size;
[0103] A topology increment determination unit, configured to determine the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources.
[0104] In yet another specific embodiment, the topology increment determination unit is specifically configured to: calculate the specification increment information and the number of topology nodes corresponding to the current resources to determine the node increment information corresponding to each topology node; determine the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node from the target resource information according to the node increment information; and determine the topology increment information of the resources corresponding to the hot expansion request based on the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node.
[0105] In a specific embodiment, the resource comparison module 12 may include:
[0106] A first comparison unit, configured to compare the number of processors, memory size, disk size, and the specification increment information in the target resource information of the remaining resources of the host corresponding to the virtual machine to obtain a corresponding first comparison result;
[0107] A second comparison unit, configured to compare the number of processors, memory size, disk size, and the topology increment information of the host nodes corresponding to each topology node in the target resource information to obtain a corresponding second comparison result; the host node is a topology node of the host, corresponding to fixed resources, and the resources corresponding to the topology node of the virtual machine are a subset of the fixed resources;
[0108] Correspondingly, the resource comparison module 12 may include:
[0109] An allocation condition judgment unit, configured to judge whether the relationship between the remaining resources characterized by the first comparison result and the second comparison result and the target incremental resources corresponding to the resource incremental information meets a preset allocation condition; the preset allocation condition indicates that the target incremental resources are a subset of the remaining resources;
[0110] A prohibition execution unit, configured to prohibit the execution of the hot expansion request when the relationship between the remaining resources characterized by the first comparison result and / or the second comparison result and the target incremental resources corresponding to the resource incremental information does not meet the preset allocation condition;
[0111] An allow execution unit, configured to allow the execution of the hot expansion request when both the first comparison result and the second comparison result indicate that the relationship between the remaining resources and the target incremental resources corresponding to the resource incremental information meets the preset allocation condition.
[0112] In a specific embodiment, the resource management module 13 may include:
[0113] An incremental information clearing unit, configured to clear the resource incremental information when the hot expansion request is executed successfully or the execution of the hot expansion request is not allowed;
[0114] A resource rollback unit, configured to perform a resource rollback and release operation on the virtual machine based on the resource incremental information when the execution of the hot expansion request fails.
[0115] In another specific embodiment, the device may further include:
[0116] A processor binding module, configured to, when the hot expansion request represents configuring a processor binding policy, use a processor corresponding to the corresponding host node and matching the specification incremental information to establish a processor binding relationship with the virtual machine, and manage and update the remaining resources according to the processor binding relationship.
[0117] Furthermore, an embodiment of the present application also discloses an electronic device, Figure 7It is a structural diagram of an electronic device shown according to an exemplary embodiment. The content in the figure should not be regarded as any limitation on the scope of use of this application. The electronic device may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the virtual machine resource management method disclosed in any of the foregoing embodiments. In addition, the electronic device in this embodiment may specifically be an electronic computer.
[0118] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of this application, and no specific limitation is imposed on it here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.
[0119] In addition, as a carrier for resource storage, the memory 22 may be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.
[0120] Among them, the operating system 221 is used to manage and control each hardware device and the computer program 222 on the electronic device, and it may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the virtual machine resource management method executed by the electronic device disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program that can be used to complete other specific tasks. <unk>
[0121] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the virtual machine resource management method disclosed above. For the specific steps of this method, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details will not be repeated here.
[0122] Furthermore, this application also discloses a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, they implement the virtual machine resource management method disclosed above.
[0123] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.
[0124] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0125] The steps of the methods or algorithms described in combination with the embodiments disclosed in this article can be directly implemented by hardware, software modules executed by a processor, or a combination of the two. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0126] Finally, it should also be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.
[0127] The above has introduced the technical solutions provided by this application in detail. Specific examples are used in this article to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. A virtual machine resource management method, characterized in that, Including: Obtain a hot expansion request for the current resources of a virtual machine, and record the resource increment information corresponding to the hot expansion request; The resource increment information includes the specification increment information of the resource and the topology increment information of the resource; Compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information, and determine whether to execute the hot expansion request based on the comparison result; Manage and update the remaining resources based on the execution situation of the hot expansion request and in combination with the resource increment information.
2. The virtual machine resource management method according to claim 1, wherein The recording of the resource increment information corresponding to the hot expansion request includes: Determine the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the difference between the expanded resources corresponding to the hot expansion request and the current resources; Record the specification increment information and the topology increment information respectively by using the pre-set specification increment attribute and topology increment attribute.
3. The virtual machine resource management method according to claim 2, wherein The determining of the specification increment information and topology increment information of the resources corresponding to the hot expansion request according to the difference between the expanded resources corresponding to the hot expansion request and the current resources includes: Determine the specification increment information of the resources corresponding to the hot expansion request according to the resource differences between the expanded resource information corresponding to the hot expansion request and the current resources in terms of the number of processors, memory size, and disk size; Determine the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources.
4. The virtual machine resource management method according to claim 3, wherein The determining of the topology increment information of the resources corresponding to the hot expansion request according to the specification increment information and the number of topology nodes corresponding to the current resources includes: Calculate the specification increment information and the number of topology nodes corresponding to the current resources to determine the node increment information corresponding to each topology node; Determine the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node from the target resource information according to each node increment information; Based on the list of processors to be added, the memory size to be added, and the disk size to be added corresponding to each topology node, determine the topology increment information of the resources corresponding to the hot expansion request.
5. The virtual machine resource management method according to claim 4, wherein The comparison of the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource increment information includes: Compare the number of processors, memory size, disk size in the target resource information of the remaining resources of the host corresponding to the virtual machine with the specification increment information to obtain corresponding first comparison results; Compare the number of processors, memory size, disk size in the target resource information of the host nodes corresponding to each topology node with the topology increment information to obtain corresponding second comparison results; the host node is the topology node of the host, corresponding to fixed resources, and the resources corresponding to the topology node of the virtual machine are a subset of the fixed resources; Correspondingly, the determining of whether to execute the hot expansion request based on the comparison result includes: Determine whether the relationship between the remaining resources characterized by the first comparison result and the second comparison result and the target incremental resources corresponding to the resource incremental information meets a preset allocation condition; the preset allocation condition indicates that the target incremental resources are a subset of the remaining resources; If the relationship between the remaining resources characterized by the first comparison result and / or the second comparison result and the target incremental resources corresponding to the resource incremental information does not meet the preset allocation condition, then prohibit the execution of the hot expansion request; If both the first comparison result and the second comparison result indicate that the relationship between the remaining resources and the target incremental resources corresponding to the resource incremental information meets the preset allocation condition, then allow the execution of the hot expansion request.
6. The virtual machine resource management method according to any one of claims 1 to 5, characterized in that The management and update of the remaining resources based on the execution situation of the hot expansion request and in combination with the resource incremental information includes: If the hot expansion request is successfully executed or the execution of the hot expansion request is not allowed, then clear the resource incremental information; If the execution of the hot expansion request fails, then perform a resource rollback and release operation on the virtual machine based on the resource incremental information.
7. The virtual machine resource management method according to any one of claims 1 to 5, characterized in that, During the execution of the hot expansion request, it further includes: If the hot expansion request represents configuring a processor binding policy, then use the processor corresponding to the corresponding host node that matches the specification incremental information to establish a processor binding relationship with the virtual machine, and manage and update the remaining resources according to the processor binding relationship.
8. A virtual machine resource management device, characterized in that It includes: An incremental record module, configured to obtain a hot expansion request for the current resources of a virtual machine and record the resource incremental information corresponding to the hot expansion request; The resource incremental information includes specification incremental information of resources and topology incremental information of resources; A resource comparison module, configured to compare the target resource information of the remaining resources of the host corresponding to the virtual machine with the resource incremental information, and determine whether to execute the hot expansion request based on the comparison result; A resource management module, configured to manage and update the remaining resources based on the execution situation of the hot expansion request and in combination with the resource incremental information.
9. An electronic device, characterized in that, It includes: A memory, configured to store a computer program; A processor, configured to execute the computer program to implement the steps of the virtual machine resource management method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on a computer-readable storage medium, and when the computer program is executed by a processor, it implements the steps of the virtual machine resource management method according to any one of claims 1 to 7.