WO2024021480A1 - 一种虚拟机动态迁移的方法、装置及电子设备 - Google Patents

一种虚拟机动态迁移的方法、装置及电子设备 Download PDF

Info

Publication number
WO2024021480A1
WO2024021480A1 PCT/CN2022/141594 CN2022141594W WO2024021480A1 WO 2024021480 A1 WO2024021480 A1 WO 2024021480A1 CN 2022141594 W CN2022141594 W CN 2022141594W WO 2024021480 A1 WO2024021480 A1 WO 2024021480A1
Authority
WO
WIPO (PCT)
Prior art keywords
type
register
virtual machine
preset
data
Prior art date
Application number
PCT/CN2022/141594
Other languages
English (en)
French (fr)
Inventor
刘强
王夕波
王春林
阳春光
李成
韩丁
湛松涛
Original Assignee
天翼云科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 天翼云科技有限公司 filed Critical 天翼云科技有限公司
Publication of WO2024021480A1 publication Critical patent/WO2024021480A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • G06F9/5088Techniques for rebalancing the load in a distributed system involving task migration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing

Definitions

  • the present application relates to the field of cloud computing virtualization technology, and in particular to a method, device and electronic equipment for dynamic migration of virtual machines.
  • 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 the virtual machine service. This process will not cause any impact on users. Causes obvious impact, allowing administrators to perform offline maintenance or upgrades on physical hosts without affecting normal use of users.
  • Dynamic migration actually encapsulates the virtual machine configuration 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 control to the destination host, and the virtual machine system continues to run on the destination host, thereby realizing dynamic migration of the virtual machine.
  • This application provides a method, device and electronic device for dynamic migration of a virtual machine, which realizes dynamic migration of the virtual machine based on hardware.
  • this application provides a method for dynamic migration of virtual machines, which method includes:
  • the migration transmission data containing the data structure is stored, so that the virtual machine can be migrated from the source host to the target host, and the target can also be restored.
  • Host register After classifying the types of virtual machines on the source host, the migration transmission data containing the data structure is stored, so that the virtual machine can be migrated from the source host to the target host, and the target can also be restored.
  • responding to the type being consistent with the preset type includes:
  • the type of the virtual machine to be migrated is matched with each preset type of the virtual machine.
  • the virtual machine to be migrated matches a virtual machine that is consistent with the preset type, it is determined that the virtual machine to be migrated matches the preset type.
  • Virtual machines thereby filtering virtual machines based on their type.
  • the data structure corresponding to the interrupt controller that meets the conditions is stored, including:
  • the register type is associated with the data, a data structure is generated, and the data structure is stored.
  • the method after migrating the to-be-migrated virtual machine from the source host to the target host based on the migration transmission data, the method includes:
  • the register data is input into the preset register to realize the injection of register data.
  • 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.
  • this application provides a device for dynamic migration of virtual machines.
  • the device includes:
  • the determination module is used to determine the type of virtual machine to be migrated on the source host
  • a storage module configured to store the data structure corresponding to the interrupt controller that meets the conditions 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 transmission data.
  • 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. When a preset type consistent with the type is matched, when the response is that the type is consistent with the preset type.
  • the storage module is also used to extract the interrupt controller of the type, extract the register type of the register in the interrupt controller and the data corresponding to the register, and put the The register type is associated with the data, a data structure is generated, and the data structure is stored.
  • the migration module is specifically configured to control the CPU on the target host to start and restore the virtual machine of the interrupt controller of the type, and extract the preset information in the interrupt controller of the type. Set up a register, read the preset register, and input the register data into the preset register to realize the injection of register data.
  • this application provides an electronic device, including:
  • Memory used to store computer programs
  • the processor is configured to implement the above-mentioned method steps of dynamic migration of a virtual machine when executing the computer program stored on the memory.
  • a fourth aspect is a computer-readable storage medium.
  • a computer program is stored in the computer-readable storage medium.
  • the computer program is executed by a processor, the above-mentioned method steps for dynamic migration of a virtual machine are implemented.
  • Figure 1 is a flow chart of the steps of a virtual machine dynamic migration method provided by this application.
  • Figure 2 is a flow chart of the physical lapic dynamic migration source host provided by this application.
  • Figure 3 is a flow chart of the physical lapic dynamic migration target host provided by this application.
  • Figure 4 is a schematic structural diagram of a device for dynamic migration of virtual machines provided by this application.
  • Figure 5 is a schematic structural diagram of an electronic device provided by this application.
  • the method adopted is based on software and apic simulation.
  • the virtual machine directly uses the physical lapic, because the status of the physical lapic is in the physical register.
  • software-based and lapic simulations are implemented on the basis of software. Therefore, there is a lack of a method for dynamic migration of hardware transparent transmission virtual machines.
  • embodiments of the present application provide a method for dynamic migration of virtual machines, which is used for dynamic migration of virtual machines based on hardware transparent transmission.
  • the method and the device described in the embodiments 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 repeated descriptions will not be repeated.
  • this application provides a method for dynamic migration of virtual machines, which can realize dynamic migration of virtual machines based on hardware transparent transmission.
  • the implementation process of this method is as follows:
  • Step S1 Determine the type of virtual machine to be migrated on the source host.
  • the embodiment of this application is to realize the dynamic migration of virtual machines based on hardware transparent transmission
  • the type can be a virtual machine that can add "lapic" transparent transmission.
  • the virtual machine to be migrated is a virtual machine that can perform transparent transmission. It needs to be added that the lapic in this application document for the interrupt controller.
  • Step S2 In response to the type being consistent with the preset type, store the data structure corresponding to the interrupt controller that meets the conditions.
  • the type of virtual machine to be migrated has been determined above. In order to ensure that the virtual machine to be migrated is a virtual machine of the specified type, the type of the virtual machine to be migrated needs to be matched with each preset type in the preset type set. If the types match 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 among the preset types.
  • each interrupt controller has a register. This register is used for reading and/or writing, and is then extracted from the interrupt controller.
  • the register type 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 go into too much detail here.
  • the data structure can be added when calling kvm_vcpu_ioctl and KVM_GET_LAPIC
  • the implementation of saving the physical lapic data structure is added, which is mainly implemented to save all readable physical lapic registers.
  • Step S3 Add the data structure to the migration transmission data of the virtual machine to be migrated;
  • KVM is combined with QEMU to realize the migration of the virtual machine.
  • QEMU is an open source simulator and virtual machine supervisor.
  • QEMU can be used as a user mode simulator.
  • a dynamic code translation mechanism is used to execute code that is different from the host architecture.
  • QEMU can also serve as a virtual machine supervisor, simulate the entire system, and use other VMMs (Xen, KVM, etc.) to use the virtualization support provided by the hardware to create performance close to that of the host.
  • Virtual machines 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.
  • the data structure is stored in the migration transmission data. Since the migration transmission data is stored in KVM, the physical lapic state can be saved and restored.
  • Step S4 Migrate the virtual machine to be migrated from the source host to the target host based on the migration transmission data.
  • the above describes adding the data structure to the migration transmission data of the virtual machine to be migrated.
  • 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.
  • the target host After the target host receives the migration transmission data, the target host will start and restore the virtual machine corresponding to the above type of interrupt controller. It can also start a new transparent transmission lapic virtual machine according to the qemu xml configuration and restore the physical lapic.
  • the target host In order to inject register data into the register, the target host will turn off the corresponding CPU interrupt under the host, restore the physical lapic ordinary register, then read the irr/isr register, and re-inject the corresponding interrupt into the register according to the interrupt number. Finally, the server will Control the target host to resume virtual machine operation.
  • the source host includes QEMU and KVM.
  • QEMU is a hardware virtualization program that calls the function kvm_get _ apic calls kvm_vcpu_ioctl or KVM_GET_LAPIC. Since the source host is migrating a dynamic virtual machine, the guest exists on the virtual machine and the host exists on the host. During the process of migrating the virtual machine, it is necessary to ensure that the host interrupt is turned off and the specified cpu exits.
  • the physical lapic dynamic migration flow chart to the target host is shown in Figure 3.
  • the program kvm _put_apic _state will Read the saved lapic status information, including physical lapic, and then based on the program kvm_apic_put and the program kvm_vcpu_ioctl or KVM_SET_LAPIC when the host interrupt is turned off, read the lapic status, including the physical lapic register to kvm, and set the physical lapic status through the program bm_apic_set_state.
  • Some readable and writable registers are written directly into kvm. Since the interrupt request register and the interrupt processing register are read-only registers, the corresponding interrupt needs to be re-injected into the interrupt request register and the interrupt processing register. The injection into the register has been described above. Corresponding to the interrupt, after the program injects the interrupt in the register, it returns to QEMU and completes the subsequent migration recovery process. After the migration recovery process stays on the target host, the specified cpu is started, and finally the guest in KVM is re-entered through the programs kvm_vcpu_ioctl and KVM_RUN. The physical lapic resumes operation, thereby achieving the purpose of migrating the virtual machine from the source host to the target host and the migrated virtual machine resumes operation on the target host.
  • the data structure is stored based on the type of the virtual machine to be migrated, the data structure is added to the migration transmission data, and the migration transmission data is sent from the source host to the target host to achieve hardware-based transparent transmission. Live migration of virtual machines.
  • embodiments of the present application also provide a device for dynamic migration of virtual machines.
  • the device for dynamic migration of virtual machines is used to implement the function of a method for dynamic migration of virtual machines.
  • Devices include:
  • the determination module 401 is used to determine the type of the virtual machine to be migrated on the source host;
  • the storage module 402 is configured to store the data structure corresponding to the interrupt controller that meets the conditions in response to the type being consistent with the preset type;
  • Matching module 403, configured to add the data structure to the migration transmission data of the virtual machine to be migrated;
  • the migration module 404 is configured to migrate the virtual machine to be migrated from the source host to the target host based on the migration transmission data.
  • the storage module 402 is specifically configured to match the type of the virtual machine to be migrated with each preset type in the preset type set. When a preset that is consistent with the type is matched, type, respond that the type is consistent with the preset type.
  • the storage module 402 is also used to extract the interrupt controller of the type, extract the register type of the register in the interrupt controller and the data corresponding to the register, and convert the The register type is associated with the data, a data structure is generated, and the data structure is stored.
  • the migration module 404 is specifically configured to control the CPU on the target host to start and restore the virtual machine of the interrupt controller of the type, and extract the virtual machine of the interrupt controller of the type.
  • a preset register is read, and the register data is input into the preset register to realize the injection of register data.
  • embodiments of the present application also provide an electronic device, which can realize the function of the aforementioned device for dynamic migration of virtual machines.
  • the electronic device includes:
  • the specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of this application.
  • the connection medium between the processor 501 and the memory 502 is shown.
  • the bus 500 is represented by a thick line in FIG. 5 , and the connection methods between other components are only schematically illustrated and not limited thereto.
  • the bus 500 can be divided into an address bus, a data bus, a control bus, etc. For ease of presentation, only one thick line is used to represent it in Figure 5, but it does not mean that there is only one bus or one type of bus.
  • the processor 501 may also be called a controller, and there is no restriction on the name.
  • the memory 502 stores instructions that can be executed by at least one processor 501.
  • at least one processor 501 can perform a virtual machine dynamic migration method discussed above.
  • the processor 501 can implement the functions of each module in the device shown in Figure 4.
  • the processor 501 is the control center of the device and can use various interfaces and lines to connect various parts of the entire control device. By running or executing instructions stored in the memory 502 and calling data stored in the memory 502, the processor 501 can Various functions of the device and process data to provide overall monitoring of the device.
  • the processor 501 may include one or more processing units, and the processor 501 may integrate an application processor and a modem processor, where the application processor mainly processes the operating system, user interface and application programs. etc., the modem processor mainly handles wireless communications. It can be understood that the above modem processor may not be integrated into the processor 501.
  • the processor 501 and the memory 502 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips.
  • the processor 501 may be a general processor such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or Implement or execute each method, step and logical block diagram disclosed in the embodiments of this application.
  • a general-purpose processor may be a microprocessor or any conventional processor, etc.
  • the steps of the method for dynamic migration of a virtual machine disclosed in the embodiments of the present application can be directly implemented by a hardware processor, or executed by a combination of hardware and software modules in the processor.
  • the memory 502 can be used to store non-volatile software programs, non-volatile computer executable programs and modules.
  • the memory 502 may include at least one type of storage medium, for example, may include flash memory, hard disk, multimedia card, card-type memory, random access memory (Random access memory) Access Memory (RAM), static random access memory (Static Random Access Memory (SRAM), Programmable Read Only Memory (PROM), Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic memory, magnetic disks, optical disks, etc.
  • Memory 502 is, but is not limited to, any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
  • the memory 502 in the embodiment of the present application can also be a circuit or any other device capable of realizing a storage function, used to store program instructions and/or data.
  • the code corresponding to a virtual machine dynamic migration method introduced in the previous embodiment can be solidified into the chip, so that the chip can execute the embodiment shown in Figure 1 when running.
  • a procedure for dynamic migration of virtual machines. How to design and program the processor 501 is a technology well known to those skilled in the art, and will not be described again here.
  • embodiments of the present application also provide a storage medium that stores computer instructions.
  • the computer instructions When the computer instructions are run on a computer, the computer executes the method for dynamic migration of a virtual machine discussed above.
  • various aspects of the method for dynamic migration of virtual machines provided by this application can also be implemented in the form of a program product, which includes program code.
  • the program product When the program product is run on the device, the program code is The control device is caused to perform the steps in the virtual machine dynamic migration method described above in this specification according to various exemplary embodiments of the present application.
  • 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 that combines 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.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes in the flowchart and/or in a block or blocks in the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.

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

一种虚拟机动态迁移的方法、装置及电子设备,该方法包括:确定出源主机上的待迁移虚拟机的类型,响应于类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储,将数据结构添加至待迁移虚拟机的迁移传输数据中,基于迁移传输数据将待迁移虚拟机从源主机迁移至目标主机。通过上述的方法,将迁移传输数据从源主机迁移至目标主机,从而实现基于硬件透传虚拟机的迁移,将迁移传输数据传输至目标主机之后,能够使得虚拟机在目标主机上恢复运行。

Description

一种虚拟机动态迁移的方法、装置及电子设备 技术领域
本申请涉及云计算虚拟化技术领域,尤其涉及一种虚拟机动态迁移的方法、装置及电子设备。
背景技术
随着云计算虚拟化技术的发展,虚拟机的动态迁移是在确保虚拟机服务正常运行的同时,将一个虚拟机系统从一个物理主机移动到另一个物理主机的过程,该过程不会对用户造成明显的影响,从而使得管理员能够在不影响用户正常使用的情况下,对物理主机进行离线维修或升级。
技术问题
为了确保迁移过程中虚拟机服务可用,迁移过程仅占据非常短暂的停机时间,动态迁移实际上是将虚拟机的配置封装在一个文件中,然后通过高速网络,把虚拟机配置和内存运行状态从源主机迅速传送到目的主机上,从而达到源主机将控制权转移到目的主机,并使得虚拟机系统在目的主机上继续运行,进而实现虚拟机的动态迁移。
目前,虚拟机的动态迁移是基于软件实现,缺乏硬件透传虚拟机的迁移技术。
技术解决方案
本申请提供了一种虚拟机动态迁移的方法、装置及电子设备,基于硬件实现虚拟机的动态迁移。
第一方面,本申请提供了一种虚拟机动态迁移的方法,所述方法包括:
确定出源主机上的待迁移虚拟机的类型;
响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;
将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
通过上述的方法,将源主机上的虚拟机的类型进行分类之后,通过将包含数据结构的迁移传输数据进行存储,从而能够实现将虚拟机从源主机迁移至目标主机,并且,也能够恢复目标主机的寄存器。
在一种可能的设计中,响应于所述类型与预设类型一致,包括:
将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配;
当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。
通过上述的方法,将待迁移虚拟机的类型与虚拟机的各个预设类型进行匹配,当待迁移虚拟机匹配到与预设类型一致的虚拟机时,确定待迁移虚拟机符合预设类型的虚拟机,从而实现基于虚拟机的类型对虚拟机进行筛选。
在一种可能的设计中,将符合条件的中断控制器对应的数据结构进行存储,包括:
提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据;
将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。
通过上述的方法,确定出该类型的中断控制器,并提取出中断控制器中的寄存器的类型以及数据,并将该类型以及数据进行关联,生成数据结构,并将该数据结构进行存储,确保了能够实现对虚拟机的恢复。
在一种可能的设计中,基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机之后,包括:
控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机;
提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器;
将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。
通过上述的方法,服务器控制目标主机启动并恢复中断控制器对应的虚拟机,并将寄存器数据输入中断控制器中的寄存器中,实现终端程序的注入。
第二方面,本申请提供了一种虚拟机动态迁移的装置,所述装置包括:
确定模块,用于确定出源主机上的待迁移虚拟机的类型;
存储模块,用于响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;
匹配模块,用于将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
迁移模块,用于基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
在一种可能的设计中,所述存储模块,具体用于将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配,当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。
在一种可能的设计中,所述存储模块,还用于提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据,将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。
在一种可能的设计中,所述迁移模块,具体用于控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机,提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器,将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。
第三方面,本申请提供了一种电子设备,包括:
存储器,用于存放计算机程序;
处理器,用于执行所述存储器上所存放的计算机程序时,实现上述的一种虚拟机动态迁移的方法步骤。
第四方面,一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述的一种虚拟机动态迁移的方法步骤。
上述第一方面至第四方面中的各个方面以及各个方面可能达到的技术效果请参照上述针对第一方面或第一方面中的各种可能方案可以达到的技术效果说明,这里不再重复赘述。
附图说明
图1为本申请提供的一种虚拟机动态迁移的方法步骤的流程图;
图2为本申请提供的物理lapic动态迁移源主机流程图;
图3为本申请提供的物理lapic动态迁移目标主机流程图;
图4为本申请提供的一种虚拟机动态迁移的装置的结构示意图;
图5为本申请提供的一种电子设备的结构示意图。
本发明的实施方式
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述。方法实施例中的具体操作方法也可以应用于装置实施例或系统实施例中。需要说明的是,在本申请的描述中“多个”理解为“至少两个”。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。A与B连接,可以表示:A与B直接连接和A与B通过C连接这两种情况。另外,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。
目前,为了实现虚拟机的动态迁移,采用的方式为基于软件以及apic模拟实现,在“lapic”透传的高性能虚拟机上,虚拟机直接使用物理lapic,由于物理lapic的状态在物理寄存器中,而基于软件以及lapic模拟是在软件的基础上实现的,因此,缺乏一种硬件透传虚拟机的动态迁移的方法。
为了解决上述描述的问题,本申请实施例提供了一种虚拟机动态迁移的方法,用以基于硬件透传的虚拟机的动态迁移。其中,本申请实施例所述方法和装置基于同一技术构思,由于方法及装置所解决问题的原理相似,因此装置与方法的实施例可以相互参见,重复之处不再赘述。
下面结合附图,对本申请实施例进行详细描述。
参照图1,本申请提供了一种虚拟机动态迁移的方法,该方法可以实现基于硬件透传虚拟机的动态迁移,该方法的实现流程如下:
步骤S1:确定出源主机上的待迁移虚拟机的类型。
由于本申请实施例是为了实现基于硬件透传虚拟机动态迁移,因此,为了能够实现上述虚拟机的动态迁移,首先,需要确定出源主机上待迁移虚拟机的源主机的类型,待迁移主机的类型在本申请实施例中可以为能够增加“lapic”透传的虚拟机,本申请实施例中待迁移虚拟机为能够进行透传的虚拟机,需要补充的是,本申请文件中的lapic为中断控制器。
步骤S2:响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储。
上述已经确定出了待迁移虚拟机的类型,为了确保待迁移虚拟机为指定类型的虚拟机,需要将待迁移虚拟机的类型与预设类型集中的各个预设类型进行匹配,若该类型匹配出一致的预设类型,则代表该类型在预设类型中;若该类型未匹配出一致的预设类型,则代表该类型不在预设类型中。
当该类型与预设类型一致时,将确定出该类型对应的中断控制器,每一个中断控制器都存在一个寄存器,该寄存器用于读和/或写,再从该中断控制器中提取出寄存器的寄存器类型以及该寄存器对应的数据,该寄存器的类型可以为:TPR、APR、 PPR、 RRD、 LDR、 DFR、 ICR、IRR、 ISR、 TMR、 LVTT等,寄存器类型还可以为其他的类型,这里不做过多阐述。
获得寄存器的类型以及该寄存器对应的数据之后,将该类型以及数据进行关联,生成数据结构,并将该数据结构进行存储,需要进行说明的是,可以在调用kvm_vcpu_ioctl以及KVM_GET_LAPIC时,将数据结构添加至前述调用程序中,以及在kvm_apic_get_state函数中增加保存物理lapic数据结构的实现,主要实现为保存所有可读的物理lapic寄存器。
步骤S3:将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
上述描述数据结构的存储,在虚拟机的迁移过程中,KVM与     QEMU结合用于实现虚拟机的迁移,QEMU是一款开源的模拟器以及虚拟机监管器,QEMU可以作为用户态模拟器,利用动态代码翻译机制来执行不同于主机架构的代码,QEMU还可以作为虚拟机监管器,模拟全系统,利用其他VMM(Xen, KVM, etc)来使用硬件提供的虚拟化支持,创建接近于主机性能的虚拟机,每个虚拟机对应主机(host)中的一个QEMU进程,而虚拟机的vcpu对应QEMU进程的一个线程,该vcpu为虚拟机的cpu。
将数据结构进行存储之后,将数据结构添加至待迁移虚拟机的迁移传输数据中,并在目的端调用kvm_vcpu_ioctl或者KVM_SET_LAPIC时增加保存的物理lapic的数据结构。
基于上述的描述,将数据结构存储至迁移传输数据中,由于迁移传输数据保存在KVM中,因此,能够实现物理lapic状态的保存与恢复。
步骤S4:基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
上述描述了将数据结构添加至待迁移虚拟机的迁移传输数据中,源主机向目标主机进行虚拟机的动态迁移时,服务器控制源主机将迁移传输数据迁移至目标主机,从而实现基于硬件透传虚拟机的动态迁移。
目标主机在接收迁移传输数据之后,目标主机将起启动并恢复上述类型的中断控制器对应的虚拟机,也可以根据qemu xml配置启动新的透传lapic的虚机,并恢复物理lapic。
为了在寄存器中实现寄存器数据的注入,目标主机将关闭host下对应cpu中断,并恢复物理lapic普通寄存器,再读取irr/isr寄存器,按中断号向寄存器中重新注入对应中断,最后,服务器将控制目标主机恢复虚机运行。
具体的,物理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状态迁移到目标主机,从而实现虚拟机从源主机上的迁移。
源主机将虚拟机发送至目标主机之后,物理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恢复运行,从而实现虚拟机从源主机迁移至目标主机以及迁移的虚拟机在目标主机上恢复运行的目的。
基于上述的方法,基于待迁移虚拟机的类型对数据结构进行存储,并将数据结构添加至迁移传输数据中,并通过将迁移传输数据从源主机发送至目标主机的方式,实现基于硬件透传虚拟机的动态迁移。
基于同一发明构思,本申请实施例中还提供了一种虚拟机动态迁移的装置,该虚拟机动态迁移的装置用于实现了一种虚拟机动态迁移的方法的功能,参照图4,所述装置包括:
确定模块401,用于确定出源主机上的待迁移虚拟机的类型;
存储模块402,用于响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;
匹配模块403,用于将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
迁移模块404,用于基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
在一种可能的设计中,所述存储模块402,具体用于将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配,当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。
在一种可能的设计中,所述存储模块402,还用于提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据,将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。
在一种可能的设计中,所述迁移模块404,具体用于控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机,提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器,将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。
基于同一发明构思,本申请实施例中还提供了一种电子设备,所述电子设备可以实现前述一种虚拟机动态迁移的装置的功能,参考图5,所述电子设备包括:
至少一个处理器501,以及与至少一个处理器501连接的存储器502,本申请实施例中不限定处理器501与存储器502之间的具体连接介质,图5中是以处理器501和存储器502之间通过总线500连接为例。总线500在图5中以粗线表示,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。总线500可以分为地址总线、数据总线、控制总线等,为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。或者,处理器501也可以称为控制器,对于名称不做限制。
在本申请实施例中,存储器502存储有可被至少一个处理器501执行的指令,至少一个处理器501通过执行存储器502存储的指令,可以执行前文论述的一种虚拟机动态迁移的方法。处理器501可以实现图4所示的装置中各个模块的功能。
其中,处理器501是该装置的控制中心,可以利用各种接口和线路连接整个该控制设备的各个部分,通过运行或执行存储在存储器502内的指令以及调用存储在存储器502内的数据,该装置的各种功能和处理数据,从而对该装置进行整体监控。
在一种可能的设计中,处理器501可包括一个或多个处理单元,处理器501可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器501中。在一些实施例中,处理器501和存储器502可以在同一芯片上实现,在一些实施例中,它们也可以在独立的芯片上分别实现。
处理器501可以是通用处理器,例如中央处理器(CPU)、数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本申请实施例中公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本申请实施例所公开的一种虚拟机动态迁移的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。
存储器502作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。存储器502可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random Access Memory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性存储器、磁盘、光盘等等。存储器502是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本申请实施例中的存储器502还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。
通过对处理器501进行设计编程,可以将前述实施例中介绍的一种虚拟机动态迁移的方法所对应的代码固化到芯片内,从而使芯片在运行时能够执行图1所示的实施例的一种虚拟机动态迁移的步骤。如何对处理器501进行设计编程为本领域技术人员所公知的技术,这里不再赘述。
基于同一发明构思,本申请实施例还提供一种存储介质,该存储介质存储有计算机指令,当该计算机指令在计算机上运行时,使得计算机执行前文论述的一种虚拟机动态迁移的方法。
在一些可能的实施方式中,本申请提供一种虚拟机动态迁移的方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当程序产品在装置上运行时,程序代码用于使该控制设备执行本说明书上述描述的根据本申请各种示例性实施方式的一种虚拟机动态迁移的方法中的步骤。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (10)

  1. 一种虚拟机动态迁移的方法,其特征在于,包括:
    确定出源主机上的待迁移虚拟机的类型;
    响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;
    将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
    基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
  2. 如权利要求1所述的方法,其特征在于,响应于所述类型与预设类型一致,包括:
    将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配;
    当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。
  3. 如权利要求1所述的方法,其特征在于,将符合条件的中断控制器对应的数据结构进行存储,包括:
    提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据;
    将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。
  4. 如权利要求1所述的方法,其特征在于,基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机之后,包括:
    控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机;
    提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器;
    将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。
  5. 一种虚拟机动态迁移的装置,其特征在于,所述装置包括:
    确定模块,用于确定出源主机上的待迁移虚拟机的类型;
    存储模块,用于响应于所述类型与预设类型一致,将符合条件的中断控制器对应的数据结构进行存储;
    匹配模块,用于将所述数据结构添加至所述待迁移虚拟机的迁移传输数据中;
    迁移模块,用于基于所述迁移传输数据将所述待迁移虚拟机从源主机迁移至目标主机。
  6. 如权利要求5所述的装置,其特征在于,所述存储模块,具体用于将所述待迁虚拟机的类型与预设类型集中的各个预设类型进行匹配,当匹配出与所述类型一致的预设类型时,响应于所述类型与预设类型一致。
  7. 如权利要求5所述的装置,其特征在于,所述存储模块,还用于提取出所述类型的中断控制器,以及提取出所述中断控制器中寄存器的寄存器类型和所述寄存器对应的数据,将所述寄存器类型与所述数据进行关联,生成数据结构,并将所述数据结构进行存储。
  8. 如权利要求5所述的装置,其特征在于,所述迁移模块,具体用于控制所述目标主机上的CPU启动并恢复所述类型的中断控制器的虚拟机,提取出所述类型的中断控制器中的预设寄存器,并读取所述预设寄存器,将所述寄存器数据输入预设寄存器中,实现寄存器数据的注入。
  9. 一种电子设备,其特征在于,包括:
    存储器,用于存放计算机程序;
    处理器,用于执行所述存储器上所存放的计算机程序时,实现权利要求1-4任一项所述的方法步骤。
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-4任一项所述的方法步骤。
PCT/CN2022/141594 2022-07-25 2022-12-23 一种虚拟机动态迁移的方法、装置及电子设备 WO2024021480A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210877002.3A CN115292000A (zh) 2022-07-25 2022-07-25 一种虚拟机动态迁移的方法、装置及电子设备
CN202210877002.3 2022-07-25

Publications (1)

Publication Number Publication Date
WO2024021480A1 true WO2024021480A1 (zh) 2024-02-01

Family

ID=83823896

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/141594 WO2024021480A1 (zh) 2022-07-25 2022-12-23 一种虚拟机动态迁移的方法、装置及电子设备

Country Status (2)

Country Link
CN (1) CN115292000A (zh)
WO (1) WO2024021480A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115292000A (zh) * 2022-07-25 2022-11-04 天翼云科技有限公司 一种虚拟机动态迁移的方法、装置及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060005189A1 (en) * 2004-06-30 2006-01-05 Microsoft Corporation Systems and methods for voluntary migration of a virtual machine between hosts with common storage connectivity
CN111857968A (zh) * 2020-07-29 2020-10-30 山东超越数控电子股份有限公司 一种虚拟机的热迁移方法、系统、设备以及介质
CN113326105A (zh) * 2021-08-04 2021-08-31 深圳市科力锐科技有限公司 基于主机迁移的硬件设备配置方法、装置及设备
CN114691300A (zh) * 2022-03-25 2022-07-01 阿里巴巴(中国)有限公司 一种虚拟机实例的热迁移方法
CN115292000A (zh) * 2022-07-25 2022-11-04 天翼云科技有限公司 一种虚拟机动态迁移的方法、装置及电子设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060005189A1 (en) * 2004-06-30 2006-01-05 Microsoft Corporation Systems and methods for voluntary migration of a virtual machine between hosts with common storage connectivity
CN111857968A (zh) * 2020-07-29 2020-10-30 山东超越数控电子股份有限公司 一种虚拟机的热迁移方法、系统、设备以及介质
CN113326105A (zh) * 2021-08-04 2021-08-31 深圳市科力锐科技有限公司 基于主机迁移的硬件设备配置方法、装置及设备
CN114691300A (zh) * 2022-03-25 2022-07-01 阿里巴巴(中国)有限公司 一种虚拟机实例的热迁移方法
CN115292000A (zh) * 2022-07-25 2022-11-04 天翼云科技有限公司 一种虚拟机动态迁移的方法、装置及电子设备

Also Published As

Publication number Publication date
CN115292000A (zh) 2022-11-04

Similar Documents

Publication Publication Date Title
US9823851B2 (en) Secure migratable architecture having security features
TWI509518B (zh) 用於改良巢式虛擬化之性能的方法、中央處理單元裝置及系統
US6480919B2 (en) Method and apparatus for providing seamless hooking and intercepting of selected kernel and hal exported entry points
US11487523B2 (en) Updating machine emulator
US12014199B1 (en) Virtualization extension modules
US10346330B2 (en) Updating virtual machine memory by interrupt handler
JP2011100431A (ja) 仮想マシン制御装置及び仮想マシン制御方法
US10055136B2 (en) Maintaining guest input/output tables in swappable memory
US11036666B2 (en) Asynchronous mapping of hot-plugged device associated with virtual machine
US9715403B2 (en) Optimized extended context management for virtual machines
US10430221B2 (en) Post-copy virtual machine migration with assigned devices
US11875145B2 (en) Virtual machine update while keeping devices attached to the virtual machine
US11321077B1 (en) Live updating of firmware behavior
US10467078B2 (en) Crash dump extraction of guest failure
WO2024021480A1 (zh) 一种虚拟机动态迁移的方法、装置及电子设备
US20230221971A1 (en) Multiple port emulation
US11249792B1 (en) Peripheral device mounting based on file system compatibility
US11409551B2 (en) Emulating VPID correctly for a nested hypervisor
US11755512B2 (en) Managing inter-processor interrupts in virtualized computer systems

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22952911

Country of ref document: EP

Kind code of ref document: A1