Data migration method of virtual machine and related device
By obtaining the priority information of virtual machine data blocks in the source host and determining the migration order based on it, priority is given to transmit virtual machine data blocks of the target host, the problem of low virtual machine migration efficiency in cloud computing is solved, and the rapid startup and efficient data migration of virtual machines are achieved.
Patent Information
- Application Number
- CN202311489539.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2025-05-13
AI Technical Summary
In the field of cloud computing, when a virtual machine is migrated from the source host to the target host, the target host needs to determine whether the data has been migrated when reading/writing data. If it is not migrated, it needs to be obtained from the source host across the network, resulting in low data migration efficiency, long boot time of the virtual machine, and poor user interaction experience.
When the source host determines that the migration conditions are met, the priority information of the data blocks is obtained, and the order of migration of the data blocks is determined based on the priority information, and the data blocks with higher priority are transmitted to the target host to reduce the duration of the target host pulling data from the source host.
By prioritizing the transmission of data blocks with higher priority, the virtual machine of the target host can be turned on quickly, improving the data migration efficiency of the virtual machine and improving the user's interactive experience.
Smart Images

Figure CN119987935A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a data migration method and related devices for a virtual machine. Background Art
[0002] In the field of cloud computing, when migrating a virtual machine from a source host to a target host, the boot time of the virtual machine running on the target host is an important indicator for measuring the basic services of cloud computing.
[0003] At present, in the process of using real-time migration technology to migrate virtual machine data, when the target host reads / writes data, it will first determine whether the required data has been migrated to the target host. If it has been migrated to the target host, it will directly read and write from the target host's memory. If it has not been migrated to the target host, it is necessary to obtain the data from the source host through network transmission. At this time, a request will be sent to the source host. After receiving the request, the source host will send the requested data to the target host. The time to pull data from the target host to the source host generally accounts for a large proportion of the entire I / O (input / output) access. If all I / Os of the target host need to be obtained across the network, the efficiency of data migration is low, resulting in a longer startup time of the virtual machine of the target host and a poor user interaction experience. Summary of the invention
[0004] The present application provides a data migration method and related devices for a virtual machine, which can shorten the time it takes for a target host to pull data from a source host and improve the interactive experience during data transmission.
[0005] In a first aspect, the present application provides a method for migrating data of a virtual machine, which can be applied in the field of cloud computing technology, and is mainly applied to a source host for virtual machine migration, wherein the data of the virtual machine includes at least two data blocks, and the method includes:
[0006] When the source host determines that the migration conditions are met, it will first obtain the priority information corresponding to at least two data blocks; then, the source host can determine the migration order of the at least two data blocks based on the priority information corresponding to the at least two data blocks; finally, the source host sends the at least two data blocks to the target host according to the migration order.
[0007] During the startup process of the virtual machine of the target host, if the target host does not find the data required for startup in the storage, it needs to obtain the data required for startup from the source host through network transmission. The efficiency of data migration is low, resulting in a long startup time of the virtual machine of the target host. In order to solve the above problems, in this application, when the source host determines that the migration conditions are met, the data blocks corresponding to the file can be transmitted in sequence based on the priority information of the data blocks. For example, data blocks with higher priorities are transmitted to the target host first, so that the virtual machine of the target host can be directly started based on the obtained data blocks when it is started, without having to obtain them from the source host across the network, thereby realizing the rapid startup of the virtual machine of the target host and improving the data migration efficiency of the virtual machine.
[0008] In a possible implementation of the first aspect, during startup of a virtual machine of the target host, the order in which the virtual machine loads data blocks during startup is related to priority information of the data blocks;
[0009] Obtaining priority information corresponding to the at least two data blocks respectively includes:
[0010] Obtaining a loading sequence of the at least two data blocks during startup of the virtual machine of the target host;
[0011] Priority information of the at least two data blocks is determined according to the sequence, wherein the priority of the data block at the front of the sequence is higher than the priority of the data block at the back of the sequence.
[0012] In this possible implementation, the source host determines the priority information of the data blocks based on the order in which the data blocks are loaded during the boot process of the operating system, and sends the data blocks with high priority to the target host first, so that the virtual machine of the target host can be directly booted based on the received data blocks, thereby saving boot time.
[0013] In a possible implementation manner of the first aspect, the method further includes:
[0014] receiving a read / write request for a first data block sent by a target host;
[0015] Determine the location information corresponding to the first data block according to the read / write request of the first data block;
[0016] Determine the file to which the first data block belongs in the memory according to the location information;
[0017] The file to which the first data block belongs in the memory is sent to the target host.
[0018] In this possible implementation, when the source host receives a read / write request for a data block sent by the target host, instead of directly sending the data block, the file to which the data block belongs in the memory is determined according to the read / write request for the data block, and the file where the data block is located is sent to the target host. By parsing the file system of the memory, analyzing the file where the data block is located in the memory, the rest of the file excluding the data block is transmitted in advance, so as to transmit in advance the data blocks that may be used by the target host, realize the rapid reconstruction of the virtual machine of the target host, improve the running fluency, and enhance the interactive experience of the target host during the transmission process.
[0019] In a possible implementation manner of the first aspect, the position information corresponding to the first data block includes an offset and a length corresponding to the first data block in the memory.
[0020] In this possible implementation, after receiving a read / write request for a data block sent by the target host, the source host can determine the location information of the data block to be read, that is, the offset and length of the data block in the memory, by parsing the information of the read / write request, so as to transmit the data blocks that the target host may use in advance, realize the rapid reconstruction of the virtual machine of the target host, improve the running smoothness, and enhance the interactive experience of the target host during the transmission process.
[0021] In a possible implementation manner of the first aspect, the method further includes:
[0022] Get the used space in the memory;
[0023] Only the used space in the memory is sent to the target host.
[0024] In this possible implementation, compared to directly copying all the data in the memory, the source host parses the used space in the memory and only sends the data in the used space in the memory, thereby reducing the amount of data transmission and shortening the data migration time of the virtual machine.
[0025] In a second aspect, the present application provides a data migration device for a virtual machine. The beneficial effects can be found in the description of the first aspect and will not be repeated here. The device has the function of implementing the behavior in the method example of the first aspect. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The data of the virtual machine includes at least two data blocks, and the device includes:
[0026] A data analysis module, used for obtaining priority information corresponding to at least two data blocks respectively when a migration condition is met;
[0027] The data analysis module is further used to determine the migration order of at least two data blocks according to the priority information respectively corresponding to the at least two data blocks;
[0028] The data transmission module is used to send at least two data blocks to the target host according to the migration sequence.
[0029] In a possible implementation of the second aspect, during the startup of the virtual machine of the target host, the order in which the virtual machine loads the data blocks during the startup process is related to the priority information of the data blocks;
[0030] The data parsing module is also used to:
[0031] Obtaining a loading sequence of at least two data blocks during a startup process of a virtual machine of a target host;
[0032] Priority information of at least two data blocks is determined according to the sequence, wherein the priority of a data block that is earlier in the sequence is higher than the priority of a data block that is later in the sequence.
[0033] In a possible implementation of the second aspect, the data transmission module is further configured to receive a read / write request for the first data block sent by a target host;
[0034] The data parsing module is further used to determine the position information corresponding to the first data block according to the read / write request of the first data block;
[0035] The data parsing module is further used to determine the file to which the first data block belongs in the memory according to the location information;
[0036] The data transmission module is also used to send the file to which the first data block belongs in the memory to the target host.
[0037] In a possible implementation manner of the second aspect, the position information corresponding to the first data block includes an offset and a length corresponding to the first data block in the memory.
[0038] In a possible implementation of the second aspect, the data parsing module is further used to obtain the used space in the memory;
[0039] The data transmission module is also used to send all the data in the used space in the memory to the target host.
[0040] In a third aspect, the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory;
[0041] The processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0042] In a fourth aspect, the present application provides a computer program product comprising instructions, characterized in that when the instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0043] In a fifth aspect, the present application provides a chip system, which includes a processor for implementing the method in the first aspect or any possible implementation of the first aspect. In one possible design, the chip system also includes a memory for storing program instructions and / or data. The chip system can be composed of a chip, or can include a chip and other discrete devices.
[0044] In a sixth aspect, the present application provides a computer-readable storage medium, characterized in that it includes computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0045] The solutions of the second to sixth aspects mentioned above are used to implement or cooperate with the method in the first aspect or any possible implementation method thereof, and therefore can achieve the same or corresponding beneficial effects as the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of an architecture for virtual machine migration provided in an embodiment of the present application;
[0047] Figure 2 A schematic diagram of the structure of a controller provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of an architecture of a virtual machine migration method;
[0049] Figure 4 A schematic diagram of a flow chart of a data migration method for a virtual machine provided in an embodiment of the present application;
[0050] Figure 5 Another schematic diagram of a flow chart of a data migration method for a virtual machine provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of a structure of disk management provided in an embodiment of the present application;
[0052] Figure 7 A file distribution diagram of disk management provided in an embodiment of the present application;
[0053] Figure 8Another schematic diagram of a flow chart of a data migration method for a virtual machine provided in an embodiment of the present application;
[0054] Figure 9a A schematic diagram of a structure of a data migration device for a virtual machine provided in an embodiment of the present application;
[0055] Figure 9b Another schematic diagram of the architecture of virtual machine migration provided in an embodiment of the present application;
[0056] Fig.10 A schematic diagram of a structure of a computing device provided in an embodiment of the present application;
[0057] Fig.11 A schematic diagram of a structure of a computing device cluster provided in an embodiment of the present application;
[0058] Fig.12 Another structural diagram of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0060] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices.
[0061] The term "and / or" in this application can be a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.
[0062] It should also be noted that, in some alternative implementations, the functions / acts noted may occur out of the order of the drawings. For example, two figures shown in succession may in fact occur substantially simultaneously or may sometimes be performed in the reverse order, depending on the functions / acts involved.
[0063] In the embodiments of the present application, unless otherwise specified, the meaning of "at least one" refers to one or more, and the meaning of "plurality" refers to two or more. It is understood that in the present application, "when", "if" and "if" all refer to the device making corresponding processing under certain objective circumstances, and do not limit the time, nor do they require that there must be a judgment action when the device is implemented, nor do they mean that there are other limitations. In addition, the special word "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described as "exemplary" is not necessarily interpreted as being superior or better than other embodiments.
[0064] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0065] First, in order to better understand the solution of the embodiment of the present application, the application scenario of the embodiment of the present application is described below. This embodiment is mainly used in the field of cloud computing and is mainly used to migrate data on cloud virtual machines. Figure 1 , Figure 1 An architectural diagram of virtual machine migration provided in an embodiment of the present application includes a source host 1 and a target host 2. A virtual machine 11 is run on the source host 1, and a virtual machine 21 is run on the target host 2. Multiple virtual machines can be run on both the source host 1 and the target host 2. For ease of explanation, a single virtual machine is used as an example for explanation. The operating system (OS) running on each virtual machine includes Windows, Linux, Solaris, and Mac OS. Each virtual machine is accessed by one or more clients of one or more networks, wherein the networks include private networks (e.g., local area networks, wide area networks, intranets, etc.) and public networks.
[0066] On the source host 1, the virtual machine 11 is connected to the controller 12, and the virtual machine 11 is managed by the controller 12. The controller 12 includes a transmission agent module 121, which is responsible for migrating the virtual machine through the network.
[0067] On the target host 120, the virtual machine 21 is connected to the controller 22, and the virtual machine 21 is managed by the controller 22. The controller 22 includes a transmission agent module 221, which is responsible for migrating the virtual machine through the network.
[0068] Optionally, in some virtualization systems, the controller 12 may reside outside the source host 1 , and the controller 22 may reside outside the target host 2 .
[0069] The structures of the controller 12 and the controller 22 are further described below. It can be understood that the internal structures of the controller 12 and the controller 22 are the same. Figure 2 , Figure 2 This is a schematic diagram of the structure of the controller provided in the embodiment of the present application. Figure 2 As shown, the controller 200 is implemented by a general bus architecture.
[0070] The controller 200 includes at least one processor 201, a communication bus 202, a memory 203 and at least one communication interface 204. Since the source host or the virtual machine running on the source host can access the virtual machine disk to be transferred, the transmission agent module 121 included in the controller 12 can be understood as a process running on the source host 1, and can also be understood as a process running on the virtual machine running on the source host. The transmission agent module 121 is mainly used for the transmission or migration of the virtual machine, wherein the instructions of the transmission agent module 121 are stored in the memory 203, and the processor 201 uses the communication interface 204 to communicate data with the target host 2 by calling the transmission agent module 121. The structure of the controller 22 is similar to that of the controller 12, and will not be repeated here. It should be understood that in the process of virtual machine migration, in order to ensure the non-intrusion of the virtual machine, the memory corresponding to the virtual machine to be migrated is generally mounted on the transmission agent (Agent) module, and then the data on the disk is read and sent through the transmission agent module.
[0071] The processor 201, memory 203, and communication interface 204 communicate via the communication bus 202, and may also communicate via other means such as wireless transmission. The memory 203 is used to store instructions, and the processor 201 is used to execute instructions stored in the memory 203. The virtual machine may be mapped to storage or otherwise retained in the memory 122. The memory 203 stores program code, and the processor 201 may call the program code stored in the memory 203 to execute. Figure 4 In the embodiment shown, steps 401-403, Figure 5 Steps 501-504 and Figure 8 At least one of steps 801-802 shown.
[0072] Optionally, the processor 201 is a general-purpose central processing unit (CPU), and may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices (PLD), transistor logic devices, hardware components or any combination thereof. The above-mentioned PLD is a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0073] The communication bus 202 is used to transmit information between the processor 201, the memory 203 and the communication interface 204. The communication bus 202 is divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0074] Optionally, the memory 203 is a read-only memory (ROM) or other types of static storage devices that can store static information and instructions. Alternatively, the memory 203 is a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions. Alternatively, the memory 203 is an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.
[0075] Optionally, the memory 203 exists independently, and data related to the virtual machine is stored in the memory 203 , and is connected to the processor 201 via the communication bus 202 .
[0076] Optionally, the memory 203 and the processor 201 are integrated together.
[0077] The communication interface 204 uses any transceiver-like device for communicating with other devices or communication networks. The communication interface 204 includes a wired communication interface. Optionally, the communication interface 204 also includes a wireless communication interface. Among them, the wired communication interface is, for example, an Ethernet interface. The Ethernet interface is an optical interface, an electrical interface or a combination thereof. The wireless communication interface is a wireless local area network (WLAN) interface, a cellular network communication interface or a combination thereof, etc.
[0078] In a specific implementation, as an embodiment, the processor 201 includes one or more CPUs, such as Figure 2 CPU0 and CPU1 are shown in the figure.
[0079] In a specific implementation, as an embodiment, the controller 200 includes multiple processors, such as Figure 2 201 and processor 205 are shown in FIG. Each of these processors is a single-CPU or a multi-CPU. A processor herein refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0080] In some embodiments, the memory 203 is used to store program codes for executing the solution of the present application, and the processor 201 executes the program codes stored in the memory 203. That is, the virtual machine data migration device 900 implements the following embodiment of the virtual machine data migration method through the processor 201 and the program codes in the memory 203.
[0081] It is to be understood that the method steps in the embodiments of the present application may be implemented in hardware or in software instructions executable by the processor 201. The software instructions may be composed of corresponding software modules, and the software modules may be stored in random access memory, flash memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, registers, hard disk, mobile hard disk, CD-ROM or any other form of storage medium known in the art. In addition, the scope of the device described in the present application is not limited thereto, and the structure of the device may not be limited thereto. Figure 9a and Figure 9b A device may be a stand-alone device or may be part of a larger device. For example, a device may be:
[0082] (1) Independent integrated circuit IC, or chip, or chip system or subsystem;
[0083] (2) having a set of one or more ICs, and optionally, the IC set may also include a storage component for storing data and / or instructions;
[0084] (3) Modules that can be embedded in other devices;
[0085] (4) Receivers, terminals, intelligent terminals, wireless devices, handheld devices, mobile units, vehicle-mounted devices, artificial intelligence devices, machine equipment, household equipment, medical equipment, industrial equipment, etc.;
[0086] (5)Others
[0087] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0088] In the field of cloud computing, the virtual machine running on the target host (referred to as the target virtual machine) can generally be started through local storage or remote storage. Typical scenarios for starting through remote storage include real-time migration of virtual machines and deployment of virtual machines. The overall time from issuing the startup command to the successful startup of the target virtual machine's operating system is generally an important indicator for measuring cloud computing basic services. In addition, the time to complete virtual machine migration and virtual machine deployment is another important indicator. In addition to the system scheduling time and the startup time of the operating system itself, the entire startup time of the virtual machine generally takes up a large proportion of the time for the corresponding storage of the virtual machine to pull data from the remote end. If the data pulling time can be shortened, the operating system startup time will be greatly shortened.
[0089] Currently, there are mainly two methods for migrating a virtual machine from a source host to a target host.
[0090] Taking the storage device as a disk as an example, the core idea of the first method is similar to the "download and play" of online movies nowadays, that is, directly start the virtual machine on the empty disk of the target host. After startup, the disk data to be copied is adjusted in real time from the source host as needed. The target host requests the required data in real time, and the source host pushes all other remaining data to the target host. When all the data is transferred to the target host, the migration is completed.
[0091] See also Figure 3 , Figure 3 The following is a schematic diagram of a virtual machine migration method. The method mainly includes:
[0092] 1. The target host creates a virtual disk and maps it to the source host's disk and the target host's disk respectively;
[0093] 2. Before all disks of the source host are copied to the target host, start the operating system of the target virtual machine from the virtual disk in advance;
[0094] 3. During the startup of the target virtual machine's operating system:
[0095] (1) The source host's disk data is continuously copied asynchronously in the background (corresponding to Figure 3 (1) in );
[0096] (2) If the source host data has been copied, operate directly on the target host's disk (corresponding to Figure 3 (2) in the above);
[0097] (3) The disk of the source host has not yet been copied:
[0098] a. If it is write I / O (input / output), it is written directly to the disk of the target host (corresponding to Figure 3 a) in;
[0099] b. If it is a read I / O, the data is copied from the source host's disk to the target host's disk first, and then the data is read from the target host's disk (corresponding to Figure 3 b) in the above.
[0100] Through the above steps, the waiting time before the target virtual machine's operating system is started can be greatly reduced, improving the user experience. However, the real-time migration efficiency of this method is poor, especially in scenarios with more read operations. For example, a large number of files need to be read when booting, and remote network acquisition is performed for each I / O, which is inefficient.
[0101] The second method mainly uses the read ahead and read around methods, that is, by analyzing the behavior of I / O, the data blocks that need to be read in the future are predicted and transmitted first, so as to improve the startup speed of the operating system of the target virtual machine. For example, after the target host reads the data of a certain position from the disk, read ahead means predicting that the next read will be the data of the next position of the position, and obtaining the data of the next position from the source host first, so that when the target host reads the data of the next position in sequence, it can be read directly from the disk of the target host without obtaining it from the source host in real time, thereby saving transmission time. Read around mainly means predicting the position of the surrounding position to be read next time after reading the data of the first position by analyzing the behavior of I / O, and obtaining the data corresponding to the surrounding position from the source host in advance, so as to read directly from the disk of the target host when needed, thereby saving transmission time.
[0102] However, this method mainly predicts specific data blocks, and the accuracy of the prediction results cannot be guaranteed. If the files required for the operating system startup process cannot be transferred to the target host in advance, the operating system of the target virtual machine will also need to obtain data from the source host when it is started, resulting in a slow startup speed of the operating system of the target virtual machine. In addition, in this method, the source host generally transfers all data in the memory to the target host, which results in a large amount of data transmission and wastes bandwidth.
[0103] In order to solve the above problems, the present invention provides a method for migrating virtual machine data. Figure 1 On the source host 1 shown, it can be specifically executed by the controller 12 of the source host. In this embodiment, when the controller of the source host determines that the migration condition is met, it actively sends the data block to the target host according to the priority information of the data block, and preferentially transmits the data block with a higher priority to the target host, so that the virtual machine of the target host can be directly started based on the obtained data block when starting up, without having to obtain it from the source host across the network, thereby realizing the rapid startup of the virtual machine of the target host and improving the data migration efficiency of the virtual machine.
[0104] For ease of understanding, the data migration method of the virtual machine provided by the embodiment of the present application is specifically described below in conjunction with the accompanying drawings and application scenarios. Those skilled in the art will appreciate that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiment of the present application are also applicable to similar technical problems.
[0105] See also Figure 4 , Figure 4 A flow chart of a data migration method for a virtual machine provided in an embodiment of the present application is shown in FIG. Figure 1 The controller of the source host shown in FIG. 1 is executed. For the sake of convenience, the memory is a disk as an example. Figure 4 As shown, the data of the virtual machine includes at least two data blocks, and the method includes the following steps:
[0106] Step 401: When a migration condition is met, the controller obtains priority information corresponding to at least two data blocks.
[0107] In this step, after the source host starts the migration task, the controller first analyzes the characteristics of the disk where the data blocks corresponding to the virtual machine are located, and obtains the priority information of the data blocks corresponding to the virtual machine.
[0108] Optionally, the migration condition can be understood as the source host mounting the disk to be migrated to the virtual machine including the transmission component and the disk parsing component after starting the migration task, so that the virtual machine responsible for migration can read the disk, thereby starting the data migration of the virtual machine.
[0109] In one implementation, the controller obtains the order in which data blocks need to be loaded during the boot process of the operating system, and determines the priority of the data blocks according to the order.
[0110] In this implementation, the controller can actively obtain the data blocks that need to be loaded during the startup process of the operating system running on the target virtual machine, and determine the priority of the data according to the order of the data blocks, so as to transfer the data blocks to the target host when the source host starts to migrate, so that the target virtual machine can start the operating system according to the data blocks with higher priority when it is powered on, thereby achieving fast startup.
[0111] Step 402: The controller determines a migration order of at least two data blocks according to priority information corresponding to the at least two data blocks.
[0112] In this step, after the controller determines the priority information of the data block, it can determine the order of sending the data blocks based on the priority information of the data blocks, and send the data blocks with higher priority to the target host first to achieve fast startup or start-up of the target virtual machine.
[0113] In one example, the boot process of the target virtual machine can be mainly divided into the following stages: kernel loading stage, self-starting application startup stage, normal system operation stage, etc. It is understandable that the target virtual machine can be directly started without any data, that is, the virtual machine is started on the empty disk of the target host. After the target virtual machine is started, it is necessary to first obtain the kernel file before loading the self-starting file. After loading the self-starting file, it can enter the normal system operation stage. Corresponding to this embodiment, the controller of the source host first sends the kernel file to the target host based on the priority order, and then sends the self-starting file and other files used by the file system in the normal system operation stage to the target host, so that the target virtual machine can directly obtain the kernel file and the self-starting file from the disk of the target host after booting, and start the operating system of the virtual machine based on the kernel file and the self-starting file, so as to realize the normal boot of the target virtual machine, without the need to extend the data pulling time by sending a data request to the source host when the kernel file is needed. After the target virtual machine is normally booted, it can be operated normally based on the files used in the file system.
[0114] Step 403: The controller sends at least two data blocks to the target host according to the migration sequence.
[0115] In this step, after the controller determines the order of data blocks that the target virtual machine needs to obtain from the startup to the normal operation stage, it can send the data blocks to the target host in advance based on the order and store them in the target host's disk to improve the interactive experience of the target host during the transmission process.
[0116] It can be understood that the controller corresponding to the source virtual machine will send the data block to the controller corresponding to the target virtual machine through the network. The controller of the target virtual machine will store the data block in the physical disk of the target virtual machine. When the target virtual machine needs to operate the data block, the controller corresponding to the target virtual machine will identify whether the data block has been transmitted to the physical disk of the target host. If it has been transmitted to the physical disk of the target host, the virtual machine will be directly allowed to access the physical disk through the virtual disk. If it has not been transmitted to the physical disk of the target host, the controller corresponding to the target virtual machine will block the access of the target virtual machine, pull the data of the source host through the network, and store it in the physical disk of the target host, and then cancel the blockage, so that the target virtual machine can access the physical disk through the virtual disk and perform corresponding data operations.
[0117] See also Figure 5 , Figure 5 Another flow chart of the data migration method of a virtual machine provided in the embodiment of the present application is shown in FIG. Figure 1 The controller of the source host shown in FIG. 1 is executed. For the sake of convenience, the memory is a disk as an example. Figure 5 As shown, the following steps are included:
[0118] Step 501: The controller receives a read / write request for a first data block sent by a target host.
[0119] In this step, after the target host receives the read / write request for the first data block, if the target host does not find the data block in the disk of the target host, it will send a read / write request for the data block to the source host. After receiving the read / write request for the data block sent by the target host, the controller can perform analysis based on the read / write request.
[0120] Step 502: The controller determines location information corresponding to the first data block according to a read / write request of the first data block.
[0121] In this step, after receiving the read / write request of the data block, the controller of the source host can obtain the location information corresponding to the first data block.
[0122] Optionally, the location of the data includes an offset and a length corresponding to the first data block in the memory.
[0123] Step 503: The controller determines the file to which the first data block belongs in the memory according to the location information.
[0124] In this step, the controller can determine the file to which the first data block belongs in the disk according to the location information of the first data block, and send the rest of the data of the file except the data to the target host to improve data transmission efficiency and optimize the user experience during the migration process.
[0125] In one example, a virtual machine running on a Linux operating system is used as an example. Figure 6 , Figure 6 A schematic diagram of a disk management structure provided in an embodiment of the present application. Figure 6 As shown in the figure, vda, vdb, and sda all represent the drive letters of the disk under the Linux system, and mbr and gpt represent common partition table types. Disk partitions can be created based on different partition tables. Lvm can be created on top of the disk partition, and finally partitions are performed on lvm, and a file system is created. Taking the management method of vda as an example, the disk is divided into two disk partitions, vda1 and vda2, through the mbr partition format. vda1 is directly formatted as the ext4 file system and used as the / boot partition, while vda2 is managed through lvm, and two logical partitions are created on lvm, formatted as ext4 file systems, and mounted to / and / home for user use.
[0126] The controller Figure 6 By parsing the disk management structure shown in the figure, the offset and length corresponding to any file in the disk can be accurately obtained. Among them, the file may be discretely distributed at any location on the disk. Please refer to Figure 7 , Figure 7 A file distribution diagram of disk management provided in an embodiment of the present application. Figure 7 In the figure, File1-Flie4 represent the location of a file in the file system, where a file can correspond to a continuous segment on the disk or multiple discrete segments on the disk. The controller can obtain the location of the disk segment corresponding to any file by parsing the disk structure, that is, the offset + the length of the location, and can determine the file (such as File1-Flie4) to which the location of any data belongs.
[0127] During the migration process, the controller of the source host (source end) analyzes the I / O generated by the target host (destination end), identifies the file corresponding to the offset of the current I / O, and transfers the file first. Assume that the controller of the source host recognizes that the target host has accessed I / O (offset = 102400, length = 4096), and the controller analyzes that the offset 102400 of the I / O belongs to the file redis0001.rdb, which is the persistent file of Redis, and then transfers the rest of the file first to achieve smooth operation of Redis on the target host.
[0128] Step 504: The controller sends the file to which the first data block belongs in the disk to the target host.
[0129] See also Figure 8 , Figure 8 Another flow chart of the data migration method of a virtual machine provided in the embodiment of the present application is shown in FIG. Figure 1 The controller of the source host shown in FIG. 1 is executed. For the sake of convenience, the memory is a disk as an example. Figure 8 As shown, the following steps are included:
[0130] Step 801: The controller obtains the used space in the disk.
[0131] In this step, the controller analyzes the disk characteristics, identifies the used space in the disk, and transmits only the data in the used space instead of transmitting all the space of the disk to the target host, thereby further reducing the amount of data transmission.
[0132] It can be understood that the data transmission volume mentioned in this embodiment is based on the same sending method. For example, without considering the data transmission in a compressed manner, compared with the current full copy method, this solution can further reduce the data transmission volume.
[0133] Step 802: The controller sends to the target host only all the data in the used space in the disk.
[0134] It is worth mentioning that Figure 4 , Figure 5 as well as Figure 8 The embodiments shown can be implemented separately, in combination with any two embodiments, or together when implemented specifically, and can be set according to actual needs, which is not limited here. For example, in the process of the source host migrating the data of the virtual machine to the target host, in the startup phase, the controller of the source host can transmit the data blocks required for startup in advance based on the priority information of the data blocks to achieve the rapid startup of the virtual machine of the target host. During operation, the controller of the source host can only transmit the data in the used space in the disk, thereby reducing the amount of data transmission. In addition, when the target host determines that the data block is not in the disk of the target host, the source host receives the read / write request of the data block sent by the target host, and sends the file to which the data block belongs in the disk to the target host together, so as to improve the efficiency of data transmission. By accurately identifying the data required for each stage of migration, the data is transmitted in advance to achieve the rapid reconstruction and smooth operation of the virtual machine of the target host. In addition, compared with the current full copy method, the method provided by this embodiment can be started across clouds, and only the data blocks corresponding to the used data in the disk need to be transmitted, thereby further reducing the system startup time and the total network transmission volume.
[0135] exist Figures 1 to 8On the basis of the corresponding embodiments, in order to better implement the above solutions of the embodiments of the present application, the following also provides related devices for implementing the above solutions. Figure 9a , Figure 9a A schematic diagram of a structure of a data migration device for a virtual machine provided in an embodiment of the present application. The data migration device 900 for the virtual machine may be located at Figure 1 In the source host shown, the controller is responsible for execution. The data of the virtual machine includes at least two data blocks, and the data migration device 900 of the virtual machine includes:
[0136] The data analysis module 901 is used to obtain priority information corresponding to at least two data blocks when the migration condition is met;
[0137] The data analysis module 901 is further used to determine the migration order of at least two data blocks according to the priority information respectively corresponding to the at least two data blocks;
[0138] The data transmission module 902 is used to send at least two data blocks to the target host according to the migration sequence.
[0139] For an example, see Figure 9b , Figure 9b Another schematic diagram of the architecture of virtual machine migration provided in the embodiment of the present application. The specific structure of the source host 1 and the target host 2 can be found in Figure 1 ,exist Figure 9b In the embodiment, the structure of the data migration device 900 of the virtual machine is mainly described. Taking the storage device as a disk as an example, assuming that the data migration device 900 of the virtual machine runs on the transmission agent module 121, the data migration device 900 of the virtual machine includes a data analysis module 901 and a data transmission module 902, and the data analysis module 901 includes a priority data identification unit 9011, a disk space identification unit 9012 and a disk analysis unit 9013.
[0140] Among them, the priority data identification unit 9011 is mainly used to identify the priority information of each data block corresponding to the data of the virtual machine, the disk space identification unit 9012 is mainly used to identify the size of the space occupied by the data of the virtual machine on the disk, and the disk parsing unit 9013 is used to determine the file to which the data block belongs in the file system corresponding to the disk according to the received read / write request of the data block.
[0141] In a possible implementation, during the startup of a virtual machine of the target host, the order in which the virtual machine loads the data blocks during the startup process is related to the priority information of the data blocks;
[0142] The priority data identification unit 9011 is also used for:
[0143] Obtaining a loading sequence of at least two data blocks during a startup process of a virtual machine of a target host;
[0144] Priority information of at least two data blocks is determined according to the sequence, wherein the priority of a data block that is earlier in the sequence is higher than the priority of a data block that is later in the sequence.
[0145] In a possible implementation of the second aspect, the data transmission module 902 is further configured to receive a read / write request for the first data block sent by a target host;
[0146] The disk parsing unit 9013 is further used to determine the position information corresponding to the first data block according to the read / write request of the first data block;
[0147] The disk parsing unit 9013 is further used to determine the file to which the first data block belongs in the memory according to the location information;
[0148] The data transmission module 902 is further configured to send the file to which the first data block belongs in the memory to the target host.
[0149] In a possible implementation manner of the second aspect, the position information corresponding to the first data block includes an offset and a length corresponding to the first data block in the memory.
[0150] In a possible implementation of the second aspect, the disk space identification unit 9012 is further used to obtain the used space in the memory;
[0151] The data transmission module 902 is also used to send to the target host only all the data in the used space in the memory.
[0152] It is understandable that the module composition of the data migration device 900 of the virtual machine and the module composition of the data analysis module 901 can be set according to actual needs. This is only an example and not a limitation.
[0153] In this embodiment, the operations performed by each unit in the virtual machine data migration device 900 are the same as those described above. Figure 4 The method described in the illustrated embodiment is similar and can be used to implement the functions of the computing device in the above method embodiment, and can also achieve the beneficial effects possessed by the above method embodiment, which will not be described in detail here.
[0154] The present application also provides a computing device 1000. Fig.10 , Fig.10 A schematic diagram of a computing device provided in an embodiment of the present application. Fig.10As shown, computing device 1000 includes: bus 1002, processor 1004, memory 1006 and communication interface 1008. Processor 1004, memory 1006 and communication interface 1008 communicate through bus 1002. Computing device 1000 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in computing device 1000.
[0155] The bus 1002 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 The bus 1002 may include a path for transmitting information between various components of the computing device 1000 (eg, the memory 1006, the processor 1004, and the communication interface 1008).
[0156] The processor 1004 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0157] The memory 1006 may include a hard disk drive (HDD), a solid state drive (SSD), or other disks.
[0158] The memory 1006 stores executable program codes, and the processor 1004 executes the executable program codes to respectively implement the functions of the aforementioned data analysis module 901 and the data transmission module 902, thereby implementing the data migration method of the virtual machine. That is, the memory 1006 stores instructions for executing the data migration method of the virtual machine.
[0159] The communication interface 1008 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1000 and other devices or a communication network.
[0160] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0161] See also Fig.11 , Fig.11 A schematic diagram of a computing device cluster provided in an embodiment of the present application. Fig.11 As shown, the computing device cluster includes at least one computing device 1000. The memory 1006 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the data migration method of the virtual machine.
[0162] In some possible implementations, the memory 1006 of one or more computing devices 1000 in the computing device cluster may also store partial instructions for executing the data migration method of the virtual machine. In other words, the combination of one or more computing devices 1000 may jointly execute the instructions for executing the data migration method of the virtual machine.
[0163] It should be noted that the memory 1006 in different computing devices 1000 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the data migration device of the virtual machine. That is, the instructions stored in the memory 1006 in different computing devices 1000 can implement the functions of one or more modules in the data analysis module 901 and the data transmission module 902.
[0164] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.12 shows a possible implementation. Fig.12 , Fig.12 Another structural diagram of a computing device cluster provided in an embodiment of the present application. Fig.12 As shown, two computing devices 1000A and 1000B are connected via a network. Specifically, they are connected to the network via a communication interface in each computing device. In this type of possible implementation, the memory 1006 in the computing device 1000A stores instructions for executing the functions of the data parsing module 901. At the same time, the memory 1006 in the computing device 1000B stores instructions for executing the functions of the data transmission module 902.
[0165] It should be understood that Fig.12The functions of the computing device 1000A shown in FIG. 1000A may also be completed by multiple computing devices 1000. Similarly, the functions of the computing device 1000B may also be completed by multiple computing devices 1000.
[0166] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes a data migration method for a virtual machine.
[0167] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by the computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the data migration method of the virtual machine, or instruct the computing device to execute the data migration method of the virtual machine.
[0168] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0169] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0170] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0171] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0172] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., and other media that can store program codes.
Claims
1. A method for migrating data of a virtual machine, characterized in that: The data of the virtual machine includes at least two data blocks, and the method includes: When the migration condition is met, obtaining priority information respectively corresponding to the at least two data blocks; Determining a migration order of the at least two data blocks according to priority information respectively corresponding to the at least two data blocks; The at least two data blocks are sent to the target host according to the migration sequence.
2. The method according to claim 1, characterized in that During the startup of the virtual machine of the target host, the order in which the virtual machine loads the data blocks during the startup process is related to the priority information of the data blocks; Obtaining priority information corresponding to the at least two data blocks respectively includes: Obtaining a loading sequence of the at least two data blocks during startup of the virtual machine of the target host; Priority information of the at least two data blocks is determined according to the sequence, wherein the priority of the data block at the front of the sequence is higher than the priority of the data block at the back of the sequence.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: Receiving a read / write request for a first data block sent by the target host; Determine the location information corresponding to the first data block according to the read / write request of the first data block; Determine the file to which the first data block belongs in the memory according to the location information; The file to which the first data block belongs in the memory is sent to the target host.
4. The method according to claim 3, characterized in that The location information corresponding to the first data block includes an offset and a length corresponding to the first data block in the memory.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Obtaining the used space in the memory; Only all data in the used space in the memory is sent to the target host.
6. A data migration device for a virtual machine, characterized in that: The data of the virtual machine includes at least two data blocks, and the device includes: A data parsing module, used for obtaining priority information corresponding to the at least two data blocks respectively when the migration condition is met; The data analysis module is further used to determine the migration order of the at least two data blocks according to the priority information respectively corresponding to the at least two data blocks; The data transmission module is used to send the at least two data blocks to the target host according to the migration sequence.
7. The device according to claim 6, characterized in that During the startup of the virtual machine of the target host, the order in which the virtual machine loads the data blocks during the startup process is related to the priority information of the data blocks; The data parsing module is also used for: Obtaining a loading sequence of the at least two data blocks during startup of the virtual machine of the target host; Priority information of the at least two data blocks is determined according to the sequence, wherein the priority of the data block at the front of the sequence is higher than the priority of the data block at the back of the sequence.
8. The device according to claim 6 or 7, characterized in that The data transmission module is further used to receive a read / write request for the first data block sent by the target host; The data parsing module is further used to determine the position information corresponding to the first data block according to the read / write request of the first data block; The data parsing module is further used to determine the file to which the first data block belongs in the memory according to the location information; The data transmission module is further configured to send the file to which the first data block belongs in the memory to the target host.
9. The device according to claim 8, characterized in that The location information corresponding to the first data block includes an offset and a length corresponding to the first data block in the memory.
10. The device according to any one of claims 6 to 9, characterized in that The data parsing module is further used to obtain the used space in the memory; The data transmission module is further configured to send to the target host only all data in the used space in the memory.
11. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 5.
12. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the method according to any one of claims 1 to 5.
13. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 5.