A virtual machine memory management method, device, electronic device and storage medium

By adding memory reserved proportional attributes and adjustment mechanisms for virtual machines, the problem of physical memory waste of hosts during normal operation of virtual machines is solved, and flexible memory management and resource utilization efficiency are achieved.

CN114153556BActive Publication Date: 2025-08-15ZHENGZHOU YUNHAI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111279939.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2025-08-15
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

How to reduce the waste of physical memory of the host while ensuring the normal operation of the virtual machine, especially to avoid waste of physical memory of the host caused by memory reservation when competing with virtual machine resources.

Method used

By adding the memory reserve ratio attribute to the virtual machine, it supports quantitative memory reserve for the virtual machine, and adjusts the memory reserve ratio according to the actual situation during operation, so as to avoid the host recycling reserved memory resources until the virtual machine process exits.

Benefits of technology

It realizes that under the premise of normal operation of the virtual machine, reduces the waste of physical memory of the host, improves the efficiency of memory resource use, avoids resource waste caused by all reservations in the native solution, and is more flexible in use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114153556B_ABST
    Figure CN114153556B_ABST
Patent Text Reader

Abstract

The present application discloses a virtual machine memory management method, device, electronic device and computer-readable storage medium, the method comprising: determining a target virtual machine; wherein the configuration of the target virtual machine comprises a memory reservation attribute and a memory reservation ratio attribute, the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine; when the target virtual machine has memory reservation enabled, during the operation of the target virtual machine, a memory reservation ratio adjustment command is received, and the memory reservation ratio attribute of the target virtual machine memory is adjusted based on the adjustment command. It can be seen that the virtual machine memory management method provided by the present application reduces the waste of host physical memory while ensuring the normal operation of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a virtual machine memory management method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] With the increasing application of virtualization technology, virtual machines are gradually replacing physical machines to run some services in various fields. As the number of services running on virtual machines increases, people's requirements for virtual machines are also increasing. On the one hand, these requirements include virtual machine configuration and performance, and on the other hand, people also hope that their services can run smoothly. Memory is a basic resource for the normal operation of the operating system. Whether memory resources are sufficient or not directly affects the normal operation of virtual machine services.

[0003] In order to maximize the utilization of host memory resources, a memory balloon device is added to the virtual machine. The principle of memory balloon is to allocate memory to the virtual machine based on the real-time status of the virtual machine. In other words, the amount of memory allocated to the virtual machine is based on the amount of memory used by the virtual machine, rather than allocating memory according to the memory specifications specified when it is created. When there is competition for host memory resources, the normal operation of the virtual machine cannot be guaranteed. At this time, the memory reservation function appears. Although the native KVM (Kernel-based Virtual Machine) solution supports memory reservation, it only supports full reservation. Although it can solve the problem of normal operation of the virtual machine, the reserved memory resources may not be fully used. Other processes cannot use the unused reserved memory resources, which will cause waste of host physical memory.

[0004] Therefore, how to reduce the waste of host physical memory while ensuring the normal operation of the virtual machine is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide a virtual machine memory management method, device, electronic device and computer-readable storage medium, which reduce the waste of host physical memory while ensuring the normal operation of the virtual machine.

[0006] To achieve the above objectives, the present application provides a virtual machine memory management method, comprising:

[0007] Determine a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine;

[0008] In the case that memory reservation is enabled for the target virtual machine, a memory reservation ratio adjustment command is received during the operation of the target virtual machine, and the memory reservation ratio attribute of the target virtual machine memory is adjusted based on the adjustment command.

[0009] The receiving a memory reservation ratio adjustment command and adjusting the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command includes:

[0010] Receiving a memory reservation ratio adjustment command through the cloud management platform; wherein the adjustment command includes at least a target value of the memory reservation ratio;

[0011] updating metadata information of the target virtual machine based on the target value, and updating a configuration file of the target virtual machine based on the updated metadata information;

[0012] The memory size that needs to be reserved for the target virtual machine is calculated according to the target value, the memory characteristics of the target virtual machine are adjusted, and the target virtual machine is restarted.

[0013] Among them, also include:

[0014] Create a target virtual machine and obtain a memory reservation ratio value of the target virtual machine;

[0015] Saving the memory reservation ratio value to the metadata information of the target virtual machine;

[0016] Assigning a memory reservation ratio attribute in a configuration file of the target virtual machine to the memory reservation ratio value;

[0017] The target virtual machine is started using libvirt.

[0018] The step of creating a target virtual machine and obtaining a memory reservation ratio value of the target virtual machine includes:

[0019] A target virtual machine is created through a cloud management platform, and a memory reservation ratio value of the target virtual machine is obtained through the cloud management platform.

[0020] After the memory reservation ratio value is saved in the metadata information of the target virtual machine, the method further includes:

[0021] Restarting the target virtual machine, and after restarting, verifying whether the memory reservation ratio value exists in the metadata information of the target virtual machine;

[0022] If so, the process proceeds to the step of assigning the memory reservation ratio attribute in the configuration file of the target virtual machine to the memory reservation ratio value.

[0023] The step of starting the target virtual machine using libvirt includes:

[0024] Parsing the configuration file of the target virtual machine using libvirt to obtain the memory reservation ratio attribute;

[0025] The memory size that needs to be reserved for the target virtual machine is calculated based on the memory reservation ratio attribute, the memory characteristics of the target virtual machine are set, and the target virtual machine is started.

[0026] The step of calculating the memory size required to be reserved for the target virtual machine based on the memory reservation ratio attribute, setting the memory characteristics of the target virtual machine, and starting the target virtual machine includes:

[0027] Splice the memory reservation ratio attribute into the qemu command;

[0028] The memory size that needs to be reserved for the target virtual machine is calculated by executing the qemu command, the memory characteristics of the target virtual machine are set, and the target virtual machine is started.

[0029] To achieve the above objectives, the present application provides a virtual machine memory management device, comprising:

[0030] A determination module for determining a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, wherein the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine;

[0031] The adjustment module is used to receive a memory reservation ratio adjustment command during the operation of the target virtual machine when memory reservation is turned on for the target virtual machine, and adjust the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command.

[0032] To achieve the above objectives, the present application provides an electronic device, comprising:

[0033] memory for storing computer programs;

[0034] A processor is used to implement the steps of the above-mentioned virtual machine memory management method when executing the computer program.

[0035] To achieve the above objectives, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the virtual machine memory management method as described above are implemented.

[0036] It can be seen from the above scheme that a virtual machine memory management method provided by the present application includes: determining a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, the memory reservation attribute is used to describe whether the target virtual machine turns on memory reservation, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine; when the target virtual machine turns on memory reservation, during the operation of the target virtual machine, a memory reservation ratio adjustment command is received, and the memory reservation ratio attribute of the target virtual machine memory is adjusted based on the adjustment command.

[0037] The virtual machine memory management method provided by the present application supports quantitative memory reservation for virtual machines by adding a memory reservation ratio attribute to the virtual machine. The host will directly allocate the reserved memory to the virtual machine, and the host will not reclaim this part of the memory resources until the virtual machine process exits. In this way, even if the host resources are insufficient, there is no need to worry about the normal operation of the virtual machine. The user can modify the memory reservation ratio at any time according to the actual situation during the operation of the virtual machine, and then modify the reserved memory size of the virtual machine. It is more flexible to use and avoids the defect of wasting the host's physical memory resources caused by the full reservation of the native solution. At the same time, it also improves the efficiency of memory resource utilization. It can be seen that the virtual machine memory management method provided by the present application reduces the waste of the host's physical memory while ensuring the normal operation of the virtual machine. The present application also discloses a virtual machine memory management device, an electronic device and a computer-readable storage medium, which can also achieve the above-mentioned technical effects.

[0038] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure, but do not constitute a limitation of the present disclosure. In the drawings:

[0040] Figure 1 This is a flowchart of a virtual machine memory management method according to an exemplary embodiment;

[0041] Figure 2 This is a flowchart of another virtual machine memory management method according to an exemplary embodiment;

[0042] Figure 3 This is a flowchart showing an operation of creating a virtual machine and setting a virtual machine memory reservation according to an exemplary embodiment;

[0043] Figure 4 This is a flowchart showing a method for setting memory reservation when a bottom layer KVM starts a virtual machine according to an exemplary embodiment;

[0044] Figure 5 1 is a structural diagram of a virtual machine memory management device according to an exemplary embodiment;

[0045] Figure 6 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0046] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0047] The embodiment of the present application discloses a virtual machine memory management method, which reduces the waste of host physical memory while ensuring the normal operation of the virtual machine.

[0048] See also Figure 1 , according to an exemplary embodiment, a flowchart of a virtual machine memory management method is shown, such as Figure 1 Shown, including:

[0049] S101: Determine a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, wherein the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine;

[0050] It is understandable that Libvirt (an open source program for managing virtualization platforms) controls virtual machine memory reservation through the memory reservation attribute (locked attribute) of memoryBacking in the virtual machine XML configuration file. The locked attribute is of Boolean type. A value of true means that virtual machine memory reservation is enabled, and memory reservation is performed when the virtual machine starts. A value of false means that memory is not reserved.

[0051] In this embodiment, by modifying the libvirt code, a memory reservation ratio attribute (locked_percent) is added to the memoryBacking. This attribute describes the percentage of memory reserved for the virtual machine, with a value ranging from 0 to 100. For example, if the total memory allocated to the virtual machine is 4GB and the locked_percent value is set to 50, then 50% of the 4GB, or 2GB, is reserved for the virtual machine. During the virtual machine creation phase, libvirt parses the XML configuration file and parses the locked_percent configuration into the virtual machine configuration structure. During the virtual machine startup phase, the configuration is read from the configuration structure, spliced into the QEMU command line, and a request to start the virtual machine is sent to QEMU.

[0052] It should be noted that since qemu does not have a native reservation percentage function, qemu also needs to modify the code and extend the new command line parameter mlock-percent to receive the locked_percent configuration sent by libvirt. qemu parses the command line parameters sent by libvirt, assigns a value to mlock-percent, starts the memory initialization phase of the qemu virtual machine process, and performs quantitative memory reservation operations on the virtual machine process through the system call mlock.

[0053] S102: When memory reservation is enabled for the target virtual machine, a memory reservation ratio adjustment command is received during operation of the target virtual machine, and a memory reservation ratio attribute of the target virtual machine memory is adjusted based on the adjustment command.

[0054] In this embodiment, for a created target virtual machine, the user can modify the memory reservation ratio at any time according to actual conditions during the operation of the target virtual machine. As a feasible implementation method, the method of receiving a memory reservation ratio adjustment command and adjusting the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command includes: receiving a memory reservation ratio adjustment command through a cloud management platform; wherein the adjustment command includes at least a target value of the memory reservation ratio; updating the metadata information of the target virtual machine based on the target value, and updating the configuration file of the target virtual machine based on the updated metadata information; calculating the memory size that needs to be reserved for the target virtual machine based on the target value, adjusting the memory characteristics of the target virtual machine, and restarting the target virtual machine. In the specific implementation, the user sets the target value of the memory reservation ratio through the cloud management platform. The cloud management platform encapsulates the adjustment command and sends it to novaapi. Novaapi updates the memory reservation ratio attribute in the metadata of the target virtual machine based on the target value in the adjustment command. Nova computer modifies the configuration file of the target virtual machine based on the target value. When restarting the virtual machine, the configuration file is passed to libvirt. Libvirt expands the qemu command parameters based on the target value and passes the target value to qemu. Qemu updates the memory characteristics of the target virtual machine based on the target value and restarts the target virtual machine.

[0055] The virtual machine memory management method provided in the embodiment of the present application supports quantitative memory reservation for the virtual machine by adding a memory reservation ratio attribute to the virtual machine. The host will directly allocate the reserved memory to the virtual machine, and the host will not reclaim this part of the memory resources until the virtual machine process exits. In this way, even if the host resources are insufficient, there is no need to worry about the normal operation of the virtual machine. The user can modify the memory reservation ratio at any time according to the actual situation during the operation of the virtual machine, and then modify the reserved memory size of the virtual machine. It is more flexible to use and avoids the defect of wasting the host's physical memory resources caused by the full reservation of the native solution, while also improving the efficiency of memory resource utilization. It can be seen that the virtual machine memory management method provided in the embodiment of the present application reduces the waste of the host's physical memory while ensuring the normal operation of the virtual machine.

[0056] This example describes how to configure the memory reservation ratio when creating a target virtual machine. Specifically:

[0057] See also Figure 2 , according to an exemplary embodiment, a flowchart of another virtual machine memory management method is shown, such as Figure 2 Shown, including:

[0058] S201: Create a target virtual machine and obtain a memory reservation ratio value of the target virtual machine;

[0059] In a specific implementation, a target virtual machine is created through a cloud management platform, and a memory reservation ratio value is set in the advanced configuration of the target virtual machine, that is, the memory reservation ratio value of the target virtual machine is obtained through the cloud management platform.

[0060] S202: Saving the memory reservation ratio value to the metadata information of the target virtual machine;

[0061] In a specific implementation, the cloud management platform sends the memory reservation ratio value to the nova API, which saves the memory reservation ratio value to the metadata of the target virtual machine. After the target virtual machine is restarted, nova computer verifies whether the memory reservation ratio value exists in the metadata of the target virtual machine. If so, the process proceeds to S203.

[0062] S203: Assigning a memory reservation ratio attribute in the configuration file of the target virtual machine to the memory reservation ratio value;

[0063] In this step, nova computer adds the memory reservation ratio value to the configuration file of the target virtual machine.

[0064] S204: Start the target virtual machine using libvirt.

[0065] In this step, nova computer sends a request to libvirt to start the target virtual machine, and libvirt starts the target virtual machine.

[0066] As a feasible implementation method, this step includes: using libvirt to parse the configuration file of the target virtual machine to obtain the memory reservation ratio attribute; calculating the memory size that the target virtual machine needs to reserve based on the memory reservation ratio attribute, setting the memory characteristics of the target virtual machine, and starting the target virtual machine. In a specific implementation, the kvm bottom layer starts the target virtual machine, receives and parses the configuration file of the target virtual machine, including the CPU, memory, and various devices of the virtual machine, and determines whether the memory reservation attribute is enabled. If so, the memory reservation ratio attribute is spliced into the qemu command, and the memory size that the target virtual machine needs to reserve is calculated by executing the qemu command, and the memory characteristics of the target virtual machine are set accordingly, and the target virtual machine is started.

[0067] It can be seen that this embodiment sets the memory reservation ratio attribute when creating a virtual machine, and reserves memory for the virtual machine in a quantitative manner, avoiding the defect of wasting host physical memory resources caused by full reservation in the native solution, and also improving the efficiency of memory resource utilization.

[0068] The following describes an application embodiment provided by the present application: Figure 3 As shown, the following steps are included:

[0069] Step 1: The administrator logs in to the cloud management platform interface;

[0070] Step 2: Select Create Virtual Machine;

[0071] Step 3: Set the memory reservation value in the memory reservation settings in the advanced options of creating a virtual machine;

[0072] Step 4: The UI encapsulates the data in the virtual machine metadata and sends it to the API;

[0073] Step 5: The API processes the virtual machine metadata and sends it to Compute.

[0074] Step 6: compute determines whether the metadata contains memory reservation configuration information;

[0075] Step 7: Encapsulate the memory reservation configuration into the virtual machine XML configuration, and then send a request to libvirt to start the virtual machine.

[0076] The flowchart for setting memory reservation when the underlying kvm starts the virtual machine is as follows Figure 4 As shown, the following steps are included:

[0077] Step 1: Libvirt receives the virtual machine XML configuration file issued by the cloud platform;

[0078] Step 2: Libvirt parses the virtual machine XML file, including the CPU, memory, and various devices of the virtual machine;

[0079] Step 3: Libvirt parses the virtual machine's memory configuration to determine whether there is any memory reservation configuration.

[0080] Step 4: If there is a memory reservation configuration, add the configuration item to the qemu command;

[0081] Step 5: libvirt sends qemu commands to the qemu layer;

[0082] Step 6: Qemu parses the command parameters and retrieves the memory reservation configuration.

[0083] Step 7: When qemu starts the virtual machine process, it calculates the memory size to be reserved and sets the virtual machine memory reservation feature through the system call interface.

[0084] A virtual machine memory management device provided in an embodiment of the present application is introduced below. The virtual machine memory management device described below and the virtual machine memory management method described above can be referenced to each other.

[0085] See also Figure 5 , according to an exemplary embodiment, a structural diagram of a virtual machine memory management device is shown, such as Figure 5 Shown, including:

[0086] Determination module 501, for determining a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine;

[0087] The adjustment module 502 is used to receive a memory reservation ratio adjustment command during the operation of the target virtual machine when memory reservation is enabled for the target virtual machine, and adjust the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command.

[0088] The virtual machine memory management device provided in the embodiment of the present application supports quantitative memory reservation for the virtual machine by adding a memory reservation ratio attribute to the virtual machine. The host will directly allocate the reserved memory to the virtual machine, and the host will not reclaim this part of the memory resources until the virtual machine process exits. In this way, even if the host resources are insufficient, there is no need to worry about the normal operation of the virtual machine. The user can modify the memory reservation ratio at any time according to the actual situation during the operation of the virtual machine, and then modify the reserved memory size of the virtual machine. It is more flexible to use and avoids the defect of wasting the host's physical memory resources caused by the full reservation of the native solution, while also improving the efficiency of memory resource utilization. It can be seen that the virtual machine memory management method provided in the embodiment of the present application reduces the waste of the host's physical memory while ensuring the normal operation of the virtual machine.

[0089] Based on the above embodiment, as a preferred implementation, the adjustment module 502 includes:

[0090] A receiving unit, configured to receive a memory reservation ratio adjustment command via a cloud management platform; wherein the adjustment command includes at least a target value of the memory reservation ratio;

[0091] an updating unit, configured to update metadata information of the target virtual machine based on the target value, and update a configuration file of the target virtual machine based on the updated metadata information;

[0092] An adjusting unit is configured to calculate the memory size that needs to be reserved for the target virtual machine according to the target value, adjust the memory characteristics of the target virtual machine, and restart the target virtual machine.

[0093] Based on the above embodiment, as a preferred implementation, it further includes:

[0094] A creation module is used to create a target virtual machine and obtain a memory reservation ratio value of the target virtual machine;

[0095] A saving module, configured to save the memory reservation ratio value to the metadata information of the target virtual machine;

[0096] An assignment module, configured to assign a memory reservation ratio attribute in a configuration file of the target virtual machine to the memory reservation ratio value;

[0097] The startup module is used to start the target virtual machine using libvirt.

[0098] Based on the above embodiment, as a preferred implementation mode, the creation module is specifically a module that creates a target virtual machine through a cloud management platform and obtains a memory reservation ratio value of the target virtual machine through the cloud management platform.

[0099] Based on the above embodiment, as a preferred implementation, it further includes:

[0100] A restart module is used to restart the target virtual machine and verify whether the memory reservation ratio value exists in the metadata information of the target virtual machine after restart; if so, start the workflow of the assignment module.

[0101] Based on the above embodiment, as a preferred implementation, the startup module includes:

[0102] A parsing unit, configured to parse a configuration file of the target virtual machine using libvirt to obtain the memory reservation ratio attribute;

[0103] The setting unit is configured to calculate the memory size required to be reserved for the target virtual machine based on the memory reservation ratio attribute, set the memory characteristics of the target virtual machine, and start the target virtual machine.

[0104] Based on the above embodiment, as a preferred implementation method, the setting unit specifically splices the memory reservation ratio attribute into the qemu command, calculates the memory size that needs to be reserved for the target virtual machine by executing the qemu command, sets the memory characteristics of the target virtual machine, and starts the unit of the target virtual machine.

[0105] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0106] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application further provides an electronic device, Figure 6 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 6 As shown, the electronic equipment includes:

[0107] Communication interface 1, capable of exchanging information with other devices such as network devices;

[0108] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the virtual machine memory management method provided by one or more of the above technical solutions when running a computer program. The computer program is stored in the memory 3.

[0109] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as bus system 4.

[0110] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0111] It is understood that the memory 3 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a magnetic disk memory or a magnetic tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 3 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.

[0112] The method disclosed in the above-mentioned embodiment of the present application can be applied to processor 2 or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above-mentioned method can be completed by the integrated logic circuit of the hardware in processor 2 or instructions in the form of software. The above-mentioned processor 2 can be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the above-mentioned method in combination with its hardware.

[0113] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented. For the sake of brevity, they are not repeated here.

[0114] In an exemplary embodiment, the present application also provides a storage medium, namely, a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 storing a computer program. The computer program can be executed by a processor 2 to perform the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.

[0115] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, ROM, RAM, disks or optical disks, etc. Various media that can store program codes.

[0116] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0117] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A virtual machine memory management method, characterized in that: include: Determine a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine; In a case where memory reservation is enabled for the target virtual machine, during operation of the target virtual machine, receiving a memory reservation ratio adjustment command, and adjusting a memory reservation ratio attribute of the target virtual machine memory based on the adjustment command; The receiving a memory reservation ratio adjustment command and adjusting the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command includes: Receiving a memory reservation ratio adjustment command through the cloud management platform; wherein the adjustment command includes at least a target value of the memory reservation ratio; Updating the metadata information of the target virtual machine based on the target value through the nova api, and updating the configuration file of the target virtual machine based on the updated metadata information through novacomputer; The memory size that needs to be reserved for the target virtual machine is calculated according to the target value by libvirt, the memory characteristics of the target virtual machine are adjusted by qemu, and the target virtual machine is restarted.

2. The virtual machine memory management method according to claim 1, characterized in that: Also includes: Create a target virtual machine and obtain a memory reservation ratio value of the target virtual machine; Saving the memory reservation ratio value to the metadata information of the target virtual machine; Assigning a memory reservation ratio attribute in a configuration file of the target virtual machine to the memory reservation ratio value; The target virtual machine is started using libvirt.

3. The virtual machine memory management method according to claim 2, characterized in that: The step of creating a target virtual machine and obtaining a memory reservation ratio value of the target virtual machine includes: A target virtual machine is created through a cloud management platform, and a memory reservation ratio value of the target virtual machine is obtained through the cloud management platform.

4. The virtual machine memory management method according to claim 2, characterized in that: After the memory reservation ratio value is saved in the metadata information of the target virtual machine, the method further includes: Restarting the target virtual machine, and after restarting, verifying whether the memory reservation ratio value exists in the metadata information of the target virtual machine; If so, the process proceeds to the step of assigning the memory reservation ratio attribute in the configuration file of the target virtual machine to the memory reservation ratio value.

5. The virtual machine memory management method according to claim 2, wherein: The method of starting the target virtual machine by using libvirt includes: Parsing the configuration file of the target virtual machine using libvirt to obtain the memory reservation ratio attribute; The memory size that needs to be reserved for the target virtual machine is calculated based on the memory reservation ratio attribute, the memory characteristics of the target virtual machine are set, and the target virtual machine is started.

6. The virtual machine memory management method according to claim 5, characterized in that: The calculating the memory size that needs to be reserved for the target virtual machine based on the memory reservation ratio attribute, setting the memory characteristics of the target virtual machine, and starting the target virtual machine includes: Splice the memory reservation ratio attribute into the qemu command; The memory size that needs to be reserved for the target virtual machine is calculated by executing the qemu command, the memory characteristics of the target virtual machine are set, and the target virtual machine is started.

7. A virtual machine memory management device, characterized in that: include: A determination module for determining a target virtual machine; wherein the configuration of the target virtual machine includes a memory reservation attribute and a memory reservation ratio attribute, wherein the memory reservation attribute is used to describe whether the target virtual machine has memory reservation enabled, and the memory reservation ratio attribute is used to describe the reserved memory ratio of the target virtual machine; An adjustment module is configured to receive a memory reservation ratio adjustment command during the operation of the target virtual machine when memory reservation is enabled for the target virtual machine, and adjust the memory reservation ratio attribute of the target virtual machine memory based on the adjustment command; Wherein, the adjustment module includes: A receiving unit, configured to receive a memory reservation ratio adjustment command via a cloud management platform; wherein the adjustment command includes at least a target value of the memory reservation ratio; an updating unit, configured to update the metadata information of the target virtual machine based on the target value through the nova api, and update the configuration file of the target virtual machine based on the updated metadata information through nova computer; The adjustment unit is used to calculate the memory size that needs to be reserved for the target virtual machine according to the target value through libvirt, adjust the memory characteristics of the target virtual machine through qemu, and restart the target virtual machine.

8. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the virtual machine memory management method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the virtual machine memory management method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • A method and system for realizing memory share scheduling management based on KVM virtualization

    CN109885381A

  • Data storage method, device and equipment and computer readable storage medium

    CN112596862A