Virtual machine migration method and device and storage medium
The method of tracking and pausing virtual machines through bitmap information solves the problem of reduced efficiency caused by CPU exit during virtual machine migration, and achieves a more stable and efficient migration process.
Patent Information
- Application Number
- CN202310158284.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2043-02-23
AI Technical Summary
The existing technology requires the virtual machine CPU to exit during the virtual machine migration process, resulting in reduced business operation efficiency and possible abnormalities.
By reading the dirty page bitmap information from the bitmap storage space, determine the dirty page to be sent, pause the virtual machine when the preset pause time meets the conditions, read the dirty page bit flag in the last-level page table, and update the bitmap Information, determine the current dirty page to be sent and send it to the target device.
This avoids the virtual machine CPU exit phenomenon, reduces the impact on business operation efficiency, and improves the stability and efficiency of the migration process.
Smart Images

Figure CN118535313A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a virtual machine migration method, device and storage medium. Background Art
[0002] In a cloud scenario, if a running virtual machine is migrated from one physical server to another, it is necessary to perform a hot migration of the virtual machine's memory while ensuring that the business in the virtual machine is uninterrupted. This process requires tracking the dirty pages (changed memory) generated by the source virtual machine during the migration process on the source server and transferring the dirty pages to the target migration device.
[0003] However, the existing technology requires the CPU (vcpu) in the virtual machine to exit (VM-EXIT) to track dirty pages, resulting in the vcpu exiting for each dirty page transfer. The vcpu exit operation will reduce the operating efficiency of the business in the virtual machine and may even cause business abnormalities.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present application is to provide a virtual machine migration method, device and storage medium, aiming to solve the technical problem that the prior art reduces the operating efficiency of the business in the virtual machine and affects the normal operation of the business when performing virtual machine migration.
[0006] To achieve the above object, the present application provides a virtual machine migration method, the method comprising: Reading dirty page bitmap information from the bitmap storage space, and determining the dirty page to be sent according to the dirty page bitmap information; When the dirty page to be sent and the preset pause time meet the final iteration condition, pausing the source virtual machine and reading the dirty page bit flag in the last-level page table; The dirty page bitmap information is updated according to the dirty page bit flag to obtain current bitmap information; The dirty page to be sent currently is determined according to the current bitmap information, and the dirty page to be sent currently is sent to the target migration device.
[0007] In a possible implementation of the present application, before reading dirty page bitmap information from the bitmap storage space and determining the dirty page to be sent according to the dirty page bitmap information, the method further includes: The dirty page bit flag in the last-level page table is read, and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag.
[0008] In a possible implementation of the present application, the step of reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Read dirty page bitmap information from the bitmap storage space; Determine a non-dirty page item according to the dirty page bitmap information; The dirty page bit flag corresponding to the non-dirty page entry in the last-level page table is read, and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag.
[0009] In a possible implementation of the present application, before reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag, the method further includes: Determine the last-level page table memory according to the memory size of the source virtual machine; A final-level page table is constructed according to the final-level page table memory.
[0010] In a possible implementation of the present application, reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a kernel-mode thread; The kernel state thread polls the dirty page bit flag in the last-level page table at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
[0011] In a possible implementation of the present application, reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a user state thread, and create a memory mapping for the user state thread, mapping the memory space corresponding to the last level page table to the user state address space; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled by the user-mode thread at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
[0012] In a possible implementation of the present application, reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a polling instance in the DPU accelerator card, create a memory mapping for the DPU accelerator card, and map the memory space and the bitmap storage space corresponding to the last-level page table to the DPU accelerator card; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled at a preset period by the polling instance to obtain dirty page flag information; Based on the memory mapping, the dirty page bitmap information in the bitmap storage space is updated according to the dirty page flag information.
[0013] In a possible implementation of the present application, after reading dirty page bitmap information from the bitmap storage space and determining the dirty page to be sent according to the dirty page bitmap information, the method further includes: When the dirty pages to be sent and the preset pause time meet the continuous iteration condition, the dirty pages to be sent this time are selected from the dirty pages to be sent, and the dirty page bitmap information is updated according to the dirty pages to be sent this time; The dirty page bit flag corresponding to the dirty page sent this time is cleared, and the dirty page sent this time is sent to the target migration device.
[0014] In a possible implementation of the present application, selecting the dirty page to be sent this time from the dirty pages to be sent, and updating the dirty page bitmap information according to the dirty page to be sent this time, includes: Selecting the dirty page to be sent this time from the dirty pages to be sent according to the upper limit of a single transmission; The bitmap information corresponding to the dirty page sent this time in the dirty page bitmap information is cleared.
[0015] In addition, to achieve the above-mentioned purpose, the embodiment of the present application further provides a virtual machine migration device, the virtual machine migration device comprising: An information acquisition module is configured to read dirty page bitmap information from a bitmap storage space, and determine dirty pages to be sent according to the dirty page bitmap information; A logic judgment module is configured to pause the source virtual machine and read the dirty page bit flag in the last-level page table when the dirty page to be sent and the preset pause time meet the final iteration condition; A data updating module is configured to update the dirty page bitmap information according to the dirty page bit flag to obtain current bitmap information; The data migration module is configured to determine the current dirty page to be sent according to the current bitmap information, and send the current dirty page to be sent to the target migration device.
[0016] In addition, to achieve the above-mentioned purpose, an embodiment of the present application also provides a virtual machine migration device, which includes: a processor, a memory, and a virtual machine migration program stored in the memory and executable on the processor, and when the virtual machine migration program is executed by the processor, the steps of the virtual machine migration method described above are implemented.
[0017] In addition, to achieve the above-mentioned purpose, an embodiment of the present application further provides a computer-readable storage medium, on which a virtual machine migration program is stored, and when the virtual machine migration program is executed, the steps of the virtual machine migration method described above are implemented.
[0018] The present application reads dirty page bitmap information from the bitmap storage space, and determines the dirty page to be sent according to the dirty page bitmap information; when the dirty page to be sent and the preset pause time meet the final iteration condition, the source virtual machine is paused, and the dirty page bit flag in the last-level page table is read; the dirty page bitmap information is updated according to the dirty page bit flag to obtain the current bitmap information; the current dirty page to be sent is determined according to the current bitmap information, and the current dirty page to be sent is sent to the target migration device. During the virtual machine migration process, dirty page tracking is not performed using the existing method, but dirty page bitmap information is used to track dirty pages to determine the current dirty page to be sent, which will not cause the virtual machine CPU to have a page missing exception, thereby avoiding the virtual machine CPU exit phenomenon and reducing the impact on the operating efficiency of the business in the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a structural diagram of an electronic device of a hardware operating environment involved in an embodiment of the present application; Figure 2 This is a flowchart of the first embodiment of the virtual machine migration method of the present application; Figure 3 This is a flow chart of the second embodiment of the virtual machine migration method of the present application; Figure 4 A flowchart of a third embodiment of the virtual machine migration method of the present application; Figure 5 A schematic diagram of a device component according to an embodiment of the present application; Figure 6 A schematic diagram of component interaction according to an embodiment of the present application; Figure 7 This is a structural block diagram of the first embodiment of the virtual machine migration device of the present application.
[0020] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0021] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0022] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a virtual machine migration device in the hardware operating environment involved in the embodiment of the present application.
[0023] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0024] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0025] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a virtual machine migration program.
[0026] exist Figure 1 In the electronic device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the electronic device of the present application can be set in a virtual machine migration device, and the electronic device calls the virtual machine migration program stored in the memory 1005 through the processor 1001, and executes the virtual machine migration method provided in the embodiment of the present application.
[0027] The present application embodiment provides a virtual machine migration method, referring to Figure 2 , Figure 2 This is a flow chart of a first embodiment of a virtual machine migration method of the present application.
[0028] In this embodiment, the virtual machine migration method includes the following steps: Step S100: reading dirty page bitmap information from the bitmap storage space, and determining the dirty page to be sent according to the dirty page bitmap information.
[0029] It should be noted that the executor of this embodiment can be the virtual machine migration device, and the virtual machine migration device can be a server or personal computer equipped with an active virtual machine. Of course, it can also be other devices with the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the virtual machine migration method of the present application is explained by taking the virtual machine migration device as an example.
[0030] It should be noted that the bitmap storage space can be a memory space in the virtual machine migration device, which is used to store the dirty page bitmap. The dirty page bitmap can be a dot matrix map or a raster map, in which each dot or grid corresponds to a page in the virtual machine. The data stored in the point or grid is used to identify whether the virtual machine page corresponding to the point or grid has changed, that is, whether it is a dirty page.
[0031] For example, a dot map is used as a dirty page bitmap, and each dot stores 1 bit of data. If the data stored in the dot is 0, it means that the virtual machine page corresponding to the dot is not a dirty page; if the data stored in the dot is 1, it means that the virtual machine page corresponding to the dot is a dirty page.
[0032] It is understandable that after reading the dirty page bitmap from the bitmap storage space and obtaining the dirty page bitmap information, all dirty pages in the source virtual machine can be determined according to the identifiers of each point in the dirty page bitmap information, thereby obtaining the dirty pages to be sent.
[0033] Step S200: When the dirty page to be sent and the preset pause time meet the final iteration condition, the source virtual machine is paused, and the dirty page bit flag in the last-level page table is read.
[0034] It should be noted that when hot migrating a virtual machine, the administrator of the virtual machine migration device will set the maximum duration for which the virtual machine is allowed to pause during the last dirty page transmission, that is, the preset pause duration. If the dirty page to be sent can be transferred within the preset pause duration, then it can be determined that the dirty page to be sent and the preset pause duration meet the final iteration conditions.
[0035] If the final iteration conditions are met, this will be the last iteration, that is, the last dirty page transfer. In order to avoid data loss, it is necessary to suspend the operation of the source virtual machine and then read the dirty page bit flag in the last-level page table of the virtual machine. The last-level page table can be a resident memory of the virtual machine monitor (Hypervisor) during the life cycle of the virtual machine.
[0036] Step S300: updating the dirty page bitmap information according to the dirty page bit flag to obtain current bitmap information.
[0037] It is understandable that after the dirty page bit flag is read, the dirty page bitmap information stored in the bitmap storage space may be updated according to the dirty page bit flag, thereby obtaining the latest bitmap information, ie, the current bitmap information.
[0038] Step S400: determining the dirty page to be sent currently according to the current bitmap information, and sending the dirty page to be sent currently to the target migration device.
[0039] It should be noted that during the last dirty page transmission, the source virtual machine has been suspended, and no new dirty pages will be generated in the source virtual machine. After obtaining the current bitmap information, the current dirty page to be sent is determined according to the current bitmap information, which can avoid data loss during the virtual machine migration process.
[0040] It is understandable that after determining the dirty page to be sent, the dirty page to be sent can be sent to the target migration device, thereby completing the hot migration of the virtual machine. The target migration device can be the device to which the virtual machine is migrated during the virtual machine migration process, such as a server or a personal computer.
[0041] In actual use, after the dirty page to be sent is sent to the target migration device, the overall virtual machine migration process has been completed. At this time, the source virtual machine can be destroyed and memory release and other operations can be performed to reduce resource usage in the device.
[0042] This embodiment reads dirty page bitmap information from the bitmap storage space, and determines the dirty page to be sent according to the dirty page bitmap information; when the dirty page to be sent and the preset pause time meet the final iteration condition, the source virtual machine is paused, and the dirty page bit flag in the last-level page table is read; the dirty page bitmap information is updated according to the dirty page bit flag to obtain the current bitmap information; the current dirty page to be sent is determined according to the current bitmap information, and the current dirty page to be sent is sent to the target migration device. During the virtual machine migration process, dirty page tracking is not performed using the existing method, but dirty page bitmap information is used to track dirty pages to determine the current dirty page to be sent, which will not cause the virtual machine CPU to have a page missing exception, thereby avoiding the virtual machine CPU exit phenomenon and reducing the impact on the operating efficiency of the business in the virtual machine.
[0043] refer to Figure 3 , Figure 3 This is a flow chart of a second embodiment of a virtual machine migration method of the present application.
[0044] Based on the first embodiment, the virtual machine migration method of this embodiment further includes, before step S100: Step S010: determining the last-level page table memory according to the memory size of the source virtual machine.
[0045] It should be noted that this embodiment will transform the page table memory managed by the original virtual machine monitor (hypervisor). When creating a virtual machine, the memory size required for storing the last-level page table will be calculated based on the memory size of the virtual machine, the last-level page table memory will be determined, and then the memory application will be made at one time. When applying for memory, continuous memory space is used first, and the memory offset address of the page table in the memory space is calculated based on the physical address page frame number (GFN) of the current virtual machine.
[0046] Step S020: constructing a final-level page table according to the final-level page table memory.
[0047] It should be noted that when a virtual machine is created, it will build an address mapping page table to store the guest physical address (GPA) and the host physical address (HPA). After applying for the final page table memory, the final page table is built according to the applied final page table memory, that is, when the virtual machine monitor builds the address mapping page table (GPA->HPA page table), the final page table memory is used as the final page table for construction.
[0048] In actual use, during the virtual machine migration process, the tracking of memory dirty pages requires the use of the last-level page table. With the original page table memory management method, the virtual machine will have page fault exceptions due to an incomplete migration process, resulting in vcpu exit. After the page table memory management method is modified, the applied memory can be directly used as the memory of the last-level page table, thereby avoiding the phenomenon of vcpu exiting due to page fault exceptions in the virtual machine.
[0049] Step S030: reading the dirty page bit flag in the last-level page table, and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag.
[0050] It should be noted that there will be multiple page table entries in the final page table, and each page table entry corresponds to a page in a virtual machine. During the operation of the virtual machine, if a page in the virtual machine changes, the page table entry of the page in the final page table will be written with a dirty page bit flag to indicate that the page is a dirty page. Updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag can be to update the data stored in the points or grids in the dirty page bitmap in the bitmap storage space according to the dirty page bit flag.
[0051] It should be understood that reading the dirty page bit flag in the last-level page table requires scanning the page table entries in the last-level page table one by one, which is relatively time-consuming and cannot be directly applied in the dirty page transmission process. At this time, in order to facilitate the dirty page transmission, a dirty page bitmap can be created in the bitmap storage space, and then the dirty page bit flag in the last-level page table is read periodically. After reading the dirty page bit flag in the last-level page table, the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag. In the dirty page transmission process, only the dirty page bitmap information needs to be read during transmission to determine the dirty page.
[0052] In the implementation process, a CPU thread may be created to periodically read the dirty page bit flag in the last-level page table and update the dirty page bitmap information in the bitmap storage space. The CPU thread may be divided into a user state thread and a kernel state thread. If a kernel state thread is created for execution, step S030 in this embodiment may include: Create a kernel-mode thread; The kernel state thread polls the dirty page bit flag in the last-level page table at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
[0053] It should be noted that the kernel state thread has a higher access right and can directly access the memory in the virtual machine monitor. If a kernel state thread is created, the kernel state thread directly has the right to access the last-level page table. At this time, the dirty page bit flag in the last-level page table can be directly polled by the kernel state thread at a preset period, and the dirty page bitmap information in the bitmap storage space can be updated according to the dirty page flag information obtained. Among them, the preset period can be pre-set by the administrator of the virtual machine migration device, for example, the preset period is set to 30 seconds.
[0054] If a user-mode thread is created, then step S030 in this embodiment may include: Create a user state thread, and create a memory mapping for the user state thread, mapping the memory space corresponding to the last level page table to the user state address space; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled by the user-mode thread at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
[0055] It should be noted that the user-state thread has low access rights and cannot directly access the memory in the virtual machine monitor. At this time, in order to ensure that the created user-state thread can normally read the dirty page bit flag in the last-level page table and update the dirty page bitmap information, a memory mapping can be created to map the memory space corresponding to the last-level page table to the user-state address space. At this time, the user-state thread can read the dirty page bit flag in the last-level page table from the user-state address space according to the created memory mapping, and update the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag information read. Among them, the memory mapping can be created through the MMU function of the CPU, and before sending the dirty page memory, the dirty page bitmap information and dirty page bit flag corresponding to the batch of dirty page memory sent can be directly cleaned up through memory mapping in the user-state address space.
[0056] In a possible implementation of this embodiment, the dirty page bit flag in the last-level page table may be read through the DPU accelerator card instance and the dirty page bitmap information in the bitmap storage space may be updated. In this case, step S030 in this embodiment may include: Create a polling instance in the DPU accelerator card, create a memory mapping for the DPU accelerator card, and map the memory space and the bitmap storage space corresponding to the last-level page table to the DPU accelerator card; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled at a preset period by the polling instance to obtain dirty page flag information; Based on the memory mapping, the dirty page bitmap information in the bitmap storage space is updated according to the dirty page flag information.
[0057] It should be noted that, since the instance created in the data processing unit (DPU) accelerator card has low access rights, it cannot directly access the memory space and bitmap storage space corresponding to the last-level page table. At this time, in order to ensure that the created polling instance can normally read the dirty page bit flag in the last-level page table and update the dirty page bitmap information in the bitmap storage space, it is necessary to create a memory mapping, map the memory space and bitmap storage space corresponding to the last-level page table to the DPU accelerator card, and after the memory mapping is established, the created polling instance can access the memory space and bitmap storage space corresponding to the last-level page table. At this time, the polling instance can be used to poll the dirty page bit flag in the last-level page table at a preset period, and according to the obtained dirty page flag information, the dirty page bitmap information in the bitmap storage space is updated. Among them, when creating a memory mapping, the IOMMU function can be used to create a memory mapping.
[0058] In a possible implementation of this embodiment, when reading the dirty page bit flag in the last-level page table, the more page table entries are read, the longer the execution time is consumed. In order to improve the reading efficiency, step S03 in this embodiment may include the following steps: Read dirty page bitmap information from the bitmap storage space; Determine a non-dirty page item according to the dirty page bitmap information; The dirty page bit flag corresponding to the non-dirty page entry in the last-level page table is read, and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag.
[0059] It should be noted that if a page has been marked as a dirty page, even if the memory corresponding to the page is changed again, the page is still a dirty page, and the fact that the page is a dirty page has actually been written into the dirty page bitmap information. At this time, in order to improve the reading efficiency, before reading the dirty page bit flag in the last-level page table, you can first read the dirty page bitmap information, determine the non-dirty page items at the time of the last read according to the dirty page bitmap information, and then read the dirty page bit flag corresponding to the non-dirty page items in the last-level page table, and then update the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag corresponding to the non-dirty page items. This can reduce the page table entries that need to be read when reading the last-level page table, thereby improving the reading efficiency.
[0060] This embodiment determines the final page table memory according to the memory size of the source virtual machine; constructs the final page table according to the final page table memory; reads the dirty page bit flag in the final page table, and updates the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag. Since the final page table memory is determined in advance according to the memory size of the source virtual machine, and the final page table is constructed according to the final page table memory, it is ensured that the virtual machine CPU will not exit due to a page fault exception during the virtual machine migration process, further reducing the impact on the virtual machine business.
[0061] refer to Figure 4 , Figure 4 This is a flow chart of a third embodiment of a virtual machine migration method of the present application.
[0062] Based on the first embodiment above, after step S100, the virtual machine migration method of this embodiment further includes: Step S200': when the dirty pages to be sent and the preset pause time meet the continuous iteration condition, the dirty pages to be sent this time are selected from the dirty pages to be sent, and the dirty page bitmap information is updated according to the dirty pages to be sent this time.
[0063] It should be noted that when hot migrating a virtual machine, the administrator of the virtual machine migration device will set the maximum duration for which the virtual machine is allowed to pause during the last dirty page transmission, that is, the preset pause duration. If the dirty page to be sent cannot be transmitted within the preset pause duration, then it can be determined that the dirty page to be sent and the preset pause duration meet the continuous iteration conditions.
[0064] It can be understood that if the dirty pages to be sent and the preset pause time meet the continuous iteration conditions, it means that only a part of the dirty pages can be transmitted this time. Therefore, some dirty pages can be selected from the dirty pages to be sent as the dirty pages to be sent this time, and then the dirty page bitmap information is updated according to the dirty pages sent this time to avoid repeated dirty page transmission thereafter.
[0065] In actual use, in order to reasonably select the dirty page to be sent this time, the step of selecting the dirty page to be sent this time from the dirty pages to be sent in this embodiment, and updating the dirty page bitmap information according to the dirty page to be sent this time, may include: Selecting the dirty page to be sent this time from the dirty pages to be sent according to the upper limit of a single transmission; The bitmap information corresponding to the dirty page sent this time in the dirty page bitmap information is cleared.
[0066] It should be noted that the upper limit of a single transmission may be determined by a preset pause duration and a transmission bandwidth of the virtual machine migration device, or may be pre-set by an administrator of the virtual machine migration device, and this embodiment does not limit this. Selecting the dirty page to be sent this time from the dirty pages to be sent according to the upper limit of a single transmission may be selecting a dirty page whose size is less than or equal to the preset transmission upper limit from the dirty pages to be sent as the dirty page to be sent this time.
[0067] In actual use, clearing the bitmap information corresponding to the dirty page sent this time in the dirty page bitmap information may be to find the point or grid corresponding to the dirty page sent this time in the dirty page bitmap information and adjust the data recorded therein to the mark data corresponding to the non-dirty page.
[0068] For example, if the data stored at a point in the dirty page bitmap information is 0, it means that the virtual machine page corresponding to the point is not a dirty page; if the data stored at the point is 1, it means that the virtual machine page corresponding to the point is a dirty page, then the data stored at the point corresponding to the dirty page sent this time in the dirty page bitmap information is set to 0.
[0069] Step S300': clearing the dirty page bit flag corresponding to the dirty page sent this time, and sending the dirty page sent this time to the target migration device.
[0070] It can be understood that if the dirty page sent this time is sent to the target migration device, it means that the memory of the dirty page sent this time has been synchronized to the target migration device. In order to avoid subsequent repeated dirty page transmission, before sending the dirty page sent this time to the target migration device, the dirty page bit flag corresponding to the dirty page sent this time in the last-level page table can be cleared.
[0071] For ease of understanding, now combined Figure 5 and 6 This is for illustration only, but not for limitation. Figure 5 is a schematic diagram of the device components of this embodiment, such as Figure 5 As shown, the virtual machine migration device includes a final page table, a polling module, a dirty page bitmap, a migration thread, and a virtual machine monitor (hypervisor), wherein the virtual machine monitor is responsible for the management of the GPA->HPA page table. The final page table is a resident memory during the life cycle of the virtual machine; the polling module is responsible for polling the dirty page bit in the final page table, and synchronizing the result to the dirty page bitmap information stored in the bitmap storage space; the migration thread is responsible for notifying the virtual machine monitor of the dirty page tracking method, reading the dirty page bitmap information and sending the dirty page, and is responsible for cleaning the dirty page bitmap and notifying the virtual machine monitor to clean the dirty page bit flag in the page table. The dirty page bitmap is stored in the bitmap storage space, and each bit in the bitmap corresponds to a page of the virtual machine. 0 represents that the page of the virtual machine is not a dirty page, and 1 represents that the page of the virtual machine is a dirty page.
[0072] Figure 6 is a schematic diagram of component interaction in this embodiment, such as Figure 6As shown in the figure, the interaction process of each component is as follows: 1. When the virtual machine is created, the virtual machine monitor (hypervisor) calculates the memory size required for the last-level page table in the page table it manages according to the memory size of the virtual machine and applies for it, preferably using continuous memory for application. 2. When the virtual machine monitor establishes the GPA->HPA page table, it uses the above-applied memory as its last-level page table, and the memory address offset of the page table is calculated by the physical address page frame number (GFN) of the current virtual machine. 3. When the virtual machine starts to migrate, the migration thread notifies the virtual machine monitor to track dirty pages using polling, and the virtual machine monitor turns off the original dirty page tracking mechanism. 4. The polling module starts to poll the dirty page bits in the page table and updates the dirty page bitmap information. It can only poll the page table memory that is not a dirty page in the dirty page bitmap information. 5. The migration thread obtains the dirty page bitmap information, cleans the dirty page bitmap corresponding to the batch of memory before sending a batch of dirty page memory, and notifies the virtual machine monitor to clean the dirty page bits of the page table. 6. The migration thread iterates and sends dirty pages in a loop. 7. When the migration thread enters the last iteration, the virtual machine is paused and the polling module is waited for to complete a polling operation before obtaining the dirty page bitmap. 8. The migration thread sends the last batch of dirty page memory. 9. The migration is completed, the source virtual machine is destroyed, the polling module exits, and the virtual machine monitor releases the page table memory.
[0073] In this embodiment, when the dirty pages to be sent and the preset pause time meet the continuous iteration condition, the dirty page to be sent this time is selected from the dirty pages to be sent, and the dirty page bitmap information is updated according to the dirty page to be sent this time; the dirty page bit flag corresponding to the dirty page to be sent this time is cleared, and the dirty page to be sent this time is sent to the target migration device. Since the dirty page to be sent this time is selected from the dirty pages to be sent for dirty page transmission when the dirty pages to be sent and the preset pause time meet the continuous iteration condition, instead of transmitting all at once, the phenomenon of continuously transmitting a large amount of data and reducing the operating efficiency of the virtual machine business is avoided, and before the transmission, the dirty page bitmap information is updated according to the dirty page to be sent this time, and the dirty page bit flag corresponding to the dirty page to be sent this time is cleared, which can avoid the transmission of duplicate data when the dirty page is subsequently transmitted, thereby improving the execution efficiency of the virtual machine migration method of this embodiment.
[0074] In addition, an embodiment of the present application further proposes a storage medium, on which a virtual machine migration program is stored. When the virtual machine migration program is executed by a processor, the steps of the virtual machine migration method described above are implemented.
[0075] Reference Figure 7 , Figure 7 This is a structural block diagram of the first embodiment of the virtual machine migration device of the present application.
[0076] like Figure 7 As shown, the virtual machine migration device proposed in the embodiment of the present application includes: The information acquisition module 10 is configured to read dirty page bitmap information from the bitmap storage space, and determine the dirty page to be sent according to the dirty page bitmap information; The logic judgment module 20 is configured to pause the source virtual machine and read the dirty page bit flag in the last-level page table when the dirty page to be sent and the preset pause time meet the final iteration condition; A data updating module 30 is configured to update the dirty page bitmap information according to the dirty page bit flag to obtain current bitmap information; The data migration module 40 is configured to determine the current dirty page to be sent according to the current bitmap information, and send the current dirty page to be sent to the target migration device.
[0077] This embodiment reads dirty page bitmap information from the bitmap storage space, and determines the dirty page to be sent according to the dirty page bitmap information; when the dirty page to be sent and the preset pause time meet the final iteration condition, the source virtual machine is paused, and the dirty page bit flag in the last-level page table is read; the dirty page bitmap information is updated according to the dirty page bit flag to obtain the current bitmap information; the current dirty page to be sent is determined according to the current bitmap information, and the current dirty page to be sent is sent to the target migration device. During the virtual machine migration process, dirty page tracking is not performed using the existing method, but dirty page bitmap information is used to track dirty pages to determine the current dirty page to be sent, which will not cause the virtual machine CPU to have a page missing exception, thereby avoiding the virtual machine CPU exit phenomenon and reducing the impact on the operating efficiency of the business in the virtual machine.
[0078] In a possible implementation of this embodiment, the information acquisition module 10 is further configured to read a dirty page bit flag in the last-level page table, and update the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag.
[0079] In a possible implementation of this embodiment, the information acquisition module 10 is also configured to read dirty page bitmap information from a bitmap storage space; determine non-dirty page items based on the dirty page bitmap information; read the dirty page bit flag corresponding to the non-dirty page item in the last-level page table, and update the dirty page bitmap information in the bitmap storage space based on the dirty page bit flag.
[0080] In a possible implementation of this embodiment, the information acquisition module 10 is further configured to determine a final-level page table memory according to a memory size of the source virtual machine; and construct a final-level page table according to the final-level page table memory.
[0081] In a possible implementation of this embodiment, the information acquisition module 10 is also configured to create a kernel-mode thread; obtain dirty page flag information by polling the dirty page bit flag in the last-level page table at a preset period through the kernel-mode thread; and update the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag information.
[0082] In a possible implementation of this embodiment, the information acquisition module 10 is also configured to create a user-state thread and create a memory mapping for the user-state thread, mapping the memory space corresponding to the last-level page table to the user-state address space; based on the memory mapping, the user-state thread polls the dirty page bit flag in the last-level page table at a preset period to obtain dirty page flag information; and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
[0083] In a possible implementation of this embodiment, the information acquisition module 10 is also configured to create a polling instance in the DPU accelerator card, and create a memory mapping for the DPU accelerator card, and map the memory space and the bitmap storage space corresponding to the last-level page table to the DPU accelerator card; based on the memory mapping, the dirty page bit flag in the last-level page table is polled at a preset period through the polling instance to obtain dirty page flag information; based on the memory mapping, the dirty page bitmap information in the bitmap storage space is updated according to the dirty page flag information.
[0084] In a possible implementation of the present embodiment, the logic judgment module 20 is also configured to select the dirty page to be sent from the dirty pages to be sent when the dirty pages to be sent and the preset pause time meet the continuous iteration condition, and update the dirty page bitmap information according to the dirty pages to be sent; clear the dirty page bit flag corresponding to the dirty page to be sent, and send the dirty page to the target migration device.
[0085] In a possible implementation of this embodiment, the logic judgment module 20 is further configured to select the dirty page to be sent this time from the dirty pages to be sent according to the upper limit of a single transmission; The bitmap information corresponding to the dirty page sent this time in the dirty page bitmap information is cleared.
[0086] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present application. In specific applications, technicians in this field can make settings as needed, and the present application does not impose any limitation on this.
[0087] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present application. In practical applications, technicians in this field can select part or all of it according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0088] In addition, for technical details not fully described in this embodiment, please refer to the virtual machine migration method provided in any embodiment of the present application, and will not be repeated here.
[0089] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0090] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0091] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, 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 (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0092] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A virtual machine migration method, characterized in that: The virtual machine migration method comprises: Reading dirty page bitmap information from the bitmap storage space, and determining the dirty page to be sent according to the dirty page bitmap information; When the dirty page to be sent and the preset pause time meet the final iteration condition, pausing the source virtual machine and reading the dirty page bit flag in the last-level page table; The dirty page bitmap information is updated according to the dirty page bit flag to obtain current bitmap information; The dirty page to be sent currently is determined according to the current bitmap information, and the dirty page to be sent currently is sent to the target migration device.
2. The virtual machine migration method according to claim 1, characterized in that: The method further includes: reading dirty page bitmap information from the bitmap storage space and determining the dirty page to be sent according to the dirty page bitmap information; The dirty page bit flag in the last-level page table is read, and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag.
3. The virtual machine migration method according to claim 2, characterized in that: The step of reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Read dirty page bitmap information from the bitmap storage space; Determine a non-dirty page item according to the dirty page bitmap information; The dirty page bit flag corresponding to the non-dirty page entry in the last-level page table is read, and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag.
4. The virtual machine migration method according to claim 2, characterized in that: Before the dirty page bit flag in the last-level page table is read and the dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag, the method further includes: Determine the last-level page table memory according to the memory size of the source virtual machine; A final-level page table is constructed according to the final-level page table memory.
5. The virtual machine migration method according to claim 2, characterized in that: The step of reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a kernel-mode thread; The kernel state thread polls the dirty page bit flag in the last-level page table at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
6. The virtual machine migration method according to claim 2, characterized in that: The step of reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a user state thread, and create a memory mapping for the user state thread, mapping the memory space corresponding to the last level page table to the user state address space; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled by the user-mode thread at a preset period to obtain dirty page flag information; The dirty page bitmap information in the bitmap storage space is updated according to the dirty page bit flag information.
7. The virtual machine migration method according to claim 2, characterized in that: The step of reading the dirty page bit flag in the last-level page table and updating the dirty page bitmap information in the bitmap storage space according to the dirty page bit flag includes: Create a polling instance in the DPU accelerator card, create a memory mapping for the DPU accelerator card, and map the memory space and the bitmap storage space corresponding to the last-level page table to the DPU accelerator card; Based on the memory mapping, the dirty page bit flag in the last-level page table is polled at a preset period by the polling instance to obtain dirty page flag information; Based on the memory mapping, the dirty page bitmap information in the bitmap storage space is updated according to the dirty page flag information.
8. The virtual machine migration method according to any one of claims 1 to 7, characterized in that: After reading the dirty page bitmap information from the bitmap storage space and determining the dirty page to be sent according to the dirty page bitmap information, the method further includes: When the dirty pages to be sent and the preset pause time meet the continuous iteration condition, the dirty pages to be sent this time are selected from the dirty pages to be sent, and the dirty page bitmap information is updated according to the dirty pages to be sent this time; The dirty page bit flag corresponding to the dirty page sent this time is cleared, and the dirty page sent this time is sent to the target migration device.
9. The virtual machine migration method according to claim 8, characterized in that: The step of selecting the dirty page to be sent this time from the dirty pages to be sent, and updating the dirty page bitmap information according to the dirty page to be sent this time, includes: Selecting the dirty page to be sent this time from the dirty pages to be sent according to the upper limit of a single transmission; The bitmap information corresponding to the dirty page sent this time in the dirty page bitmap information is cleared.
10. A virtual machine migration device, characterized in that: The virtual machine migration device includes: a processor, a memory, and a virtual machine migration program stored in the memory and executable on the processor. When the virtual machine migration program is executed by the processor, the steps of the virtual machine migration method according to any one of claims 1 to 9 are implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a virtual machine migration program, and when the virtual machine migration program is executed, the steps of the virtual machine migration method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Virtual machine migration method and device, electronic equipment and storage medium
CN111638938A
Virtual machine dirty page obtaining method and device, electronic equipment and readable storage medium
CN112099905A
Virtual machine live migration method and device, electronic equipment and storage medium
CN115048183A
PML-based virtual machine page table tracking method and system
CN115576643A
PML-based virtual machine page migration method and system
CN115576644A
Cited By
Virtual machine merging and dirty marking method, electronic equipment and storage medium
CN122691724A
