Virtual machine live migration method and device, electronic equipment, storage medium and computer program product
By identifying duplicate pages between virtual machines and transferring only the page type information, the problem of memory usage expansion during virtual machine live migration is solved, achieving a more efficient migration process.
Patent Information
- Application Number
- CN202511262392.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-05
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-09-05
AI Technical Summary
In Linux kernel virtualization technology, during live migration of virtual machines, multiple copies of copy-on-write shared pages cause memory usage to expand, leading to migration failures, increased network traffic, and extended migration time.
By identifying duplicate pages between different virtual machines and transferring only page type information rather than page content during migration, the page type is used for memory mapping and configuration on the destination host to reduce the amount of duplicate page data.
It effectively reduces memory usage during the migration process, avoids migration failures and increased network traffic, and shortens migration time.
Smart Images

Figure CN120762819A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtualization technology, and in particular to a virtual machine hot migration method, device, electronic device, storage medium and computer program product. Background Art
[0002] In Linux kernel virtualization technology, live migration is widely used to move virtual machines (VMs) from one physical machine to another. Live migration facilitates workload consolidation, load balancing, fault management, and energy conservation. Multiple VMs can coexist on a single physical machine while maintaining functional isolation, thereby improving data center resource efficiency.
[0003] Copy-on-write (COW) shared pages share the same pages within different virtual machines and between multiple virtual machines on the same physical host. Therefore, when migrating a virtual machine to the same destination, each shared page is replicated multiple times on the destination host. This increased memory usage during the migration process can lead to problems such as migration failures, increased network traffic, and extended migration times. Summary of the Invention
[0004] Embodiments of the present application provide a virtual machine hot migration method, device, electronic device, storage medium, and computer program product.
[0005] The technical solution of the embodiment of the present application is implemented as follows: The present invention provides a method for hot migration of a virtual machine, including: During migration of the current virtual page, determining a page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to the migrated virtual page; wherein the page type includes: duplicate pages between different virtual machines; Based on the page type, relevant information of the current virtual page is migrated to the destination host; wherein the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0006] In the above solution, the first related attribute includes one or more of the following: a first physical frame number and a first virtual page number; the second related attribute includes one or more of the following: a second physical frame number and a second virtual page number; Determining the page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to the migrated virtual page includes: Matching the first virtual page number with each second virtual page number in the first preset information set, and matching the first physical frame number with each second physical frame number in the first preset information set, to determine a first matching result; The first matching result is used to indicate whether the first virtual page number matches any second virtual page number, and whether the first physical frame number matches any second physical frame number; the first preset information set is used to store one or more of the second physical frame number and the second virtual page number corresponding to the migrated virtual page; Based on the first matching result and the modified page number during the migration process, the page type of the current virtual page is determined.
[0007] In the above solution, based on the first matching result and the modified page number during the migration process, the page type of the current virtual page is determined, including any one of the following: If the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number does not match any second physical frame number, determining that the page type of the current virtual page is a unique page; If the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number matches any second physical frame number, determining that the page type of the current virtual page is a duplicate page; If the first matching result indicates that the first virtual page number matches any second virtual page number, and the first virtual page number matches the modified page number, then the page type of the current virtual page is determined to be a dirty page.
[0008] In the above scheme, the information about the current virtual page is migrated to the destination host based on the page type, including any of the following: If the current virtual page is a unique page or a dirty page, determining the page content, page type, and first physical frame number corresponding to the current virtual page as relevant information, and migrating the relevant information to the destination host; If the current virtual page is a duplicate page, the page type and the first physical frame number corresponding to the current virtual page are determined as relevant information, and the relevant information is migrated to the destination host.
[0009] The present application also provides a method for hot migration of a virtual machine, which is applied to a destination host and includes: Receiving relevant information about a current virtual page migrated by a source host; wherein the relevant information includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; and the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page; Based on the relevant information, complete the configuration of the virtual machine corresponding to the current virtual page.
[0010] In the above solution, based on the relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including: If the page type is a unique page, the page content in the relevant information is written into a preset file, and the write location, page type, and first physical frame number corresponding to the page content are stored in a second preset information set; wherein the second preset information set is used to store one or more of the first physical frame number, write location, and page type corresponding to the received virtual page; Copy the page content in the preset file to the corresponding virtual machine memory.
[0011] In the above solution, based on the relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including: If the page type is a repeated page, searching the second preset information set for a corresponding target write position based on the first physical frame number in the relevant information; For the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the location indicated by the target write location in the preset file.
[0012] In the above solution, based on the relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including: If the page type is a dirty page, the page content in the relevant information is copied to the corresponding virtual machine memory.
[0013] In the above solution, the method further includes: After each pre-copy round is completed, for the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the position indicated by the target write position in the preset file through busy waiting.
[0014] The embodiment of the present application further provides a virtual machine hot migration device, which is applied to a source host and includes: a determination unit configured to determine, during migration of the current virtual page, a page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to the migrated virtual page; wherein the page type includes: a duplicate page between different virtual machines; The sending unit is used to migrate the relevant information of the current virtual page to the destination host based on the page type; wherein the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0015] The embodiment of the present application further provides a virtual machine hot migration device, which is applied to a destination host and includes: a receiving unit, configured to receive relevant information about a current virtual page migrated by a source host; wherein the relevant information includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; and the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page; The configuration unit is used to complete the configuration of the virtual machine corresponding to the current virtual page based on the relevant information.
[0016] An embodiment of the present application also provides an electronic device, including a first memory and a first processor, wherein the first memory stores a computer program that can be run on the first processor, and when the first processor executes the computer program, the steps in the method on the source host side are implemented.
[0017] An embodiment of the present application also provides an electronic device, including a second memory and a second processor, wherein the second memory stores a computer program that can be run on the second processor, and when the second processor executes the computer program, the steps in the method on the destination host side are implemented.
[0018] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a first processor, the steps in the method on the source host side are implemented.
[0019] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by the second processor, the steps in the method on the destination host side are implemented.
[0020] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps in the method on the source host side when executed by a first processor.
[0021] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps in the method on the destination host side when executed by the second processor.
[0022] In the embodiment of the present application, in the process of migrating the current virtual page, the page type of the current virtual page is determined based on the first related attribute corresponding to the current virtual page and the second related attribute corresponding to the migrated virtual page; wherein the page type includes: repeated pages between different virtual machines; based on the page type, the related information of the current virtual page is migrated to the destination host; wherein the related information includes the page type; the related information when the page type is a repeated page is different from the related information when the page type is a non-repeated page. In this way, since the related information of the repeated pages between different virtual machines does not include page content, the data amount of the related information of the repeated pages is small, and the memory occupation in the migration process is greatly reduced, solving the problems of migration failure, traffic increase and migration time extension caused by memory occupation. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 Flowchart of the virtual machine live migration method provided by the embodiment of the present application Figure 1 ; Figure 2 Effect diagram of the virtual machine live migration method provided by the embodiment of the present application Figure 1 ; Figure 3 Flowchart of the virtual machine live migration method provided by the embodiment of the present application Figure 2 ; Figure 4 Flowchart of the virtual machine live migration method provided by the embodiment of the present application Figure 3 ; Figure 5 Flowchart of the virtual machine live migration method provided by the embodiment of the present application Figure 4 ; Figure 6 Flowchart of the virtual machine live migration method provided by the embodiment of the present application Figure 5 ; Figure 7 Interaction diagram of the virtual machine live migration method provided by the embodiment of the present application Figure 8 Structure diagram of the virtual machine live migration device provided by the embodiment of the present application Figure 1 ; Figure 9 Hardware entity of the electronic device provided by the embodiment of the present application Figure 1 ; Figure 10 Structure diagram of the virtual machine live migration device provided by the embodiment of the present application Figure 2 ; Figure 11 Hardware entity of the electronic device provided by the embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions of this application are further elaborated in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0025] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0026] If similar descriptions of "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0028] This application embodiment provides a method for hot migration of virtual machines. Figure 1 , which is a flow diagram of the virtual machine hot migration method provided in the embodiment of the present application Figure 1 , will combine Figure 1 The steps shown are explained: S101 . During migration of a current virtual page, determine the page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to a migrated virtual page.
[0029] In an embodiment of the present application, the source host may include multiple virtual hosts, each of which may correspond to multiple virtual pages. Duplicate pages may exist between different virtual hosts, i.e., COW shared pages. When migrating each current virtual page of each virtual host, a first relevant attribute of the current virtual page may be determined, the first relevant attribute may be matched with a second relevant attribute corresponding to the migrated virtual page, and the page type corresponding to the current virtual page may be determined based on whether the first relevant attribute and the second relevant attribute have the same attribute.
[0030] Page types include: unique page, duplicate page, and dirty page. A unique page is a virtual page that has not yet been migrated; a duplicate page is a virtual page that has already been transferred; and a dirty page is a virtual page that was modified during the pre-copy migration process and needs to be retransmitted.
[0031] The first related attribute may include one or more of the following: a first physical frame number and a first virtual page number corresponding to the current virtual page. The second related attribute may include one or more of the following: a second physical frame number and a second virtual page number corresponding to the migrated virtual page. For duplicate pages between different virtual machines, the physical frame numbers are the same.
[0032] S102. Migrate relevant information of the current virtual page to a destination host based on the page type; wherein the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0033] In an embodiment of the present application, the source host can determine the relevant information of the current virtual page based on the page type corresponding to the current virtual page, and transmit the relevant information of the current virtual page to the destination host. The relevant information determined for the duplicate page does not include the corresponding page content, but includes the corresponding first physical frame number and page type. The relevant information of other page types includes the corresponding page content, first physical frame number, and page type.
[0034] This embodiment of the present application provides a virtual machine live migration method, featuring a sharing-aware live migration technology that preserves pre-existing COW shared pages (duplicate pages) when migrating multiple virtual machines to the same destination host. The core concept is to identify virtual pages mapped to the same physical page on the source host and map them to the same physical page at the destination. This eliminates the risk of migration failure due to memory expansion and reduces overall migration time and network traffic overhead.
[0035] In an embodiment of the present application, during the migration of the current virtual page, the page type of the current virtual page is determined based on the first relevant attribute corresponding to the current virtual page and the second relevant attribute corresponding to the migrated virtual page; wherein the page type includes: duplicate pages between different virtual machines; based on the page type, the relevant information of the current virtual page is migrated to the destination host; wherein the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page. In this way, since the relevant information for duplicate pages between different virtual machines does not include the page content, the data volume of the relevant information for the duplicate pages is small, and thus the memory usage during the migration process is greatly reduced, solving the problems of migration failure, increased traffic, and extended migration time caused by memory usage.
[0036] The virtual machine hot migration method provided by the embodiment of the present application can retain all pre-existing COW shared pages when concurrently migrating coexisting virtual machines. Regardless of the underlying page sharing mechanism, multiple virtual pages mapped by COW shared pages will be mapped to the same physical frame number in physical memory. The source host will check the first physical frame number of each current virtual page being transferred, identify whether the second physical frame number of the migrated virtual page on the source host matches, and avoid transferring duplicate pages to the target host multiple times. Figure 2 As shown, the source host includes virtual machines VM-1, VM-2, and VM-n. The source host categorizes the virtual pages of each virtual machine into unique, duplicate, and dirty pages. It then transfers the corresponding information to the target host based on the page type. Duplicate pages are not retransmitted. At the target node, the relevant information for each virtual page is received and mapped into the memory of the corresponding virtual machine.
[0037] See also Figure 3 , which is a flow diagram of the virtual machine hot migration method provided in the embodiment of the present application Figure 2 , Figure 1 S101 in the above example can also be realized by S201 to S202, which will be combined with Figure 3 The steps shown are explained: S201 : Match a first virtual page number with each second virtual page number in a first preset information set, match a first physical frame number with each second physical frame number in the first preset information set, and determine a first matching result.
[0038] In an embodiment of the present application, the first related attributes include one or more of the following: a first physical frame number and a first virtual page number; the second related attributes include one or more of the following: a second physical frame number and a second virtual page number. The first preset information set is used to store one or more of the second physical frame number and the second virtual page number corresponding to the migrated virtual page. The source host can determine the first physical frame number and the first virtual page number of the current virtual page, and match the first virtual page number with each second virtual page number in the first preset information set, and match the first physical frame number with each second physical frame number in the first preset information set to determine a first matching result. The first matching result is used to characterize whether the first virtual page number matches any second virtual page number, and whether the first physical frame number matches any second physical frame number.
[0039] The first physical frame number may be the physical frame number (PFN) of the current virtual page. A physical frame number is a unique number assigned to a physical memory page in operating system memory management, used to identify and track consecutive physical memory blocks. The first virtual page number may be a virtual page number (VPN), a core concept in operating system memory management used to map virtual addresses to physical addresses in the paging mechanism.
[0040] S202: Determine the page type of the current virtual page based on the first matching result and the modified page number during the migration process.
[0041] In an embodiment of the present application, the source host can determine the page type based on whether the first physical frame number and the first virtual page number have corresponding matching second physical frame numbers and second virtual page numbers in the first preset information set, and whether the obtained modified page number matches the first virtual page number. The modified page number is the VPN of the virtual page that was modified during the previous page copy process and needs to be retransmitted.
[0042] In the embodiment of the present application, if the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number does not match any second physical frame number, then the page type of the current virtual page is determined to be a unique page.
[0043] In the embodiment of the present application, if the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number matches any second physical frame number, then the page type of the current virtual page is determined to be a duplicate page.
[0044] In the embodiment of the present application, if the first matching result indicates that the first virtual page number matches any second virtual page number, and the first virtual page number matches the modified page number, then the page type of the current virtual page is determined to be a dirty page.
[0045] In an embodiment of the present application, the source host determines the first physical frame number and first virtual page number of the current virtual page. The first physical frame number and first virtual page number are matched with the second physical frame number and second virtual page number stored in a hash table (a first preset information set). The source host Linux kernel exposes the first physical frame number and first virtual page number to user space via a page mapping table (pagemap). User space processes can find the PFN of a specific VPN. Each pagemap entry contains 64 bits of information and is indexed by the VPN, with the first 56 bits representing the PFN. The source host uses the pagemap to accurately retrieve the PFN of each VPN, thereby determining the page type.
[0046] The source host can determine whether the page type of the current virtual page is one of the following three types based on whether the PFN and VPN of the current virtual page exist in the hash table (the first preset information set): Unique Page: A virtual page that has not yet been transferred is considered a unique page. In this case, the corresponding PFN and VPN are not in the hash table. Therefore, before the virtual page content is sent, the PFN and VPN of the virtual page are inserted into the hash table.
[0047] Duplicate Page: A transferred virtual page is considered a duplicate page. In this case, the PFN exists in the hash table, but the VPN does not. Therefore, before sending the PFN, only the VPN for that virtual page is inserted into the hash table.
[0048] Dirty Pages: A virtual page that needs to be retransmitted because it was modified in a previous pre-copy round is called a dirty page. The PFN may or may not be present in the hash table, but the VPN is guaranteed to be present. In this case, only the PFN is inserted into the hash table before the virtual page contents are sent.
[0049] In an embodiment of the present application, if the current virtual page is a unique page or a dirty page, the page content, page type, and first physical frame number corresponding to the current virtual page are determined as relevant information, and the relevant information is migrated to the destination host. If the current virtual page is a duplicate page, the page type and first physical frame number corresponding to the current virtual page are determined as relevant information, and the relevant information is migrated to the destination host. In this way, the corresponding page content of the duplicate page is not transmitted, which reduces the amount of data related to the duplicate page, thereby solving a series of problems caused by excessive memory usage.
[0050] In an embodiment of the present application, the first virtual page number is matched with each second virtual page number in the first preset information set, and the first physical frame number is matched with each second physical frame number in the first preset information set to determine a first matching result. Based on the first matching result and the modified page number during the migration process, the page type of the current virtual page is determined. In this way, the first physical frame number, the first virtual page number, the second physical frame number and the second virtual page number in the first preset information set are matched to determine the page type corresponding to the current virtual page. When it is determined to be a duplicate page, the corresponding page content is not sent, thereby reducing the amount of data of the relevant information of the duplicate page, thereby solving a series of problems caused by the extra memory usage.
[0051] See also Figure 4 , which is a flow diagram of the virtual machine hot migration method provided in the embodiment of the present application Figure 3 , will combine Figure 4 The steps shown are explained: S301. Receive relevant information of the current virtual page migrated by the source host; wherein the relevant information includes the page type corresponding to the current virtual page; the page type is determined by the source host based on a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0052] In an embodiment of the present application, a destination host receives information about a current virtual page transmitted from a source host. The information includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a match between a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes duplicate pages between different virtual machines; and the information about a duplicate page differs from the information about a non-duplicate page.
[0053] Among them, page types include: unique page, duplicate page and dirty page.
[0054] S302: Based on the relevant information, complete the configuration of the virtual machine corresponding to the current virtual page.
[0055] In an embodiment of the present application, the destination host can directly copy the page content into the memory of the corresponding virtual machine based on the page type in the relevant information of the current virtual page, or map the virtual address of the current virtual page to the storage location corresponding to the first physical frame number for the virtual machine of the current virtual page according to the first physical frame number in the relevant information, or directly copy the page content into the memory of the corresponding virtual machine.
[0056] In an embodiment of the present application, the virtual machine hot migration method can be operated in two ways, depending on whether the relevant information received from the source node includes page content. If complete relevant information (including page content, page type, and first physical frame number) is received, its page content is copied to the corresponding virtual machine memory, and the first physical frame number is recorded for future reference. On the other hand, if the relevant information only includes the first physical frame number and page type, the corresponding virtual page is mapped to the previously received physical page with the same first physical frame number.
[0057] In an embodiment of the present application, relevant information of the current virtual page migrated by the source host is received; wherein, the relevant information includes the page type corresponding to the current virtual page; the page type is determined by the source host based on the first relevant attribute corresponding to the current virtual page and the second relevant attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page. Based on the relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed. In this way, since the relevant information for duplicate pages between different virtual machines does not include the page content, the data volume of the relevant information for duplicate pages is relatively small, and thus the memory usage during the migration process is greatly reduced, solving the problems of migration failure, increased traffic, and extended migration time caused by memory usage.
[0058] See also Figure 5 , which is a flow diagram of the virtual machine hot migration method provided in the embodiment of the present application Figure 4 , Figure 4 S302 in the above can also be realized by S401 to S402, which will be combined with Figure 5 The steps shown are explained: S401: If the page type is a unique page, write the page content in the relevant information into a preset file, and store the write position, page type, and first physical frame number corresponding to the page content in a second preset information set.
[0059] In an embodiment of the present application, after receiving the relevant information, if the destination host detects that the page type is a unique page, the page content in the relevant information is written into a preset file, and the correspondence between the write location of the page content, the page type, and the first physical frame number can be stored in a second preset information set. The second preset information set is used to store one or more of the first physical frame number, write location, and page type corresponding to the received virtual page.
[0060] In an embodiment of the present application, a memory backend file (preset file) can be set on the destination host. Each received information about the current virtual page is memory-mapped using the memory-mapped file (mmap) system call. The destination host can set two important flags: shared mapping (MAP_SHARED) and private mapping (MAP_PRIVATE). The MAP_SHARED flag causes any writes to the mapped virtual address to be written back to the backend file. On the other hand, MAP_PRIVATE causes COW mapping, meaning any write to the mapped virtual address allocates a new private page for the process before the write is committed, ensuring that the write is not transferred to the backend file. When information about a unique page is received, the unique page can be configured with the MAP_SHARED flag. The page contents of the received information are then written to the backend file, and the mmap configuration for that page is changed to MAP_PRIVATE to enable COW mapping for any future repetitions of the same page. The first physical frame number of the unique page and its corresponding mmap offset (write location) are also recorded in a hash table (the second preset information set).
[0061] S402: Copy the page content in the preset file into the corresponding virtual machine memory.
[0062] In the embodiment of the present application, the destination host can directly copy the page content in the relevant information of the unique page to the memory of the corresponding virtual machine.
[0063] In an embodiment of the present application, if the page type is a unique page, the page content in the relevant information is written into a preset file, and the write position, page type, and first physical frame number corresponding to the page content are stored in a second preset information set; wherein the second preset information set is used to store one or more of the first physical frame number, write position, and page type corresponding to the received virtual page; and the page content in the preset file is copied into the corresponding virtual machine memory. In this way, when facing a unique page, the corresponding write position, page type, and first physical frame number are stored in the second preset information set. After receiving a duplicate page, the mapping position of the virtual address can be determined in the preset file based on the first physical frame number corresponding to the duplicate page, thereby achieving smooth migration of the duplicate page without obtaining the page content corresponding to the duplicate page.
[0064] See also Figure 6 , which is a flow diagram of the virtual machine hot migration method provided in the embodiment of the present application Figure 5 , Figure 4S302 in the above can also be realized through S403 to S404, which will be combined with Figure 6 The steps shown are explained: S403: If the page type is a repeated page, query the corresponding target writing position in the second preset information set based on the first physical frame number in the relevant information.
[0065] In an embodiment of the present application, the second preset information set is used to store one or more of the first physical frame number, write location, and page type corresponding to the received virtual page. In this way, the first physical frame number in the relevant information of the duplicate page can be matched with each first physical frame number in the second preset information set to determine the target write location corresponding to the first physical frame number that matches the first physical frame number of the duplicate page in the second preset information set.
[0066] The target write position may be the mmap offset of the page content of the same physical frame number corresponding to the repeated page in the preset file.
[0067] S404 : For the virtual machine corresponding to the current virtual page, map the virtual address of the current virtual page to the location indicated by the target write location in the preset file.
[0068] In the embodiment of the present application, the destination host can map the virtual address of the current virtual page to the location indicated by the target write location in the preset file for the virtual machine corresponding to the current virtual page.
[0069] In an embodiment of the present application, if the page type is a dirty page, the page content in the relevant information is copied to the corresponding virtual machine memory.
[0070] In this embodiment of the present application, when information about a duplicate page is received, the first physical frame number is used as a key to search the second preset information set to retrieve the corresponding mmap offset (destination write location), and the virtual address is mapped to the backend file using the MAP_PRIVATE flag. If information about a dirty page is received, any mmap operation is skipped and the entire page content is directly copied from the network to the VM's address space.
[0071] In the embodiment of the present application, after each pre-copy round is completed, for the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the location indicated by the target write location in the preset file through busy waiting.
[0072] In an embodiment of the present application, ideally, for a given PFN, information about a unique page (including its page content and PFN) should arrive at the destination host before information about any duplicate pages (including only the PFN). However, during the migration of multiple virtual machines, information about a VM's duplicate pages may sometimes arrive before information about the unique pages (e.g., VMx's PFN arrives before VMy's unique page content). However, before the unique page is mapped and its page content is written to the backend file, the duplicate pages cannot be COW mapped. To address this issue, multi-VM synchronization is designed as follows: At the end of each pre-copy round, all pending VMx duplicate pages that depend on VMy can be updated through a busy wait to prevent outdated mapping entries. The busy wait at the end of the last pre-copy round can extend the downtime of the virtual machine. To mitigate this delay, an additional real-time pre-copy round without a busy wait can be included before the downtime phase.
[0073] In an embodiment of the present application, if the page type is a duplicate page, the corresponding target write position is queried in the second preset information set based on the first physical frame number in the relevant information. For the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the position indicated by the target write position in the preset file. Since the relevant information of the duplicate page transmitted by the source host does not include the corresponding page content, the virtual address of the virtual machine of the duplicate page is mapped by the target write position, which can also realize the migration of duplicate pages with less transmitted data, and solve the problems of migration failure, increased traffic and extended migration time caused by memory occupation.
[0074] See also Figure 7 , which is an interactive diagram of the virtual machine live migration method provided in an embodiment of the present application, will be described in conjunction with the steps: S501 : During migration of a current virtual page, the source host determines the page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to a migrated virtual page.
[0075] In the embodiment of the present application, the implementation steps of S501 can refer to S101 and are not described in detail here.
[0076] S502. The source host migrates relevant information of the current virtual page to the destination host based on the page type; the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0077] In the embodiment of the present application, the implementation steps of S502 can refer to S102 and are not described in detail here.
[0078] S503: The destination host completes the configuration of the virtual machine corresponding to the current virtual page based on the relevant information.
[0079] In the embodiment of the present application, the implementation steps of S503 can refer to S302 and are not described in detail here.
[0080] See also Figure 8 , which is a schematic diagram of the structure of the virtual machine hot migration device provided in the embodiment of the present application Figure 1 .
[0081] The embodiment of the present application further provides a virtual machine live migration device 600 , which is applied to a source host and includes: a determining unit 601 and a sending unit 602 .
[0082] The determining unit 601 is configured to determine the page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to the migrated virtual page during the migration of the current virtual page; wherein the page type includes: a duplicate page between different virtual machines; The sending unit 602 is used to migrate the relevant information of the current virtual page to the destination host based on the page type; wherein the relevant information includes the page type; the relevant information when the page type is a duplicate page is different from the relevant information when the page type is a non-duplicate page.
[0083] In the embodiment of the present application, the first related attribute includes one or more of the following: a first physical frame number and a first virtual page number; the second related attribute includes one or more of the following: a second physical frame number and a second virtual page number; The determining unit 601 in the virtual machine live migration apparatus 600 is configured to match the first virtual page number with each second virtual page number in the first preset information set, and match the first physical frame number with each second physical frame number in the first preset information set, to determine a first matching result; The first matching result is used to indicate whether the first virtual page number matches any second virtual page number, and whether the first physical frame number matches any second physical frame number; the first preset information set is used to store one or more of the second physical frame number and the second virtual page number corresponding to the migrated virtual page; Based on the first matching result and the modified page number during the migration process, the page type of the current virtual page is determined.
[0084] In the embodiment of the present application, the determining unit 601 in the virtual machine live migration apparatus 600 is configured to determine that the page type of the current virtual page is a unique page if the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number does not match any second physical frame number; If the first matching result indicates that the first virtual page number does not match any second virtual page number, and the first physical frame number matches any second physical frame number, determining that the page type of the current virtual page is a duplicate page; If the first matching result indicates that the first virtual page number matches any second virtual page number, and the first virtual page number matches the modified page number, then the page type of the current virtual page is determined to be a dirty page.
[0085] In the embodiment of the present application, the sending unit 602 in the virtual machine live migration device 600 is configured to determine, if the current virtual page is a unique page or a dirty page, the page content, page type, and first physical frame number corresponding to the current virtual page as relevant information, and migrate the relevant information to the destination host; If the current virtual page is a duplicate page, the page type and the first physical frame number corresponding to the current virtual page are determined as relevant information, and the relevant information is migrated to the destination host.
[0086] It should be noted that in the embodiments of the present application, if the aforementioned virtual machine live migration method is implemented in the form of a software functional 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 embodiments of the present application, or the portion that contributes to the relevant technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for enabling a virtual machine live migration device (which can be a personal computer, etc.) to execute all or part of the methods of the various embodiments of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a magnetic disk, or an optical disk. As such, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0087] Correspondingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by the first processor, the steps in the method of the virtual machine hot migration device 600 are implemented.
[0088] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0089] It should be noted that Figure 9 A hardware entity diagram of an electronic device provided in an embodiment of the present application Figure 1 ,like Figure 9As shown, an embodiment of the present application provides an electronic device 700, including a first memory 702 and a first processor 701. The first memory 702 stores a computer program that can be run on the first processor 701. When the first processor 701 executes the program, the steps in the above method are implemented, wherein; The first processor 701 generally controls the overall operations of the electronic device 700 .
[0090] The first memory 702 is configured to store instructions and applications executable by the first processor 701, and can also cache data to be processed or processed by the first processor 701 and various modules in the electronic device 700 (for example, image data, audio data, voice communication data and video communication data), and can be implemented by flash memory (FLASH) or random access memory (RAM).
[0091] Correspondingly, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the first processor 701 of the electronic device 700 to complete the steps in the method on the side of the virtual machine hot migration device 600.
[0092] See also Figure 10 , which is a schematic diagram of the structure of the virtual machine hot migration device provided in the embodiment of the present application Figure 2 .
[0093] The embodiment of the present application further provides a virtual machine hot migration device 800 , which is applied to a destination host and includes: a receiving unit 801 and a configuration unit 802 .
[0094] A receiving unit 801 is configured to receive information related to a current virtual page migrated by a source host; the information related to the current virtual page includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; the information related to a duplicate page is different from the information related to a non-duplicate page; The configuration unit 802 is configured to complete the configuration of the virtual machine corresponding to the current virtual page based on the relevant information.
[0095] In the embodiment of the present application, the configuration unit 802 in the virtual machine live migration device 800 is configured to, if the page type is a unique page, write the page content in the relevant information into a preset file, and store the write location, page type, and first physical frame number corresponding to the page content in a second preset information set; wherein the second preset information set is configured to store one or more of the first physical frame number, write location, and page type corresponding to the received virtual page; Copy the page content in the preset file to the corresponding virtual machine memory.
[0096] In the embodiment of the present application, the configuration unit 802 in the virtual machine live migration device 800 is configured to query the corresponding target write location in the second preset information set based on the first physical frame number in the relevant information if the page type is a duplicate page; For the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the location indicated by the target write location in the preset file.
[0097] In the embodiment of the present application, the configuration unit 802 in the virtual machine live migration device 800 is used to copy the page content in the relevant information to the corresponding virtual machine memory if the page type is a dirty page.
[0098] In an embodiment of the present application, the configuration unit 802 in the virtual machine hot migration device 800 is used to map the virtual address of the current virtual page to the location indicated by the target write location in the preset file by busy waiting for the virtual machine corresponding to the current virtual page after each pre-copy round.
[0099] Correspondingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by the second processor, the steps in the method of the virtual machine hot migration device 800 are implemented.
[0100] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0101] It should be noted that Figure 11 A hardware entity diagram of an electronic device provided in an embodiment of the present application Figure 2 ,like Figure 11 As shown, an embodiment of the present application provides an electronic device 900, including a second memory 902 and a second processor 901, wherein the second memory 902 stores a computer program that can be run on the second processor 901, and the second processor 901 implements the steps in the above method when executing the program, wherein; The second processor 901 generally controls the overall operations of the electronic device 900 .
[0102] The second memory 902 is configured to store instructions and applications executable by the second processor 901, and can also cache data to be processed or processed by the second processor 901 and various modules in the electronic device 900 (for example, image data, audio data, voice communication data and video communication data), which can be implemented by flash memory (FLASH) or random access memory (RAM).
[0103] Correspondingly, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the second processor 901 of the electronic device 900 to complete the steps in the method on the side of the virtual machine hot migration device 800.
[0104] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in one or more embodiments of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0105] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0106] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0107] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0108] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0109] Those skilled in the art will understand that all or part of the steps of the above-mentioned method embodiments 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 embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), magnetic disks or optical disks.
[0110] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software functional 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, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or 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, ROMs, magnetic disks, or optical disks.
[0111] The above is only an implementation method of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the scope of protection of the present application.
Claims
1. A method for hot migration of a virtual machine, characterized in that: Applied to the source host, including: During migration of a current virtual page, determining a page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to a migrated virtual page; wherein the page type includes: duplicate pages between different virtual machines; Based on the page type, the relevant information of the current virtual page is migrated to the destination host; wherein the relevant information includes the page type; the relevant information when the page type is the duplicate page is different from the relevant information when the page type is the non-duplicate page.
2. The virtual machine live migration method according to claim 1, wherein: The first related attributes include one or more of the following: a first physical frame number and a first virtual page number; the second related attributes include one or more of the following: a second physical frame number and a second virtual page number; The determining the page type of the current virtual page based on the first related attribute corresponding to the current virtual page and the second related attribute corresponding to the migrated virtual page includes: matching the first virtual page number with each of the second virtual page numbers in the first preset information set, and matching the first physical frame number with each of the second physical frame numbers in the first preset information set, to determine a first matching result; The first matching result is used to indicate whether the first virtual page number matches any of the second virtual page numbers, and whether the first physical frame number matches any of the second physical frame numbers; the first preset information set is used to store one or more of the second physical frame number and the second virtual page number corresponding to the migrated virtual page; The page type of the current virtual page is determined based on the first matching result and the modified page number during the migration process.
3. The virtual machine hot migration method according to claim 2, characterized in that: The determining of the page type of the current virtual page based on the first matching result and the modified page number during the migration process includes any one of the following: If the first matching result indicates that the first virtual page number does not match any of the second virtual page numbers, and the first physical frame number does not match any of the second physical frame numbers, determining that the page type of the current virtual page is a unique page; If the first matching result indicates that the first virtual page number does not match any of the second virtual page numbers, and the first physical frame number matches any of the second physical frame numbers, determining that the page type of the current virtual page is the duplicate page; If the first matching result indicates that the first virtual page number matches any of the second virtual page numbers, and the first virtual page number matches the modified page number, then the page type of the current virtual page is determined to be a dirty page.
4. The method for hot migration of a virtual machine according to claim 3, wherein: Migrating the relevant information of the current virtual page to the destination host based on the page type includes any one of the following: If the current virtual page is the only page or the dirty page, determining the page content, the page type, and the first physical frame number corresponding to the current virtual page as the relevant information, and migrating the relevant information to the destination host; If the current virtual page is the duplicate page, the page type and the first physical frame number corresponding to the current virtual page are determined as the relevant information, and the relevant information is migrated to the destination host.
5. A virtual machine hot migration method, characterized in that: Applied to the destination host, including: Receiving relevant information of a current virtual page migrated by a source host; wherein the relevant information includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes: a duplicate page between different virtual machines; the relevant information when the page type is the duplicate page is different from the relevant information when the page type is the non-duplicate page; Based on the relevant information, configuration of the virtual machine corresponding to the current virtual page is completed.
6. The virtual machine live migration method according to claim 5, characterized in that: The completing the configuration of the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is a unique page, writing the page content in the relevant information into a preset file, and storing the write location, the page type, and the first physical frame number corresponding to the page content in a second preset information set; wherein the second preset information set is used to store one or more of the first physical frame number, the write location, and the page type corresponding to the received virtual page; The page content in the preset file is copied to the corresponding virtual machine memory.
7. The virtual machine live migration method according to claim 5, characterized in that: The completing the configuration of the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is the repeated page, searching the second preset information set for a corresponding target writing position based on the first physical frame number in the relevant information; For the virtual machine corresponding to the current virtual page, the virtual address of the current virtual page is mapped to the location indicated by the target write location in the preset file.
8. The method for hot migration of a virtual machine according to claim 5, wherein: The completing the configuration of the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is a dirty page, the page content in the relevant information is copied to the corresponding virtual machine memory.
9. The virtual machine live migration method according to claim 7, wherein: The method further comprises: After each pre-copy round is completed, for the current virtual page corresponding to the virtual machine, the virtual address of the current virtual page is mapped to the position indicated by the target write position in the preset file through busy waiting.
10. A virtual machine hot migration device, characterized in that: Applied to the source host, including: a determining unit configured to determine, during a migration process for a current virtual page, a page type of the current virtual page based on a first related attribute corresponding to the current virtual page and a second related attribute corresponding to a migrated virtual page; wherein the page type includes: a duplicate page between different virtual machines; A sending unit is used to migrate the relevant information of the current virtual page to the destination host based on the page type; wherein the relevant information includes the page type; the relevant information when the page type is the duplicate page is different from the relevant information when the page type is the non-duplicate page.
11. A virtual machine hot migration device, characterized in that: Applied to the destination host, including: A receiving unit, configured to receive relevant information of a current virtual page migrated by a source host; wherein the relevant information includes a page type corresponding to the current virtual page; the page type is determined by the source host based on a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to the migrated virtual page; the page type includes: duplicate pages between different virtual machines; the relevant information when the page type is the duplicate page is different from the relevant information when the page type is the non-duplicate page; A configuration unit is configured to complete the configuration of the virtual machine corresponding to the current virtual page based on the relevant information.
12. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the method implements the steps of any one of claims 1 to 4, or implements the steps of any one of claims 5 to 9.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 4, or implements the steps of the method according to any one of claims 5 to 9.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 4, or implements the steps of the method according to any one of claims 5 to 9.
Citation Information
Patent Citations
Thermal migration method and device and electronic equipment
CN112286635A
Virtual machine live migration method and device, electronic equipment and storage medium
CN113051024A
Heterogeneous memory page migration device and method and readable storage medium
CN120371550A
Systems and methods for memory deduplication by destination host in virtual machine live migration
US20150052323A1
Method, apparatus, and system for implementing hot migration of virtual machine
US20150261581A1