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

Figure CN120762819B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtualization technology, and in particular to a virtual machine hot migration method, apparatus, electronic device, storage medium, and computer program product. Background Technology
[0002] In the field of 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 saving. Multiple VMs can coexist on a single physical machine while maintaining their functional isolation, thereby improving the resource utilization efficiency of the data center.
[0003] Copy-on-Write (COW) shared pages involve sharing the same pages within different virtual machines or among multiple virtual machines located on the same physical machine. Therefore, when migrating virtual machines to the same destination, each shared page is copied multiple times on the destination host. This expansion of virtual machine memory usage during migration can lead to problems such as migration failures, increased network traffic, and extended migration times. Summary of the Invention
[0004] This application provides a virtual machine hot migration method, apparatus, electronic device, storage medium, and computer program product.
[0005] The technical solution of this application embodiment is implemented as follows:
[0006] This application provides a method for hot migration of virtual machines, including:
[0007] 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;
[0008] Based on the page type, the relevant information of the current virtual page is migrated to the destination host; 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.
[0009] In the above scheme, the first relevant attribute includes one or more of the following: the first physical frame number and the first virtual page number; the second relevant attribute includes one or more of the following: the second physical frame number and the second virtual page number;
[0010] 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 of the current virtual page is determined, including:
[0011] 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 the first matching result;
[0012] 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; the first preset information set is used to store one or more of the second physical frame number and second virtual page number corresponding to the migrated virtual page.
[0013] 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.
[0014] In the above scheme, 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:
[0015] 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.
[0016] 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.
[0017] 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.
[0018] In the above scheme, based on the page type, the relevant information of the current virtual page is migrated to the destination host, including any one of the following:
[0019] If the current virtual page is a unique page or a dirty page, then determine 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;
[0020] If the current virtual page is a duplicate page, then 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.
[0021] This application also provides a virtual machine hot migration method applied to a destination host, including:
[0022] Receive information about the current virtual page migrated from the source host; the 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 information when the page type is a duplicate page is different from the information when the page type is a non-duplicate page;
[0023] Based on the relevant information, complete the configuration of the virtual machine corresponding to the current virtual page.
[0024] In the above solution, based on relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including:
[0025] If the page type is a unique page, the page content in the relevant information is written into a preset file, and the writing 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, writing position and page type corresponding to the received virtual page;
[0026] Copy the page content from the preset file into the corresponding virtual machine memory.
[0027] In the above solution, based on relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including:
[0028] 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.
[0029] 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.
[0030] In the above solution, based on relevant information, the configuration of the virtual machine corresponding to the current virtual page is completed, including:
[0031] If the page type is a dirty page, the page content from the relevant information is copied into the corresponding virtual machine memory.
[0032] The above scheme also includes the following methods:
[0033] After each pre-copy round, 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.
[0034] This application also provides a virtual machine hot migration device, applied to a source host, including:
[0035] The determining unit is used to determine the page type of the current virtual page during the migration process of the current virtual page, 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;
[0036] The sending unit is used to migrate 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.
[0037] This application also provides a virtual machine hot migration device, applied to a destination host, including:
[0038] The receiving unit is used to receive information related to the current virtual page migrated from the source host. This 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 information related to a duplicate page differs from the information related to a non-duplicate page.
[0039] The configuration unit is used to configure the virtual machine corresponding to the current virtual page based on relevant information.
[0040] This application also provides an electronic device, including a first memory and a first processor. The first memory stores a computer program that can run on the first processor. When the first processor executes the computer program, it implements the steps in the method on the source host side.
[0041] This application also provides an electronic device, including a second memory and a second processor. The second memory stores a computer program that can run on the second processor. When the second processor executes the computer program, it implements the steps in the method on the target host side.
[0042] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a first processor, implements the steps in the method on the source host side.
[0043] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a second processor, implements the steps of the method on the target host side.
[0044] This application also provides a computer program product, including a computer program that, when executed by a first processor, implements the steps of a method on the source host side.
[0045] This application also provides a computer program product, including a computer program that, when executed by a second processor, implements the steps of a method on the target host side.
[0046] In this embodiment, 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. 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. This relevant information includes the page type. The relevant information when the page type is a duplicate page differs from the relevant information when the page type is a non-duplicate page. Thus, since the relevant information for duplicate pages between different virtual machines does not include the page content, the amount of data related to duplicate pages is smaller, significantly reducing memory usage during the migration process. This solves the problems of migration failure, increased traffic, and extended migration time caused by excessive memory usage. Attached Figure Description
[0047] Figure 1 A flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 1 ;
[0048] Figure 2 This application provides an illustration of the effect of the virtual machine hot migration method in its embodiments. Figure 1 ;
[0049] Figure 3 A flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 2 ;
[0050] Figure 4 A flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 3 ;
[0051] Figure 5 A flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 4 ;
[0052] Figure 6 A flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 5 ;
[0053] Figure 7 An interactive schematic diagram of the virtual machine hot migration method provided in the embodiments of this application;
[0054] Figure 8 Schematic diagram of the structure of the virtual machine hot migration device provided in the embodiments of this application Figure 1 ;
[0055] Figure 9 A hardware entity illustration of an electronic device provided in the embodiments of this application. Figure 1 ;
[0056] Figure 10 Schematic diagram of the structure of the virtual machine hot migration device provided in the embodiments of this application Figure 2 ;
[0057] Figure 11 A hardware entity illustration of an electronic device provided in the embodiments of this application. Figure 2 . Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0059] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is 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.
[0060] If the application documents contain similar descriptions such as "first / second", the following explanation shall be added: In the following description, the terms "first / second / third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0062] This application provides a method for hot migration of virtual machines. Please refer to [link to relevant documentation]. Figure 1 This is a flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 1 , will combine Figure 1 The steps shown are explained below:
[0063] S101. 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.
[0064] In this embodiment, the source host may include multiple virtual hosts, and each virtual host may correspond to multiple virtual pages. There may be duplicate pages between different virtual hosts, i.e., COW shared pages. When migrating each current virtual page for each virtual host, a first relevant attribute of the current virtual page can be determined. This first relevant attribute is then matched with a second relevant attribute corresponding to the migrated virtual page. Based on whether there are any identical attributes between the first and second relevant attributes, the page type corresponding to the current virtual page is determined.
[0065] The page types include: Unique Page, Duplicate Page, and Dirty Page. Unique Pages are virtual pages that have not yet been migrated; Duplicate Pages are virtual pages that have already been transferred; and Dirty Pages are virtual pages that were modified during the previous pre-copy migration and need to be retransmitted.
[0066] The first relevant attribute may include one or more of the following: the first physical frame number and the first virtual page number corresponding to the current virtual page. The second relevant attribute may include one or more of the following: the second physical frame number and the second virtual page number corresponding to the migrated virtual page. For duplicate pages between different virtual machines, the physical frame number is the same.
[0067] S102. Based on the page type, migrate the relevant information of the current virtual page 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.
[0068] In this embodiment, 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. Specifically, the relevant information determined for duplicate pages does not include the corresponding page content, but includes the corresponding first physical frame number and page type. The relevant information for other page types includes the corresponding page content, first physical frame number, and page type.
[0069] This application provides a virtual machine hot migration method, proposing a share-aware hot migration technique. This technique can retain pre-existing COW shared pages (duplicate pages) when migrating multiple virtual machines to the same destination host. Its core idea 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, eliminating the risk of migration failure due to memory expansion and reducing the total migration time and network traffic overhead.
[0070] In this embodiment, 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. 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. This relevant information includes the page type. The relevant information when the page type is a duplicate page differs from the relevant information when the page type is a non-duplicate page. Thus, since the relevant information for duplicate pages between different virtual machines does not include the page content, the amount of data related to duplicate pages is smaller, significantly reducing memory usage during the migration process. This solves the problems of migration failure, increased traffic, and extended migration time caused by excessive memory usage.
[0071] The virtual machine hot migration method provided in this application can retain all pre-existing COW shared pages when concurrently migrating coexisting virtual machines. Regardless of the underlying page sharing mechanism, virtual pages mapped by multiple COW shared pages will be mapped to the same physical frame number in physical memory. The source host checks the first physical frame number of each currently transmitted virtual page, identifies whether the second physical frame number of the migrated virtual page on the source host matches, and avoids transmitting 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 the virtual machines into unique pages, duplicate pages, and dirty pages, and transmits the corresponding relevant information to the target host based on the page type. Duplicate pages are not re-transmitted. At the target node, the relevant information for each virtual page is received and mapped accordingly into the memory of the corresponding virtual machine.
[0072] Please see Figure 3 This is a flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 2 , Figure 1 S101 in the middle can also be implemented through S201 to S202, which will combine Figure 3 The steps shown are explained below:
[0073] S201. 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 the first matching result.
[0074] In this embodiment, the first relevant attribute includes one or more of the following: a first physical frame number and a first virtual page number; the second relevant attribute includes one or more of the following: a second physical frame number and a second virtual page number. A first preset information set is used to store one or more of the second physical frame number and 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.
[0075] The first physical frame number can be the physical frame number (PFN) of the current virtual page. A physical frame number is a unique identifier assigned to a physical memory page in the operating system's memory management, used to identify and track contiguous blocks of physical memory. The first virtual page number can be the virtual page number (VPN). The virtual page number is a core concept in operating system memory management, used to map virtual addresses to physical addresses in the paging mechanism.
[0076] S202. Based on the first matching result and the modified page number during the migration process, determine the page type of the current virtual page.
[0077] In this embodiment, the source host can determine the page type based on whether a corresponding second physical frame number and second virtual page number exist in a first preset information set, and whether the obtained modified page number matches the first virtual page number. The modified page number refers to the VPN of a virtual page that was modified during a previous page copying process and needs to be retransmitted.
[0078] In this embodiment of the 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.
[0079] In this embodiment of the 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.
[0080] In this embodiment of the 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.
[0081] In this embodiment, the source host determines the first physical frame number and the first virtual page number of the current virtual page. The first physical frame number and the first virtual page number are then matched with the second physical frame number and the second virtual page number stored in a hash table (first preset information set). The source host Linux kernel exposes the first physical frame number and the first virtual page number to user space through a page-map table (pagemap). User space processes can find the PFN of a specific VPN. Each pagemap entry contains 64 bits of information, 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.
[0082] The source host can determine the page type of the current virtual page based on whether the PFN and VPN of the current virtual page exist in the hash table (first preset information set). The page type includes one of the following three types:
[0083] Unique Page: Virtual pages that have not yet been transmitted are considered unique pages. In this case, the corresponding PFN and VPN are not in the hash table. Therefore, the PFN and VPN of the virtual page are inserted into the hash table before the virtual page content is sent.
[0084] Duplicate Page: A transmitted virtual page is considered a duplicate page. In this case, the PFN exists in the hash table, but the VPN does not. Therefore, only the VPN for that virtual page is inserted into the hash table before the PFN is sent.
[0085] Dirty Page: 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 exist in the hash table, but the VPN always exists. In this case, only the PFN is inserted into the hash table before the virtual page content is sent.
[0086] In this embodiment, 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 this 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 this relevant information is migrated to the destination host. In this way, the corresponding page content is not transmitted for duplicate pages, reducing the amount of data related to duplicate pages and thus solving a series of problems caused by extra memory usage.
[0087] In this embodiment, 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 the 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. Thus, by matching the first physical frame number and the first virtual page number with the second physical frame number and the second virtual page number in the first preset information set, the page type corresponding to the current virtual page is determined. When a duplicate page is identified, the corresponding page content is not sent, thereby reducing the amount of data related to duplicate pages and solving a series of problems caused by extra memory usage.
[0088] Please see Figure 4 This is a flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 3 , will combine Figure 4 The steps shown are explained below:
[0089] S301. Receive relevant information about the current virtual page migrated from 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 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.
[0090] In this embodiment, the destination host receives information about the current virtual page transmitted by the source host. This information includes the page type corresponding to the current virtual page; the page type is determined by the source host based on the matching between a first relevant attribute corresponding to the current virtual page and a second relevant attribute corresponding to a migrated virtual page; the page type includes: duplicate pages between different virtual machines; the information related to a duplicate page type differs from the information related to a non-duplicate page type.
[0091] The page types include: unique pages, duplicate pages, and dirty pages.
[0092] S302. Based on the relevant information, complete the configuration of the virtual machine corresponding to the current virtual page.
[0093] In this embodiment, the target 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, or directly copy the page content into the memory of the corresponding virtual machine based on the first physical frame number in the relevant information.
[0094] In this embodiment, the virtual machine hot migration method can operate 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, the page content is copied into 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 a previously received physical page with the same first physical frame number.
[0095] In this embodiment, information related to the current virtual page being migrated from the source host is received. This 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 information related to duplicate pages differs from the information related to non-duplicate pages. Based on this information, the configuration of the virtual machine corresponding to the current virtual page is completed. Thus, since the information related to duplicate pages between different virtual machines does not include page content, the amount of data related to duplicate pages is small, significantly reducing memory usage during the migration process. This solves the problems of migration failure, increased traffic, and extended migration time caused by excessive memory usage.
[0096] Please see Figure 5 This is a flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 4 , Figure 4 S302 in the above can also be implemented through S401 to S402, combining Figure 5 The steps shown are explained below:
[0097] S401. If the page type is a unique page, the page content in the relevant information is written into a preset file, and the writing position, page type and first physical frame number corresponding to the page content are stored in the second preset information set.
[0098] In this embodiment, after receiving relevant information, if the target host detects that the page type is a unique page, it writes the page content from the relevant information into a preset file. The correspondence between the page content's writing location, page type, and 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, writing location, and page type corresponding to the received virtual page.
[0099] In this embodiment, a memory backend file (preset file) can be set in the destination host. Information related to each received current virtual page is memory-mapped using the Memory Mapped File (mmap) system call. The destination host can set two important flags: shared mapping (Memory MappedShared, MAP_SHARED) and private mapping (Memory Mapped Private, MAP_PRIVATE). The MAP_SHARED flag ensures that any write to the mapped virtual address will be written back to the backend file. Conversely, MAP_PRIVATE causes copy-on-write (COW) mapping, meaning that any write to the mapped virtual address will allocate a new private page for the process before the write is committed, thus ensuring that the write is not transmitted to the backend file. When information related to a unique page is received, that unique page can be configured with the MAP_SHARED flag. Then, the page content of the received information is written to the backend file, and the mmap configuration of that page is changed to MAP_PRIVATE to enable COW mapping for any future reuse of the same page. The first physical frame number of the unique page and its corresponding mmap offset (write position) are also recorded in a hash table (second preset information set).
[0100] S402. Copy the page content from the preset file into the corresponding virtual machine memory.
[0101] In this embodiment of the application, the destination host can directly copy the page content from the relevant information of the unique page into the memory of the corresponding virtual machine.
[0102] In this embodiment, if the page type is a unique page, the page content from 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. The second preset information set stores one or more of the first physical frame number, write location, and page type corresponding to the received virtual page. The page content in the preset file is copied into the corresponding virtual machine memory. Thus, for a unique page, the corresponding write location, page type, and first physical frame number are stored in the second preset information set. After receiving a duplicate page, the mapping location of the virtual address can be determined in the preset file based on the first physical frame number corresponding to the duplicate page. Therefore, the successful migration of duplicate pages can be achieved without retrieving the page content corresponding to the duplicate page.
[0103] Please see Figure 6 This is a flowchart illustrating the virtual machine hot migration method provided in this application embodiment. Figure 5 , Figure 4S302 in the above can also be implemented through S403 to S404, combining Figure 6 The steps shown are explained below:
[0104] S403. If the page type is a duplicate page, then query the corresponding target write position in the second preset information set based on the first physical frame number in the relevant information.
[0105] In this embodiment, the second preset information set is used to store one or more of the following: the first physical frame number, the write location, and the page type corresponding to the received virtual page. Thus, 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 can be determined by matching the first physical frame number in the relevant information of the duplicate page with each first physical frame number in the second preset information set.
[0106] The target write location can be the mmap offset of the page content with the same physical frame number corresponding to the duplicate page in the preset file.
[0107] 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.
[0108] In this embodiment of the application, the target 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.
[0109] In this embodiment of the application, if the page type is a dirty page, the page content in the relevant information is copied into the corresponding virtual machine memory.
[0110] In this embodiment, when information related to duplicate pages is received, the first physical frame number is used as the key to look up the second preset information set to retrieve the corresponding mmap offset (destination write location), and the MAP_PRIVATE flag is used to map the virtual address to the backend file. If information related to dirty pages is received, any mmap operation is skipped, and the entire page content is directly copied from the network to the VM's address space.
[0111] In this embodiment of the application, after each pre-copy round ends, 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.
[0112] In this embodiment, ideally, for a given PFN, the information about a unique page (including its page content and PFN) should arrive at the destination host before the information about any duplicate pages (containing only the PFN). However, during the migration of multiple virtual machines, sometimes the information about duplicate pages of a VM may arrive before the information about the unique page (e.g., the PFN of VMx arrives before the unique page content of VMy). But duplicate pages cannot be COW mapped until the unique page is mapped and its page content is written to the backend file. To solve this problem, the multi-VM synchronization is designed as follows: at the end of each pre-copy round, all pending duplicate pages in VMx that depend on VMy can be updated by busy-waiting to prevent outdated mapping entries. The busy-waiting at the end of the last pre-copy round prolongs the downtime of the virtual machines. To mitigate this delay, an additional real-time pre-copy round without busy-waiting can be included before the downtime phase.
[0113] In this embodiment, if the page type is a duplicate page, the corresponding target write location 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 location indicated by the target write location in the preset file. Since the relevant information of the duplicate page transmitted by the source host does not include the corresponding page content, mapping the virtual address of the virtual machine of the duplicate page to the target write location can also achieve the migration of duplicate pages with a smaller amount of data transmission, solving the problems of migration failure, increased traffic, and extended migration time caused by memory consumption.
[0114] Please see Figure 7 The diagram below illustrates the interaction of the virtual machine hot migration method provided in this application embodiment, and will be explained in conjunction with the steps:
[0115] S501. During the migration of the current virtual page, the source host determines the page type of the current virtual page based on the first relevant attribute corresponding to the current virtual page and the second relevant attribute corresponding to the migrated virtual page.
[0116] In this embodiment, the implementation steps of S501 can be referred to S101, and will not be described in detail here.
[0117] S502. The source host migrates the 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.
[0118] In this embodiment, the implementation steps of S502 can be referred to S102, and will not be described in detail here.
[0119] S503. The destination host, based on the relevant information, completes the configuration of the virtual machine corresponding to the current virtual page.
[0120] In this embodiment, the implementation steps of S503 can be referred to S302, and will not be described in detail here.
[0121] Please see Figure 8 The diagram below illustrates the structure of the virtual machine hot migration device provided in this application embodiment. Figure 1 .
[0122] This application also provides a virtual machine hot migration device 600, applied to a source host, including: a determining unit 601 and a sending unit 602.
[0123] The determining unit 601 is used to determine the page type of the current virtual page during the migration 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; wherein, the page type includes: duplicate pages between different virtual machines;
[0124] The sending unit 602 is used to migrate 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.
[0125] In this embodiment of the application, the first related attribute includes one or more of the following: the first physical frame number and the first virtual page number; the second related attribute includes one or more of the following: the second physical frame number and the second virtual page number;
[0126] The determining unit 601 in the virtual machine hot migration device 600 is used to match the first virtual page number with each second virtual page number in the first preset information set, match the first physical frame number with each second physical frame number in the first preset information set, and determine the first matching result;
[0127] 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; the first preset information set is used to store one or more of the second physical frame number and second virtual page number corresponding to the migrated virtual page.
[0128] 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.
[0129] In this embodiment of the application, the determining unit 601 in the virtual machine hot migration device 600 is used to determine the page type of the current virtual page as 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.
[0130] 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.
[0131] 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.
[0132] In this embodiment of the application, the sending unit 602 in the virtual machine hot migration device 600 is used to determine the page content, page type and first physical frame number corresponding to the current virtual page as relevant information if the current virtual page is a unique page or a dirty page, and migrate the relevant information to the destination host.
[0133] If the current virtual page is a duplicate page, then 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.
[0134] It should be noted that, in the embodiments of this application, if the above-described virtual machine hot migration method is implemented as 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 this application, or the part that contributes to the related 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 to cause a virtual machine hot migration device (which may be a personal computer, etc.) to execute all or part of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0135] Correspondingly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, which, when executed by a first processor, implements the steps in the method of the virtual machine hot migration device 600.
[0136] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0137] It should be noted that, Figure 9 A hardware entity illustration of an electronic device provided in the embodiments of this application. Figure 1 ,like Figure 9 As shown, this application embodiment 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 run on the first processor 701. When the first processor 701 executes the program, it implements the steps in the above-described method, wherein;
[0138] The first processor 701 typically controls the overall operation of the electronic device 700.
[0139] 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 already processed by the first processor 701 and various modules in the electronic device 700 (e.g., image data, audio data, voice communication data and video communication data), which can be implemented by flash memory or random access memory (RAM).
[0140] Correspondingly, this application embodiment also provides a computer program product, including a computer program that can be executed by a first processor 701 of an electronic device 700 to complete the steps in the method on one side of the virtual machine hot migration device 600.
[0141] Please see Figure 10 The diagram below illustrates the structure of the virtual machine hot migration device provided in this application embodiment. Figure 2 .
[0142] This application also provides a virtual machine hot migration device 800, applied to a destination host, including: a receiving unit 801 and a configuration unit 802.
[0143] The receiving unit 801 is used to receive relevant information about the current virtual page migrated from 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 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;
[0144] Configuration unit 802 is used to configure the virtual machine corresponding to the current virtual page based on relevant information.
[0145] In this embodiment of the application, the configuration unit 802 in the virtual machine hot migration device 800 is used to write the page content in the relevant information into a preset file if the page type is a unique page, and to store the writing position, 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 used to store one or more of the first physical frame number, writing position and page type corresponding to the received virtual page;
[0146] Copy the page content from the preset file into the corresponding virtual machine memory.
[0147] In this embodiment of the application, the configuration unit 802 in the virtual machine hot migration device 800 is used to query the corresponding target write position 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.
[0148] 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.
[0149] In this embodiment of the application, the configuration unit 802 in the virtual machine hot migration device 800 is used to copy the page content in the relevant information into the corresponding virtual machine memory if the page type is a dirty page.
[0150] In this embodiment of the 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 position indicated by the target write position in the preset file by busy waiting for the virtual machine corresponding to the current virtual page after each pre-copy round ends.
[0151] Correspondingly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, which, when executed by a second processor, implements the steps in the method of the virtual machine hot migration device 800.
[0152] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0153] It should be noted that, Figure 11 A hardware entity illustration of an electronic device provided in the embodiments of this application. Figure 2 ,like Figure 11As shown, this application embodiment provides an electronic device 900, including a second memory 902 and a second processor 901. The second memory 902 stores a computer program that can run on the second processor 901. When the second processor 901 executes the program, it implements the steps in the above method, wherein;
[0154] The second processor 901 typically controls the overall operation of the electronic device 900.
[0155] 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 already processed by the second processor 901 and various modules in the electronic device 900 (e.g., image data, audio data, voice communication data and video communication data), which can be implemented by flash memory or random access memory (RAM).
[0156] Correspondingly, this application also provides a computer program product, including a computer program that can be executed by a second processor 901 of an electronic device 900 to complete the steps in the method on one side of the virtual machine hot migration device 800.
[0157] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in one or more embodiments of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential 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 this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0158] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0159] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the apparatus or units can be electrical, mechanical, or other forms.
[0160] The units described above as separate components may or may not be physically separate. The components shown 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 to achieve the purpose of this embodiment according to actual needs.
[0161] In addition, each functional unit in the various embodiments of this 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 integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0162] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0163] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0164] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for hot migration of virtual machines, characterized in that, Applied to the source host, including: During the migration of the current virtual page, 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 the first matching result; the first related attribute of the current virtual page includes one or more of the following: the first physical frame number and the first virtual page number; the second related attribute of the migrated virtual page includes one or more of the following: the second physical frame number and the second virtual page number; Wherein, 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; 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; 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 hot migration method according to claim 1, characterized in that, The determination 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, then the page type of the current virtual page is determined to be 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, then the page type of the current virtual page is determined to be 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.
3. The virtual machine hot migration method according to claim 2, characterized in that, The step of 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 unique page or the dirty page, then the page content, the page type, and the first physical frame number corresponding to the current virtual page are determined to be the relevant information, and the relevant information is migrated to the destination host; If the current virtual page is the duplicate page, then the page type and the first physical frame number corresponding to the current virtual page are determined to be the relevant information, and the relevant information is migrated to the destination host.
4. A method for hot migration of virtual machines, characterized in that, Applied to the destination host, including: The system receives information related to the current virtual page being migrated from the source host. This information includes the page type corresponding to the current virtual page. The page type is determined by the source host matching a first virtual page number with each second virtual page number in a first preset information set, and matching a first physical frame number with each second physical frame number in the first preset information set, to determine a first matching result. This result is based on the first matching result and the modified page number during the migration process. The first related attribute of the current virtual page includes one or more of the following: the first physical frame number and the first virtual page number. The second related attribute of the migrated virtual page includes one or more of the following: the second physical frame number and the second virtual page number. 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 number. The first preset information set stores one or more of the second physical frame number and the second virtual page number corresponding to the migrated virtual page. The page type includes: duplicate pages between different virtual machines. The information related to the page type being a duplicate page differs from the information related to the page type being a non-duplicate page. Based on the aforementioned information, the configuration of the virtual machine corresponding to the current virtual page is completed.
5. The virtual machine hot migration method according to claim 4, characterized in that, The step of configuring the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is a unique page, the page content in the relevant information is written into a preset file, and the writing position corresponding to the page content, the page type, and the first physical frame number 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, the writing position, and the page type corresponding to the received virtual page; The page content in the preset file is copied into the corresponding virtual machine memory.
6. The virtual machine hot migration method according to claim 4, characterized in that, The step of configuring the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is the repeated page, then 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 location indicated by the target write location in the preset file.
7. The virtual machine hot migration method according to claim 4, characterized in that, The step of configuring the virtual machine corresponding to the current virtual page based on the relevant information includes: If the page type is a dirty page, then the page content in the relevant information is copied into the corresponding virtual machine memory.
8. The virtual machine hot migration method according to claim 6, characterized in that, The method further includes: After each pre-copy round, 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.
9. A virtual machine hot migration device, characterized in that, Applied to the source host, including: The determining unit is configured to, during the migration of the current virtual page, 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, and determine the first matching result; the first related attribute of the current virtual page includes one or more of the following: the first physical frame number and the first virtual page number; the second related attribute of the migrated virtual page includes one or more of the following: the second physical frame number and the second virtual page number; Wherein, 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; 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; wherein, the page type includes: duplicate pages between different virtual machines; A sending unit is configured to 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.
10. A virtual machine hot migration device, characterized in that, Applied to the destination host, including: A receiving unit is configured to receive information related to the current virtual page being migrated from 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 matching a first virtual page number with each second virtual page number in a first preset information set, and matching a first physical frame number 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 first relevant attribute of the current virtual page includes one or more of the following: the first physical frame number and the first virtual page number; the second relevant attribute of the migrated virtual page includes one or more of the following: the second physical frame number and the second virtual page number; wherein, 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 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 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; The configuration unit is used to configure the virtual machine corresponding to the current virtual page based on the relevant information.
11. An electronic device, characterized in that, The method includes a memory and a processor, the memory storing a computer program that can run on the processor, the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 3, or to implement the steps of the method according to any one of claims 4 to 8.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3, or the steps of the method according to any one of claims 4 to 8.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3, or the steps of the method according to any one of claims 4 to 8.
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