CN115292000A - A method, device and electronic device for dynamic migration of virtual machine - Google Patents
A method, device and electronic device for dynamic migration of virtual machine Download PDFInfo
- Publication number
- CN115292000A CN115292000A CN202210877002.3A CN202210877002A CN115292000A CN 115292000 A CN115292000 A CN 115292000A CN 202210877002 A CN202210877002 A CN 202210877002A CN 115292000 A CN115292000 A CN 115292000A
- Authority
- CN
- China
- Prior art keywords
- type
- virtual machine
- register
- data
- preset
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
- G06F9/5088—Techniques for rebalancing the load in a distributed system involving task migration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/4557—Distribution of virtual machine instances; Migration and load balancing
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
一种虚拟机动态迁移的方法、装置及电子设备,该方法包括:确定出源主机上的待迁移虚拟机的类型,响应于类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储,将数据结构添加至待迁移虚拟机的迁移传输数据中,基于迁移传输数据将待迁移虚拟机从源主机迁移至目标主机。通过上述的方法,将迁移传输数据从源主机迁移至目标主机,从而实现基于硬件透传虚拟机的迁移,将迁移传输数据传输至目标主机之后,能够使得虚拟机在目标主机上恢复运行。
A method, device, and electronic device for virtual machine dynamic migration, the method includes: determining the type of a virtual machine to be migrated on a source host, and in response to the type being consistent with a preset type, converting data corresponding to a qualified interrupt controller The structure is stored, the data structure is added to the migration and transmission data of the virtual machine to be migrated, and the virtual machine to be migrated is migrated from the source host to the target host based on the migration and transmission data. Through the above method, the migration and transmission data is migrated from the source host to the target host, thereby realizing the migration of the virtual machine based on hardware transparent transmission. After the migration and transmission data is transmitted to the target host, the virtual machine can be resumed on the target host.
Description
技术领域technical field
本申请涉及云计算虚拟化技术领域,尤其涉及一种虚拟机动态迁移的方法、装置及电子设备。The present application relates to the technical field of cloud computing virtualization, and in particular to a method, device and electronic equipment for dynamic migration of a virtual machine.
背景技术Background technique
随着云计算虚拟化技术的发展,虚拟机的动态迁移是在确保虚拟机服务正常运行的同时,将一个虚拟机系统从一个物理主机移动到另一个物理主机的过程,该过程不会对用户造成明显的影响,从而使得管理员能够在不影响用户正常使用的情况下,对物理主机进行离线维修或升级。With the development of cloud computing virtualization technology, the dynamic migration of virtual machines is the process of moving a virtual machine system from one physical host to another while ensuring the normal operation of virtual machine services. Cause obvious impact, so that the administrator can perform offline maintenance or upgrade on the physical host without affecting the normal use of users.
为了确保迁移过程中虚拟机服务可用,迁移过程仅占据非常短暂的停机时间,动态迁移实际上是将虚拟机的配置封装在一个文件中,然后通过高速网络,把虚拟机配置和内存运行状态从源主机迅速传送到目的主机上,从而达到源主机将控制权转移到目的主机,并使得虚拟机系统在目的主机上继续运行,进而实现虚拟机的动态迁移。In order to ensure that the virtual machine service is available during the migration process, the migration process only occupies a very short downtime. Live migration actually encapsulates the configuration of the virtual machine in a file, and then transfers the virtual machine configuration and memory running status from The source host is quickly transferred to the destination host, so that the source host transfers the control right to the destination host, and the virtual machine system continues to run on the destination host, thereby realizing the dynamic migration of the virtual machine.
目前,虚拟机的动态迁移是基于软件实现,缺乏硬件透传虚拟机的迁移技术。At present, the dynamic migration of virtual machines is implemented based on software, and there is a lack of migration technology for hardware transparent transmission of virtual machines.
发明内容Contents of the invention
本申请提供了一种虚拟机动态迁移的方法、装置及电子设备,基于硬件实现虚拟机的动态迁移。The present application provides a method, device and electronic equipment for dynamic migration of a virtual machine, which realize dynamic migration of a virtual machine based on hardware.
第一方面,本申请提供了一种虚拟机动态迁移的方法,所述方法包括:In a first aspect, the present application provides a method for live migration of a virtual machine, the method comprising:
确定出源主机上的待迁移虚拟机的类型;Determine the type of the virtual machine to be migrated on the source host;
响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;In response to the type being consistent with the preset type, storing the data structure corresponding to the qualified interrupt controller;
将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;adding the data structure to the migration transmission data of the virtual machine to be migrated;
基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。The virtual machine to be migrated is migrated from a source host to a target host based on the migration transmission data.
通过上述的方法,将源主机上的虚拟机的类型进行分类之后,通过将包含数据结构的迁移传输数据进行存储,从而能够实现将虚拟机从源主机迁移至目标主机,并且,也能够恢复目标主机的寄存器。Through the above method, after classifying the type of the virtual machine on the source host, by storing the migration transmission data including the data structure, the virtual machine can be migrated from the source host to the target host, and the target host can also be restored. Host registers.
在一种可能的设计中,响应于所述类型与预设类型一致,包括:In a possible design, in response to the type being consistent with a preset type, it includes:
将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配;matching the type of the virtual machine to be migrated with each preset type in the preset type set;
当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。When a preset type consistent with the type is matched, it is responded that the type is consistent with the preset type.
通过上述的方法,将待迁移虚拟机的类型与虚拟机的各个预设类型进行匹配,当待迁移虚拟机匹配到与预设类型一致的虚拟机时,确定待迁移虚拟机符合预设类型的虚拟机,从而实现基于虚拟机的类型对虚拟机进行筛选。Through the above method, the type of the virtual machine to be migrated is matched with each preset type of the virtual machine, and when the virtual machine to be migrated is matched with a virtual machine of the preset type, it is determined that the virtual machine to be migrated conforms to the preset type Virtual machine, so as to realize the filtering of virtual machines based on the type of the virtual machine.
在一种可能的设计中,将符合条件的中断控制器对应的数据结构进行存储,包括:In a possible design, the data structure corresponding to the qualified interrupt controller is stored, including:
提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据;Extracting the interrupt controller of the type, and extracting the register type of the register in the interrupt controller and the data corresponding to the register;
将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。Associating the register type with the data, generating a data structure, and storing the data structure.
通过上述的方法,确定出该类型的中断控制器,并提取出中断控制器中的寄存器的类型以及数据,并将该类型以及数据进行关联,生成数据结构,并将该数据结构进行存储,确保了能够实现对虚拟机的恢复。Through the above method, determine the type of interrupt controller, and extract the type and data of the register in the interrupt controller, and associate the type and data to generate a data structure, and store the data structure to ensure In order to be able to restore the virtual machine.
在一种可能的设计中,基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机之后,包括:In a possible design, after migrating the virtual machine to be migrated from the source host to the target host based on the migration transmission data, the steps include:
控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机;controlling the CPU on the target host to start and recover the virtual machine of the interrupt controller of the type;
提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器;Extracting a preset register in the type of interrupt controller, and reading the preset register;
将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。Inputting the register data into the preset register realizes the injection of the register data.
通过上述的方法,服务器控制目标主机启动并恢复中断控制器对应的虚拟机,并将寄存器数据输入中断控制器中的寄存器中,实现终端程序的注入。Through the above method, the server controls the target host to start and restore the virtual machine corresponding to the interrupt controller, and inputs the register data into the register in the interrupt controller to realize the injection of the terminal program.
第二方面,本申请提供了一种虚拟机动态迁移的装置,所述装置包括:In a second aspect, the present application provides an apparatus for live migration of a virtual machine, the apparatus comprising:
确定模块,用于确定出源主机上的待迁移虚拟机的类型;A determining module, configured to determine the type of the virtual machine to be migrated on the source host;
存储模块,用于响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;a storage module, configured to store the data structure corresponding to the qualified interrupt controller in response to the type being consistent with the preset type;
匹配模块,用于将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;A matching module, configured to add the data structure to the migration transmission data of the virtual machine to be migrated;
迁移模块,用于基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。A migration module, configured to migrate the virtual machine to be migrated from the source host to the target host based on the migration transfer data.
在一种可能的设计中,所述存储模块,具体用于将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配,当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。In a possible design, the storage module is specifically configured to match the type of the virtual machine to be migrated with each preset type in the preset type set, and when a preset type consistent with the type is matched , responding that the type is consistent with the preset type.
在一种可能的设计中,所述存储模块,还用于提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据,将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。In a possible design, the storage module is further configured to extract the type of interrupt controller, and extract the register type of the register in the interrupt controller and the data corresponding to the register, and store the The register type is associated with the data, a data structure is generated, and the data structure is stored.
在一种可能的设计中,所述迁移模块,具体用于控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机,提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器,将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。In a possible design, the migration module is specifically configured to control the CPU on the target host to start and resume the virtual machine of the type of interrupt controller, and extract the preset Setting a register, reading the preset register, inputting the register data into the preset register, and realizing the injection of the register data.
第三方面,本申请提供了一种电子设备,包括:In a third aspect, the present application provides an electronic device, including:
存储器,用于存放计算机程序;memory for storing computer programs;
处理器,用于执行所述存储器上所存放的计算机程序时,实现上述的一种虚拟机动态迁移的方法步骤。The processor is configured to implement the above-mentioned method steps for live migration of a virtual machine when executing the computer program stored in the memory.
第四方面,一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述的一种虚拟机动态迁移的方法步骤。In a fourth aspect, a computer-readable storage medium stores a computer program in the computer-readable storage medium, and when the computer program is executed by a processor, the above-mentioned method steps for dynamic migration of a virtual machine are implemented.
上述第一方面至第四方面中的各个方面以及各个方面可能达到的技术效果请参照上述针对第一方面或第一方面中的各种可能方案可以达到的技术效果说明,这里不再重复赘述。For the various aspects and possible technical effects of the above-mentioned first to fourth aspects, please refer to the above description of the technical effects that can be achieved by the first aspect or various possible solutions in the first aspect, and will not be repeated here.
附图说明Description of drawings
图1为本申请提供的一种虚拟机动态迁移的方法步骤的流程图;Fig. 1 is the flowchart of the method step of a kind of virtual machine dynamic migration provided by the present application;
图2为本申请提供的物理lapic动态迁移源主机流程图;FIG. 2 is a flow chart of the physical lapic dynamic migration source host provided by this application;
图3为本申请提供的物理lapic动态迁移目标主机流程图;Fig. 3 is the flowchart of the physical lapic dynamic migration target host provided by the present application;
图4为本申请提供的一种虚拟机动态迁移的装置的结构示意图;FIG. 4 is a schematic structural diagram of a virtual machine dynamic migration device provided by the present application;
图5为本申请提供的一种电子设备的结构示意图。FIG. 5 is a schematic structural diagram of an electronic device provided by the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述。方法实施例中的具体操作方法也可以应用于装置实施例或系统实施例中。需要说明的是,在本申请的描述中“多个”理解为“至少两个”。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。A与B连接,可以表示:A与B直接连接和A与B通过C连接这两种情况。另外,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。In order to make the purpose, technical solution and advantages of the application clearer, the application will be further described in detail below in conjunction with the accompanying drawings. The specific operation methods in the method embodiments can also be applied to the device embodiments or system embodiments. It should be noted that in the description of the present application, "plurality" is understood as "at least two". "And/or" describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B may indicate: A exists alone, A and B exist simultaneously, and B exists independently. The connection between A and B can mean: A and B are directly connected and A and B are connected through C. In addition, in the description of the present application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
目前,为了实现虚拟机的动态迁移,采用的方式为基于软件以及apic模拟实现,在“lapic”透传的高性能虚拟机上,虚拟机直接使用物理lapic,由于物理lapic的状态在物理寄存器中,而基于软件以及lapic模拟是在软件的基础上实现的,因此,缺乏一种硬件透传虚拟机的动态迁移的方法。At present, in order to realize the dynamic migration of the virtual machine, the method is based on software and apic simulation. On the high-performance virtual machine with "lapic" transparent transmission, the virtual machine directly uses the physical lapic, because the state of the physical lapic is in the physical register , while the software-based and lapic simulations are implemented on the basis of software, therefore, there is a lack of a method for dynamic migration of virtual machines with hardware transparent transmission.
为了解决上述描述的问题,本申请实施例提供了一种虚拟机动态迁移的方法,用以基于硬件透传的虚拟机的动态迁移。其中,本申请实施例所述方法和装置基于同一技术构思,由于方法及装置所解决问题的原理相似,因此装置与方法的实施例可以相互参见,重复之处不再赘述。In order to solve the problems described above, an embodiment of the present application provides a method for live migration of a virtual machine, which is used for live migration of a virtual machine based on hardware transparent transmission. Wherein, the method and the device described in the embodiment of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can be referred to each other, and the repetition will not be repeated.
下面结合附图,对本申请实施例进行详细描述。The embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
参照图1,本申请提供了一种虚拟机动态迁移的方法,该方法可以实现基于硬件透传虚拟机的动态迁移,该方法的实现流程如下:Referring to FIG. 1, the present application provides a method for dynamic migration of a virtual machine, which can realize dynamic migration of a virtual machine based on hardware transparent transmission. The implementation process of the method is as follows:
步骤S1:确定出源主机上的待迁移虚拟机的类型。Step S1: Determine the type of the virtual machine to be migrated on the source host.
由于本申请实施例是为了实现基于硬件透传虚拟机动态迁移,因此,为了能够实现上述虚拟机的动态迁移,首先,需要确定出源主机上待迁移虚拟机的源主机的类型,待迁移主机的类型在本申请实施例中可以为能够增加“lapic”透传的虚拟机,本申请实施例中待迁移虚拟机为能够进行透传的虚拟机,需要补充的是,本申请文件中的lapic为中断控制器。Since the embodiment of the present application is to realize the dynamic migration of the virtual machine based on hardware transparent transmission, in order to realize the dynamic migration of the above-mentioned virtual machine, first, it is necessary to determine the type of the source host of the virtual machine to be migrated on the source host, and the host to be migrated In the embodiment of this application, the type of virtual machine that can add "lapic" transparent transmission can be added. In the embodiment of this application, the virtual machine to be migrated is a virtual machine that can perform transparent transmission. What needs to be added is that the lapic in this application document for the interrupt controller.
步骤S2:响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储。Step S2: In response to the type being consistent with the preset type, store the data structure corresponding to the qualified interrupt controller.
上述已经确定出了待迁移虚拟机的类型,为了确保待迁移虚拟机为指定类型的虚拟机,需要将待迁移虚拟机的类型与预设类型集中的各个预设类型进行匹配,若该类型匹配出一致的预设类型,则代表该类型在预设类型中;若该类型未匹配出一致的预设类型,则代表该类型不在预设类型中。The type of the virtual machine to be migrated has been determined above. In order to ensure that the virtual machine to be migrated is a specified type of virtual machine, it is necessary to match the type of the virtual machine to be migrated with each preset type in the preset type set. If the type matches If a consistent preset type is found, it means that the type is in the preset type; if the type does not match a consistent preset type, it means that the type is not in the preset type.
当该类型与预设类型一致时,将确定出该类型对应的中断控制器,每一个中断控制器都存在一个寄存器,该寄存器用于读和/或写,再从该中断控制器中提取出寄存器的寄存器类型以及该寄存器对应的数据,该寄存器的类型可以为:TPR、APR、PPR、RRD、LDR、DFR、ICR、IRR、ISR、TMR、LVTT等,寄存器类型还可以为其他的类型,这里不做过多阐述。When the type is consistent with the preset type, the interrupt controller corresponding to the type will be determined. Each interrupt controller has a register, which is used for reading and/or writing, and then extracted from the interrupt controller. The register type of the register and the data corresponding to the register. The type of the register can be: TPR, APR, PPR, RRD, LDR, DFR, ICR, IRR, ISR, TMR, LVTT, etc. The register type can also be other types. I won't elaborate too much here.
获得寄存器的类型以及该寄存器对应的数据之后,将该类型以及数据进行关联,生成数据结构,并将该数据结构进行存储,需要进行说明的是,可以在调用kvm_vcpu_ioctl以及KVM_GET_LAPIC时,将数据结构添加至前述调用程序中,以及在kvm_apic_get_state函数中增加保存物理lapic数据结构的实现,主要实现为保存所有可读的物理lapic寄存器。After obtaining the register type and the data corresponding to the register, associate the type and data, generate a data structure, and store the data structure. It should be noted that the data structure can be added when calling kvm_vcpu_ioctl and KVM_GET_LAPIC In the aforementioned calling program, and in the kvm_apic_get_state function, the implementation of saving the physical lapic data structure is added, mainly to save all readable physical lapic registers.
步骤S3:将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;Step S3: adding the data structure to the migration transmission data of the virtual machine to be migrated;
上述描述数据结构的存储,在虚拟机的迁移过程中,KVM与QEMU结合用于实现虚拟机的迁移,QEMU是一款开源的模拟器以及虚拟机监管器,QEMU可以作为用户态模拟器,利用动态代码翻译机制来执行不同于主机架构的代码,QEMU还可以作为虚拟机监管器,模拟全系统,利用其他VMM(Xen,KVM,etc)来使用硬件提供的虚拟化支持,创建接近于主机性能的虚拟机,每个虚拟机对应主机(host)中的一个QEMU进程,而虚拟机的vcpu对应QEMU进程的一个线程,该vcpu为虚拟机的cpu。The above describes the storage of the data structure. During the migration process of the virtual machine, KVM and QEMU are combined to realize the migration of the virtual machine. QEMU is an open source simulator and a virtual machine supervisor. QEMU can be used as a user mode simulator, using Dynamic code translation mechanism to execute code different from the host architecture, QEMU can also be used as a virtual machine supervisor, simulate the whole system, use other VMMs (Xen, KVM, etc) to use the virtualization support provided by the hardware, and create performance close to the host Each virtual machine corresponds to a QEMU process in the host (host), and the vcpu of the virtual machine corresponds to a thread of the QEMU process, and the vcpu is the cpu of the virtual machine.
将数据结构进行存储之后,将数据结构添加至待迁移虚拟机的迁移传输数据中,并在目的端调用kvm_vcpu_ioctl或者KVM_SET_LAPIC时增加保存的物理lapic的数据结构。After the data structure is stored, the data structure is added to the migration transmission data of the virtual machine to be migrated, and the saved physical lapic data structure is added when the destination end calls kvm_vcpu_ioctl or KVM_SET_LAPIC.
基于上述的描述,将数据结构存储至迁移传输数据中,由于迁移传输数据保存在KVM中,因此,能够实现物理lapic状态的保存与恢复。Based on the above description, the data structure is stored in the migration transmission data. Since the migration transmission data is stored in the KVM, the preservation and restoration of the physical lapic state can be realized.
步骤S4:基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。Step S4: Migrate the virtual machine to be migrated from the source host to the target host based on the migration transfer data.
上述描述了将数据结构添加至待迁移虚拟机的迁移传输数据中,源主机向目标主机进行虚拟机的动态迁移时,服务器控制源主机将迁移传输数据迁移至目标主机,从而实现基于硬件透传虚拟机的动态迁移。The above description adds the data structure to the migration transmission data of the virtual machine to be migrated. When the source host performs dynamic migration of the virtual machine to the target host, the server controls the source host to migrate the migration transmission data to the target host, thereby realizing hardware-based transparent transmission. Live migration of virtual machines.
目标主机在接收迁移传输数据之后,目标主机将起启动并恢复上述类型的中断控制器对应的虚拟机,也可以根据qemu xml配置启动新的透传lapic的虚机,并恢复物理lapic。After the target host receives the migration and transmission data, the target host will start and restore the virtual machine corresponding to the above-mentioned type of interrupt controller, or start a new transparent lapic virtual machine according to the qemu xml configuration, and restore the physical lapic.
为了在寄存器中实现寄存器数据的注入,目标主机将关闭host下对应cpu中断,并恢复物理lapic普通寄存器,再读取irr/isr寄存器,按中断号向寄存器中重新注入对应中断,最后,服务器将控制目标主机恢复虚机运行。In order to realize the injection of register data in the register, the target host will close the corresponding CPU interrupt under the host, and restore the physical lapic common register, then read the irr/isr register, re-inject the corresponding interrupt into the register according to the interrupt number, and finally, the server will Control the target host to resume virtual machine operation.
具体的,物理lapic动态迁移源主机流程图如图2所示,在图2中,源主机中有QEMU以及KVM,QEMU为硬件虚拟化程序,调用函数kvm_get_apic调取kvm_vcpu_ioctl或者KVM_GET_LAPIC,由于源主机在迁移动态虚拟机时,guest存在于虚拟机上,host存在于主机上,在实现虚拟机的迁移的过程中,需要保证host中断关闭,指定cpu退出到host,再通过程序kvm_vcpu_ioctl_get_lapic获取lapic状态,包括物理lapic的所有可读寄存器,通过bm_apic_get_state获取物理lapic状态,只保存非Reserved寄存器,再通过程序kvm_apic_get_state保存获取到的lapic状态,包括物理lapic状态,再将已保存的lapic状态迁移到目标主机,从而实现虚拟机从源主机上的迁移。Specifically, the flowchart of physical lapic dynamic migration source host is shown in Figure 2. In Figure 2, there are QEMU and KVM in the source host, QEMU is a hardware virtualization program, calling the function kvm_get_apic to call kvm_vcpu_ioctl or KVM_GET_LAPIC, because the source host is When migrating a dynamic virtual machine, the guest exists on the virtual machine, and the host exists on the host. In the process of migrating the virtual machine, it is necessary to ensure that the host is interrupted and closed, and the specified cpu exits to the host, and then the lapic state is obtained through the program kvm_vcpu_ioctl_get_lapic, including All readable registers of the physical lapic, get the physical lapic state through bm_apic_get_state, save only non-Reserved registers, and then save the obtained lapic state through the program kvm_apic_get_state, including the physical lapic state, and then migrate the saved lapic state to the target host, so that Enables the migration of virtual machines from the source host.
源主机将虚拟机发送至目标主机之后,物理lapic动态迁移目标主机流程图如图3所示,在图3中,目标主机的QEMU接收到源主机发送的lapic状态数据之后,程序kvm_put_apic_state将读取保存的lapic状态信息,包括物理lapic,再基于程序kvm_apic_put以及程序kvm_vcpu_ioctl或者KVM_SET_LAPIC在关闭host中断的情况下,读取lapic状态,包括物理lapic寄存器到kvm中,通过程序bm_apic_set_state设置物理lapic状态,对部分可读写寄存器直接写入kvm中,由于中断请求寄存器以及中断处理寄存器为只读寄存器,因此,需要在中断请求寄存器以及中断处理寄存器中重新注入对应中断,上述已经描述了在寄存器中注入对应中断,当在寄存器中程序注入中断之后,返回QEMU,并完成后续迁移恢复流程,目标主机上的迁移恢复流程借宿之后,启动指定的cpu,最后通过程序kvm_vcpu_ioctl以及KVM_RUN重新进入KVM中的guest,物理lapic恢复运行,从而实现虚拟机从源主机迁移至目标主机以及迁移的虚拟机在目标主机上恢复运行的目的。After the source host sends the virtual machine to the target host, the flow chart of physical lapic dynamic migration to the target host is shown in Figure 3. In Figure 3, after the QEMU of the target host receives the lapic state data sent by the source host, the program kvm_put_apic_state will read Saved lapic state information, including physical lapic, and then based on the program kvm_apic_put and program kvm_vcpu_ioctl or KVM_SET_LAPIC when the host interrupt is turned off, read the lapic state, including the physical lapic register to kvm, and set the physical lapic state through the program bm_apic_set_state, for some The readable and writable registers are directly written into kvm. Since the interrupt request register and the interrupt processing register are read-only registers, it is necessary to re-inject the corresponding interrupt in the interrupt request register and the interrupt processing register. The injection of the corresponding interrupt in the register has been described above. , after the program injection interrupt in the register, return to QEMU, and complete the subsequent migration and recovery process. After the migration and recovery process on the target host stays overnight, start the specified cpu, and finally re-enter the guest in KVM through the program kvm_vcpu_ioctl and KVM_RUN, physical lapic Resume running, so as to realize the purpose of migrating the virtual machine from the source host to the target host and resuming the running of the migrated virtual machine on the target host.
基于上述的方法,基于待迁移虚拟机的类型对数据结构进行存储,并将数据结构添加至迁移传输数据中,并通过将迁移传输数据从源主机发送至目标主机的方式,实现基于硬件透传虚拟机的动态迁移。Based on the above method, the data structure is stored based on the type of the virtual machine to be migrated, and the data structure is added to the migration transmission data, and the hardware-based transparent transmission is realized by sending the migration transmission data from the source host to the target host Live migration of virtual machines.
基于同一发明构思,本申请实施例中还提供了一种虚拟机动态迁移的装置,该虚拟机动态迁移的装置用于实现了一种虚拟机动态迁移的方法的功能,参照图4,所述装置包括:Based on the same inventive concept, an embodiment of the present application also provides a device for dynamic migration of a virtual machine, the device for dynamic migration of a virtual machine is used to realize the function of a method for dynamic migration of a virtual machine, referring to Figure 4, the Devices include:
确定模块401,用于确定出源主机上的待迁移虚拟机的类型;A determining
存储模块402,用于响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;The
匹配模块403,用于将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;A
迁移模块404,用于基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。The
在一种可能的设计中,所述存储模块402,具体用于将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配,当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。In a possible design, the
在一种可能的设计中,所述存储模块402,还用于提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据,将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。In a possible design, the
在一种可能的设计中,所述迁移模块404,具体用于控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机,提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器,将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。In a possible design, the
基于同一发明构思,本申请实施例中还提供了一种电子设备,所述电子设备可以实现前述一种虚拟机动态迁移的装置的功能,参考图5,所述电子设备包括:Based on the same inventive concept, an electronic device is also provided in the embodiment of the present application, and the electronic device can realize the function of the aforementioned virtual machine dynamic migration device. Referring to FIG. 5, the electronic device includes:
至少一个处理器501,以及与至少一个处理器501连接的存储器502,本申请实施例中不限定处理器501与存储器502之间的具体连接介质,图5中是以处理器501和存储器502之间通过总线500连接为例。总线500在图5中以粗线表示,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。总线500可以分为地址总线、数据总线、控制总线等,为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。或者,处理器501也可以称为控制器,对于名称不做限制。At least one
在本申请实施例中,存储器502存储有可被至少一个处理器501执行的指令,至少一个处理器501通过执行存储器502存储的指令,可以执行前文论述的一种虚拟机动态迁移的方法。处理器501可以实现图4所示的装置中各个模块的功能。In this embodiment of the present application, the
其中,处理器501是该装置的控制中心,可以利用各种接口和线路连接整个该控制设备的各个部分,通过运行或执行存储在存储器502内的指令以及调用存储在存储器502内的数据,该装置的各种功能和处理数据,从而对该装置进行整体监控。Wherein, the
在一种可能的设计中,处理器501可包括一个或多个处理单元,处理器501可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器501中。在一些实施例中,处理器501和存储器502可以在同一芯片上实现,在一些实施例中,它们也可以在独立的芯片上分别实现。In a possible design, the
处理器501可以是通用处理器,例如中央处理器(CPU)、数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本申请实施例中公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本申请实施例所公开的一种虚拟机动态迁移的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。The
存储器502作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。存储器502可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random AccessMemory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性存储器、磁盘、光盘等等。存储器502是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本申请实施例中的存储器502还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。The
通过对处理器501进行设计编程,可以将前述实施例中介绍的一种虚拟机动态迁移的方法所对应的代码固化到芯片内,从而使芯片在运行时能够执行图1所示的实施例的一种虚拟机动态迁移的步骤。如何对处理器501进行设计编程为本领域技术人员所公知的技术,这里不再赘述。By designing and programming the
基于同一发明构思,本申请实施例还提供一种存储介质,该存储介质存储有计算机指令,当该计算机指令在计算机上运行时,使得计算机执行前文论述的一种虚拟机动态迁移的方法。Based on the same inventive concept, the embodiment of the present application also provides a storage medium, the storage medium stores computer instructions, and when the computer instructions are run on the computer, the computer executes the virtual machine live migration method discussed above.
在一些可能的实施方式中,本申请提供一种虚拟机动态迁移的方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当程序产品在装置上运行时,程序代码用于使该控制设备执行本说明书上述描述的根据本申请各种示例性实施方式的一种虚拟机动态迁移的方法中的步骤。In some possible implementations, various aspects of the method for dynamic migration of a virtual machine provided by the present application may also be implemented in the form of a program product, which includes program code. When the program product runs on the device, the program code uses The control device executes the steps in a method for live migration of a virtual machine according to various exemplary embodiments of the present application described above in this specification.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the application without departing from the spirit and scope of the application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.
Claims (10)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210877002.3A CN115292000B (en) | 2022-07-25 | 2022-07-25 | Method, device and electronic device for dynamic migration of virtual machines |
| PCT/CN2022/141594 WO2024021480A1 (en) | 2022-07-25 | 2022-12-23 | Method and apparatus for dynamic migration of virtual machine, and electronic device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210877002.3A CN115292000B (en) | 2022-07-25 | 2022-07-25 | Method, device and electronic device for dynamic migration of virtual machines |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN115292000A true CN115292000A (en) | 2022-11-04 |
| CN115292000B CN115292000B (en) | 2025-02-28 |
Family
ID=83823896
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210877002.3A Active CN115292000B (en) | 2022-07-25 | 2022-07-25 | Method, device and electronic device for dynamic migration of virtual machines |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN115292000B (en) |
| WO (1) | WO2024021480A1 (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2024021480A1 (en) * | 2022-07-25 | 2024-02-01 | 天翼云科技有限公司 | Method and apparatus for dynamic migration of virtual machine, and electronic device |
| CN117648155A (en) * | 2023-07-18 | 2024-03-05 | 武汉大学中南医院 | Virtual machine online migration method, device, computer equipment and storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106648826A (en) * | 2016-09-09 | 2017-05-10 | 北京百度网讯科技有限公司 | Method and device for live migration of virtual machine |
| US20200174817A1 (en) * | 2018-11-29 | 2020-06-04 | Shanghai Jiao Tong University | Giantvm for resource aggregation |
| CN111857968A (en) * | 2020-07-29 | 2020-10-30 | 山东超越数控电子股份有限公司 | Method, system, device and medium for live migration of virtual machine |
| CN114237814A (en) * | 2021-11-17 | 2022-03-25 | 上海浦东发展银行股份有限公司 | Virtual machine migration method, apparatus and computer equipment across virtualization platforms |
| US20220206840A1 (en) * | 2019-09-25 | 2022-06-30 | Alibaba Group Holding Limited | Timer Processing Method, Apparatus, Electronic Device and Computer Storage Medium |
| CN114691300A (en) * | 2022-03-25 | 2022-07-01 | 阿里巴巴(中国)有限公司 | Hot migration method of virtual machine instance |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7383405B2 (en) * | 2004-06-30 | 2008-06-03 | Microsoft Corporation | Systems and methods for voluntary migration of a virtual machine between hosts with common storage connectivity |
| CN113326105B (en) * | 2021-08-04 | 2021-11-05 | 深圳市科力锐科技有限公司 | Hardware equipment configuration method, device and equipment based on host migration |
| CN115292000B (en) * | 2022-07-25 | 2025-02-28 | 天翼云科技有限公司 | Method, device and electronic device for dynamic migration of virtual machines |
-
2022
- 2022-07-25 CN CN202210877002.3A patent/CN115292000B/en active Active
- 2022-12-23 WO PCT/CN2022/141594 patent/WO2024021480A1/en not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106648826A (en) * | 2016-09-09 | 2017-05-10 | 北京百度网讯科技有限公司 | Method and device for live migration of virtual machine |
| US20200174817A1 (en) * | 2018-11-29 | 2020-06-04 | Shanghai Jiao Tong University | Giantvm for resource aggregation |
| US20220206840A1 (en) * | 2019-09-25 | 2022-06-30 | Alibaba Group Holding Limited | Timer Processing Method, Apparatus, Electronic Device and Computer Storage Medium |
| CN111857968A (en) * | 2020-07-29 | 2020-10-30 | 山东超越数控电子股份有限公司 | Method, system, device and medium for live migration of virtual machine |
| CN114237814A (en) * | 2021-11-17 | 2022-03-25 | 上海浦东发展银行股份有限公司 | Virtual machine migration method, apparatus and computer equipment across virtualization platforms |
| CN114691300A (en) * | 2022-03-25 | 2022-07-01 | 阿里巴巴(中国)有限公司 | Hot migration method of virtual machine instance |
Non-Patent Citations (1)
| Title |
|---|
| 杨子夜、周逸勋、陈海波、臧斌宇: "利用虚拟机动态迁移技术整合虚拟和模拟环境", 小型微型计算机系统, vol. 31, no. 03, 15 March 2010 (2010-03-15), pages 423 - 429 * |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2024021480A1 (en) * | 2022-07-25 | 2024-02-01 | 天翼云科技有限公司 | Method and apparatus for dynamic migration of virtual machine, and electronic device |
| CN117648155A (en) * | 2023-07-18 | 2024-03-05 | 武汉大学中南医院 | Virtual machine online migration method, device, computer equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN115292000B (en) | 2025-02-28 |
| WO2024021480A1 (en) | 2024-02-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11487523B2 (en) | Updating machine emulator | |
| US12014199B1 (en) | Virtualization extension modules | |
| WO2017114283A1 (en) | Method and apparatus for processing read/write request in physical host | |
| CN111813713B (en) | Data acceleration operation processing method, device and computer readable storage medium | |
| JP2011100431A (en) | Device and method for controlling virtual machine | |
| US9715403B2 (en) | Optimized extended context management for virtual machines | |
| US9880872B2 (en) | Post-copy based live virtual machines migration via speculative execution and pre-paging | |
| US12340207B2 (en) | Virtual machine update while keeping devices attached to the virtual machine | |
| CN112352221A (en) | Shared memory mechanism to support fast transfer of SQ/CQ pair communications between SSD device drivers and physical SSDs in virtualized environments | |
| CN111796912A (en) | Sunwei platform storage input and output device virtualization performance optimization method and system | |
| US10467078B2 (en) | Crash dump extraction of guest failure | |
| CN115292000A (en) | A method, device and electronic device for dynamic migration of virtual machine | |
| US10318329B2 (en) | Driver switch for live migration with an assigned device | |
| CN112099916B (en) | Virtual machine data migration method and device, computer equipment and storage medium | |
| CN109542829B (en) | Control method, device and electronic equipment of GPU equipment in multi-system | |
| CN107193633A (en) | A kind of batch creates the method and device of virtual machine | |
| CN107861795B (en) | Method, system and device for simulating physical TCM chip and readable storage medium | |
| US11409551B2 (en) | Emulating VPID correctly for a nested hypervisor | |
| CN105487898A (en) | A method of increasing the speed of batch startup and shutdown of virtual machines | |
| CN120067017A (en) | PCIE interrupt affinity remapping method, system, device and storage medium | |
| CN120610740A (en) | Configuration method of input/output memory management unit, electronic device and storage medium | |
| CN115390987A (en) | Method for supporting QXL display in ARM64 architecture virtual machine | |
| CN119180147A (en) | Event-driven simulation check point construction method, device, equipment and medium | |
| CN119961050A (en) | Virtual machine data processing method, system and electronic device | |
| CN103488522A (en) | Method for managing device of virtual machine and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |
