WO2018119811A1 - 多虚拟机同时运行的方法、装置及电子设备 - Google Patents

多虚拟机同时运行的方法、装置及电子设备 Download PDF

Info

Publication number
WO2018119811A1
WO2018119811A1 PCT/CN2016/112833 CN2016112833W WO2018119811A1 WO 2018119811 A1 WO2018119811 A1 WO 2018119811A1 CN 2016112833 W CN2016112833 W CN 2016112833W WO 2018119811 A1 WO2018119811 A1 WO 2018119811A1
Authority
WO
WIPO (PCT)
Prior art keywords
operating system
hypervisor
context
module
kvm
Prior art date
Application number
PCT/CN2016/112833
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 深圳前海达闼云端智能科技有限公司
Priority to CN201680002889.4A priority Critical patent/CN107223236B/zh
Priority to PCT/CN2016/112833 priority patent/WO2018119811A1/zh
Publication of WO2018119811A1 publication Critical patent/WO2018119811A1/zh
Priority to US16/457,016 priority patent/US10901766B2/en

Links

Images

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/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/45545Guest-host, i.e. hypervisor is an application program itself, e.g. VirtualBox
    • 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/45537Provision of facilities of other operating environments, e.g. WINE
    • 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/45541Bare-metal, i.e. hypervisor runs directly on hardware
    • 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/461Saving or restoring of program or task context
    • 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/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • 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/45579I/O management, e.g. providing access to device drivers or storage

Definitions

  • the present application relates to the field of virtualization technologies, and in particular, to a method, an apparatus, and an electronic device for simultaneously operating multiple virtual machines.
  • KVM Kernel Virtual Machine
  • Figure 1 shows a schematic diagram of a prior art KVM-based virtualization solution architecture. As shown in the figure, it usually consists of a host operating system and It consists of several virtual guest operating systems running on the same set of hardware processor chips, sharing processors and peripheral resources.
  • the ARM processor supporting the virtualization architecture includes at least three modes: EL (Exception Level) 2, EL1, and EL0.
  • the Hypervisor program is run in EL2 mode, the Linux kernel program is run in EL1 mode, and the user space program is run in EL0 mode (User mode Application).
  • the Hypervisor layer manages hardware resources such as CPU, memory, timers, and interrupts. Through the virtualized resources of CPU, memory, timers, and interrupts, different operating systems can be time-divisionally loaded onto physical processors to implement system virtualization. The function.
  • the shortcoming of the prior art is that the virtualization solution can only execute one platform Platform Hypervisor at the hypervisor layer, and cannot execute third-party hypervisor software.
  • An object of the present application is to solve the technical problem that the virtualization solution in the prior art can only execute one Platform Platform Hypervisor at the Hypervisor layer and cannot execute the third-party Hypervisor software.
  • the embodiment of the present application provides a method for simultaneously running multiple virtual machines, and a package include:
  • the embodiment of the present application provides a device for simultaneously running multiple virtual machines, including:
  • a receiving module configured to initiate a request to run a second operating system in Qemu;
  • a virtual machine switching module configured to trigger an exception to the Hypervisor of the first operating system currently running in the KVM module
  • a first switching interface module configured to save a context of a hypervisor of the first operating system and load a context of a hypervisor of the second operating system in a hypervisor of the first operating system;
  • a second switching interface module configured to save a context of the first operating system and load a context of the second operating system in a hypervisor of the second operating system.
  • an embodiment of the present application provides an electronic device, including: a memory, one or more processors, and one or more modules; the one or more modules are stored in the memory, and It is configured to be executed by the one or more processors, the one or more modules comprising instructions for performing the various steps in the method as described above.
  • an embodiment of the present application provides a computer program product for use in conjunction with an electronic device, the computer program product comprising a computer program embedded in a computer readable storage medium, the computer program comprising The electronic device is caused to execute instructions of the various steps in the method as described above.
  • the embodiment of the present application may trigger an exception to the Hypervisor of the currently operating first operating system in the KVM module, and then save the Hypervisor of the first operating system in the first Hypervisor.
  • FIG. 1 is a schematic diagram showing a virtualization architecture based on KVM technology in the prior art
  • FIG. 2 is a schematic flowchart of a method for implementing simultaneous operation of multiple virtual machines in the first embodiment of the present application
  • FIG. 3 is a schematic structural diagram of an apparatus for simultaneously operating multiple virtual machines in Embodiment 2 of the present application;
  • FIG. 4 is a schematic structural diagram of an electronic device in Embodiment 3 of the present application.
  • FIG. 5 is a schematic diagram showing a virtualization architecture in Embodiment 5 of the present application.
  • FIG. 6 is a schematic diagram of a framework for simultaneously running multiple virtual machines in Embodiment 5 of the present application.
  • FIG. 7 is a schematic flowchart showing the simultaneous operation of multiple virtual machines in Embodiment 5 of the present application.
  • FIG. 8 is a schematic diagram showing a virtualization architecture of a multi-core processor in Embodiment 6 of the present application.
  • the KVM/Hypervisor module spans the Host Linux kernel and the Hypervisor layer, and provides an interface node for Qemu on the one hand, allowing Qemu to create a virtual CPU through the KVM node and managing the virtualized resources; on the other hand, the KVM/Hypervisor implements the Host.
  • the Linux system switches out from the physical CPU, then loads the Guest Linux system onto the physical processor, and finally processes the subsequent transactions that the Guest Linux system exits abnormally.
  • Qemu runs as an application of Host Linux, provides virtual hardware device resources for the operation of Guest Linux, creates virtual CPUs through KVM nodes of KVM/Hypervisor module, allocates physical hardware resources, and loads an unmodified Guest Linux. Go to the physical hardware processor to run.
  • a very critical function to be implemented in the Hypervisor layer is to protect the running context of the operating system currently running on the physical hardware, and then another operation. The operating context of the system is restored to the physical hardware and code execution begins, enabling dynamic switching of the operating system. If a hardware platform has implemented more complex logic functions in the Hypervisor layer and does not support virtualization functions, it would be very difficult to run virtualization software on such a platform.
  • the existing mobile platform software has run very complicated logic.
  • the existing software has occupied all the physical hardware resources of the Hypervisor layer, such as the stage 2MMU page table and the exception vector table.
  • the third-party Hypervisor software does not have any permissions and Opportunities are executed at the hypervisor level.
  • the embodiment of the present application provides a method, a device, and an electronic device for simultaneously running multiple virtual machines, so that multiple virtual machines can be simultaneously run when the hardware supports only one virtualization extension. And ensure that their respective functions run independently.
  • FIG. 2 is a schematic flowchart showing the implementation of a method for simultaneously running multiple virtual machines in the first embodiment of the present application. As shown in the figure, the method for simultaneously running the multiple virtual machines may include the following steps:
  • Step 201 In Qemu, initiate a request to run a second operating system
  • Step 202 In the KVM module, triggering an exception to a hypervisor of a currently running first operating system
  • Step 203 Save a context of a hypervisor of the first operating system in a hypervisor of the first operating system, and load a context of a hypervisor of the second operating system;
  • Step 204 Save the context of the first operating system and load the context of the second operating system in the hypervisor of the second operating system.
  • the Qemu can be used as a process of the first operating system. After the Qemu is started, the request to run the second operating system can be initiated.
  • a function module Hypervisor Swap controller for switching can be added to the KVM module. (Swap controller), the hypervisor Swap controller is responsible for triggering the exception to the currently running first operating system hypervisor, each hypervisor can have a function module Hypervisor Swap entry (Swap entry) for context processing, through Swap entry The dynamic switching operation of the Hypervisor software is implemented.
  • the Swap controller executes the Swap entry code of the Hypervisor of the operating system through an abnormal call, saves the context of the Hypervisor of the current operating system, and then The context of the running Hypervisor is written to the physical hardware CPU's registers and starts running.
  • the Swap entry of the Hypervisor to be run saves the context of the operating system to be run and loads the context of the operating system to be run.
  • the embodiment of the present application adds the functions of the Hypervisor Swap Controller and the Hypervisor Swap Entry while maintaining the Hypervisor software framework of the original hardware platform, and realizes the virtualization in a single hardware.
  • the software dynamically switches and runs, which supports different upper-level virtual operating systems, that is, independent functions.
  • each core can independently run a virtual machine of a different function type.
  • the method may further include:
  • the application returns to Qemu.
  • the second operating system may be saved in the hypervisor of the second operating system. Context and loading the context of the first operating system, then triggering an exception in the KVM module to the Hypervisor of the second operating system, saving the context of the Hypervisor of the second operating system in the Hypervisor of the second operating system and loading the first
  • the operating system's hypervisor context restores the normal operation of the first operating system's hypervisor and the first operating system.
  • the context of the hypervisor of the first operating system is saved in the hypervisor of the first operating system, and the context of the hypervisor of the second operating system is loaded, which may be:
  • the KVM module is called back in the Hypervisor of the first operating system, and the context of the Hypervisor of the first operating system is saved in the KVM module and the context of the Hypervisor of the second operating system is loaded.
  • the Hypervisor that triggers the first operating system may be abnormally called in the KVM module, and the first operating system is triggered by the first operating system.
  • the Hypervisor calls back the KVM module, saves the context of the Hypervisor of the first operating system in the KVM module, loads the context of the Hypervisor of the second operating system into the process of the physical hardware processor, and starts running the Hypervisor of the second operating system.
  • Software code; the second operating system's hypervisor saves the context of the first operating system and loads the context of the second operating system onto the physical hardware, and the processor starts running the second operating system.
  • the second operating system After the second operating system finishes running, it can be returned to the Hypervisor of the second operating system to save the context of the second operating system and restore the context of the first operating system.
  • the hypervisor callback KVM module of the second operating system is triggered by the exception call in the KVM module, and the context of the hypervisor of the second operating system is protected in the KVM module, and the context of the hypervisor of the first operating system is restored to the physical hardware processor. At this point, the first operating system and its hypervisor resume normal operation.
  • the first operating system may be a host host operating system
  • the Hypervisor of the first operating system may be a platform hypervisor
  • the second operating system may be a guest guest operating system
  • the second operating system Hypervisor can be a third-party hypervisor.
  • the host operating system and the platform hypervisor are in normal running state, and then after receiving the running request from the guest operating system, dynamically switch to the third-party hypervisor to realize the operation of the guest operating system;
  • the guest operating system and the third-party hypervisor are in normal running state.
  • the guest operates dynamically to the platform hypervisor to implement the operation of the host operating system.
  • the embodiment of the present application can automatically switch back to the Host operating system.
  • the kernel of the first operating system is a Host Linux kernel
  • the kernel of the second operating system is a Guest Linux kernel
  • the operating system can be a Linux system
  • the kernel of the first virtual operating system is Host Linux kernel
  • the kernel of the second virtual operating system is a Guest Linux kernel
  • other operating system kernels may be used by those skilled in the art, which is not limited in this application.
  • a space may be preset to save the respective context of the hypervisor.
  • the context of the two hypervisors to be switched may be saved to the stack to be loaded into the hypervisor running on the CPU ( In the stack space, it can also be saved in the storage space of the KVM module.
  • the third-party hypervisor can be used to switch between the host host operating system supported by the upper layer and at least one guest virtual operating system.
  • the platform hypervisor may be a Qualcomm Platform Hypervisor or the like
  • the third-party hypervisor may be a Xen architecture Hypervisor, a KVM Hypervisor, or the like.
  • the embodiment of the present application further provides a device for simultaneously running multiple virtual machines. Since the principle of solving the problems of these devices is similar to the method for simultaneously running multiple virtual machines, the implementation of these devices can be referred to the method. The implementation, repetitions will not be repeated.
  • FIG. 3 is a schematic structural diagram of an apparatus for simultaneously running multiple virtual machines in the second embodiment of the present application. As shown in the figure, the apparatus for simultaneously running the multiple virtual machines may include the following steps:
  • the receiving module 301 is configured to initiate a request to run the second operating system in Qemu.
  • the virtual machine switching module Hypervisor swap controller 302 is configured to trigger an exception to the Hypervisor of the first operating system currently running in the KVM module;
  • a first switch interface module swap entry 303 configured to save a context of a hypervisor of the first operating system and load a context of a hypervisor of the second operating system in a hypervisor of the first operating system;
  • the second switch interface module swap entry 304 is configured to save the context of the first operating system and load the context of the second operating system in the hypervisor of the second operating system.
  • the second switch interface module swap entry may be further configured to save the context of the second operating system and load the first in the hypervisor of the second operating system when monitoring the end of the second operating system in Qemu The context of the operating system;
  • the virtual machine switching module Hypervisor swap controller may be further used to trigger an exception to the Hypervisor of the second operating system in the KVM module;
  • the second switch interface module swap entry may be further configured to save a context of a hypervisor of the operating system and load a context of a hypervisor of the first operating system in a hypervisor of the second operating system.
  • the first switch interface module swap entry may be specifically configured to call back a KVM module in the Hypervisor of the first operating system, save a context of a Hypervisor of the first operating system in the KVM module, and load a Hypervisor of the second operating system. Context.
  • the first operating system may be a host host operating system
  • the Hypervisor of the first operating system may be a platform hypervisor
  • the second operating system may be a guest guest operating system
  • the second operating system Hypervisor can be a third-party hypervisor.
  • the kernel of the first operating system may be a Host Linux kernel
  • the kernel of the second operating system may be a Guest Linux kernel
  • an embodiment of the present application further provides an electronic device, which will be described below.
  • the electronic device may include: a memory 401, one or more processors 402, and one or more modules;
  • the one or more modules are stored in the memory 402 and configured to be executed by the one or more processors 402, the one or more modules including for performing simultaneous operation of the multiple virtual machines described above The instructions for each step in the method.
  • the electronic device may be a mobile phone, a pad, a tablet computer, a personal computer PC, an intelligent robot, or the like.
  • the electronic device may further include: a display screen, where the display screen may be used to display a graphical user interface, and the display screen may specifically be a touch touch screen or a non-touch screen.
  • the embodiment of the present application further provides a computer program product for use in combination with an electronic device, which will be described below.
  • a computer program product for use with an electronic device comprising: a computer program embedded in a computer readable storage medium, the computer program comprising: for causing the electronic device to execute the multiple virtual machine Instructions for each step in the method of running simultaneously.
  • the embodiment of the present application is described by taking the virtualization architecture of the Linux Kernel as an example, including a Platform Hypervisor and a KVM Hypervisor.
  • FIG. 5 is a schematic diagram of a virtualization architecture in the fifth embodiment of the present application.
  • the embodiment of the present application maintains the Hypervisor software framework of the original hardware platform unchanged from the prior art virtualization architecture solution.
  • the Linux open source hypervisor part of the software code is integrated, and the functions of Hypervisor Swap Controller and Hypervisor Swap Entry are added to the architecture diagram to realize the dynamic dynamic switching operation of the Hypervisor layer.
  • the Swap Controller is responsible for dynamic switching of different functions of the Hypervisor, such as Qualcomm Platform Hypervisor, Xen architecture Hypervisor, KVM Hypervisor, and so on.
  • the Hypervisor itself implements switching to the operating system supported by the upper layer.
  • the KVM Hypervisor is responsible for the switching operation of Host Linux and multiple Guest Linux virtual operating systems.
  • the technical solution provided by the embodiment of the present application can simultaneously run multiple virtual machines on the basis of a single hardware virtualization extension to support different upper virtual operating systems and independent functions.
  • FIG. 6 is a schematic diagram of a framework in which multiple virtual machines run simultaneously in the fifth embodiment of the present application.
  • the Hypervisor Swap Controller is responsible for triggering the switching of the hypervisor, and each hypervisor has a Swap entry.
  • the Swap Controller implements the dynamic switching operation of the virtual machine (virtual operating system) on the Hypervisor through the Swap entry.
  • the Swap Controller executes the Swap entry in the Hypervisor corresponding to the virtual operating system through an abnormal call.
  • FIG. 7 is a schematic flowchart showing the operation of multiple virtual machines running in the fifth embodiment of the present application. As shown in the figure, the specific process may be as follows:
  • Step 701 power-on reset
  • Step 702 Host Linux and the Platform Hypervisor are in a normal running state
  • Step 703 When Guest Linux needs to run, the KVM module triggers the Platform Hypervisor Swap entry callback KVM module Hypervisor swap controller to perform on-site protection on the Platform Hypervisor running context by using an exception call;
  • Step 704 the KVM module Hypervisor swap controller loads the context of the KVM Hypervisor onto the physical hardware processor, and starts running the KVM Hypervisor software code;
  • Step 705 the KVM Hypervisor saves the Host Linux kernel context and loads the Guest. Linux kernel context to physical hardware, the processor starts running the Guest Linux kernel;
  • Step 706 after the Guest Linux kernel finishes running, return to the KVM Hypervisor to save the Guest Linux kernel context, and restore the Host Linux kernel context;
  • Step 707 The KVM module triggers the KVM Hypervisor Swap entry callback KVM module by the exception call.
  • the Hypervisor swap controller performs on-site protection on the KVM Hypervisor running context, and restores the Platform Hypervisor running context to the physical hardware processor.
  • Step 708 Host Linux and Platform Hypervisor resume normal operation.
  • FIG. 8 is a schematic diagram showing a virtualization architecture of a multi-core processor in Embodiment 6 of the present application.
  • the multi-core processor may be a Linux Kernel including multiple threads, and each core independently runs a virtual operating system when implemented.
  • a kernel runs the Host operating system independently as a Host Linux Kernel
  • a kernel runs the Guest1 operating system independently as a Guest1Linux Kernel (for example, a personal operating system)
  • another kernel runs the Guest2 operating system independently as a Guest2Linux Kernel (for example, an enterprise operating system).
  • the Guest1 operating system personal operating system
  • the Guest2 operating system can provide and allocate resources by Qemu1
  • the Guest2 operating system enterprise operating system
  • the Hypervisor layer can include several different hypervisors, such as Platform Hypervisor, Xen architecture hypervisor, KVM Hypervisor, Linux Containers (LXC), and so on.
  • Platform Hypervisor Xen architecture hypervisor
  • KVM Hypervisor KVM Hypervisor
  • Linux Containers LXC
  • the Hypervisor corresponding to the virtual operating system is switched accordingly, for example, switching from the Platform Hypervisor to the Xen architecture hypervisor, switching from the Xen architecture Hypervisor to the KVM Hypervisor, etc.
  • the Hypervisor Swap Controller is responsible for Trigger the hypervisor that is currently running, and run the running The Swap entry module of the Hypervisor.
  • the running Hypervisor's Swap entry module saves the context of the running Hypervisor to the specified location, and loads the context of the target hypervisor saved in the specified location into the CPU register, and then the target hypervisor saves the previously running virtual operating system. Context, and load the context of the virtual operating system corresponding to the target hypervisor saved in the specified location to the CPU register.
  • the designated location may be a space of a Hypervisor such as a Platform Hypervisor, a Xen architecture Hypervisor, a KVM Hypervisor, or a Linux Containers (LXC), or a space in a KVM module.
  • a Hypervisor such as a Platform Hypervisor, a Xen architecture Hypervisor, a KVM Hypervisor, or a Linux Containers (LXC), or a space in a KVM module.
  • a virtual operating system that needs to be switched is required.
  • the context can be saved in the Qemu of the Host Linux Kernel.
  • the Host Linux Kernel can have multiple Qemu, and each Qemu is responsible for providing the hardware device resources of the virtual operating system for the operation of one virtual operating system.
  • the specific data structure can be a stack, or other data structure forms (for example, arrays, queues, etc.), and only need to have access to data.
  • the data structure may be multiple, for example: two stacks, one stack for storing the context of the Platform Hypervisor, one for storing the context of the KVM Hypervisor, and the like, and the record state of the context may be at the bottom of any stack. .
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
  • the application can 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.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow 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)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)
  • Hardware Redundancy (AREA)

Abstract

一种多虚拟机同时运行的方法、装置及电子设备,方法包括:在Qemu中,发起运行第二操作系统的请求(201);在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor(202);在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文(203);在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文(204)。采用本方法,可以实现多个虚拟机同时运行并保证各自的功能独立运行。

Description

多虚拟机同时运行的方法、装置及电子设备 技术领域
本申请涉及虚拟化技术领域,特别涉及一种多虚拟机同时运行的方法、装置及电子设备。
背景技术
KVM(Kernel Virtual Machine)技术是一个开源的虚拟化解决方案,图1示出了现有技术中基于KVM技术的虚拟化方案架构示意图,如图所示,通常由一个主机(Host)操作系统和若干个虚拟出来的客户机(Guest)操作系统组成,这些操作系统运行在同一套硬件处理器芯片上,共享处理器以及外设资源。
支持虚拟化架构的ARM处理器至少包含EL(Exception Level)2、EL1、EL0三种模式,EL2模式下运行Hypervisor程序,EL1模式下运行Linux kernel程序,EL0模式下运行用户空间程序(User mode的Application)。Hypervisor层管理CPU、内存、定时器,中断等硬件资源,通过CPU、内存、定时器、中断的虚拟化资源,可以把不同的操作系统分时加载到物理处理器上运行,从而实现系统虚拟化的功能。
现有技术的不足在于:虚拟化方案在Hypervisor层只能执行一个平台Platform Hypervisor,无法执行第三方Hypervisor软件。
发明内容
本申请实施例的一个目的在于解决现有技术中虚拟化方案在Hypervisor层只能执行一个平台Platform Hypervisor,无法执行第三方Hypervisor软件这一技术问题。
第一个方面,本申请实施例提供了一种多虚拟机同时运行的方法,包 括:
在Qemu中,发起运行第二操作系统的请求;
在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
第二个方面,本申请实施例提供了一种多虚拟机同时运行的装置,包括:
接收模块,用于在Qemu中,发起运行第二操作系统的请求;
虚拟机切换模块,用于在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
第一切换接口模块,用于在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
第二切换接口模块,用于在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
第三个方面,本申请实施例提供了一种电子设备,包括:存储器、一个或多个处理器、以及一个或多个模块;所述一个或多个模块被存储于所述存储器中,并被配置成由所述一个或多个处理器执行,所述一个或多个模块包括用于执行如上所述方法中各个步骤的指令。
第四个方面,本申请实施例提供了一种与电子设备结合使用的计算机程序产品,所述计算机程序产品包括内嵌于计算机可读的存储介质中的计算机程序,所述计算机程序包括用于使所述电子设备执行如上所述方法中各个步骤的指令。
有益效果如下:
本申请实施例在Qemu中发起运行第二操作系统的请求后可以在KVM模块中触发异常到当前运行的第一操作系统的Hypervisor,再在所述第一Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文,并在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文,实现Hypervisor及其虚拟操作系统的上下文管理,从而实现了虚拟机的动态切换运行,即使在硬件只支持一个虚拟化扩展的情况下,也可以让多个虚拟机同时运行并保证各自的功能独立运行。
附图说明
下面将参照附图描述本申请的具体实施例,其中:
图1示出了现有技术中基于KVM技术的虚拟化架构示意图;
图2示出了本申请实施例一中多虚拟机同时运行的方法实施的流程示意图;
图3示出了本申请实施例二中多虚拟机同时运行的装置的结构示意图;
图4示出了本申请实施例三中电子设备的结构示意图;
图5示出了本申请实施例五中虚拟化架构示意图;
图6示出了本申请实施例五中多虚拟机同时运行的框架示意图;
图7示出了本申请实施例五中多虚拟机同时运行的流程示意图;
图8示出了本申请实施例六中多核处理器的虚拟化架构示意图。
具体实施方式
为了使本申请的技术方案及优点更加清楚明白,以下结合附图对本申请的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本申请的一部分实施例,而不是所有实施例的穷举。并且在不冲突的情况下, 本说明中的实施例及实施例中的特征可以互相结合。
发明人在发明过程中注意到:
现有技术中,KVM/Hypervisor module跨越Host Linux kernel和Hypervisor两层,一方面为Qemu提供接口节点,允许Qemu通过KVM节点创建虚拟CPU,管理虚拟化资源;另一方面KVM/Hypervisor实现了把Host Linux系统从物理CPU上切换出去,然后把Guest Linux系统加载到物理处理器上运行,最后处理Guest Linux系统异常退出的后续事务。
Qemu作为Host Linux的一个应用运行,为Guest Linux的运行提供虚拟的硬件设备资源,通过KVM/Hypervisor module的设备KVM节点,创建虚拟CPU,分配物理硬件资源,实现把一个未经修改的Guest Linux加载到物理硬件处理器上去运行。
通过上面的描述,要想在一个硬件平台上实现虚拟化,在Hypervisor层要实现一个非常关键的功能是,对当前运行在物理硬件上的操作系统的运行上下文进行现场保护,然后把另外一个操作系统的运行上下文恢复到物理硬件上并开始执行代码,从而实现操作系统的动态切换运行。如果一个硬件平台在Hypervisor层已实现了比较复杂的逻辑功能,而且不支持虚拟化功能,在这样的平台上想运行虚拟化软件,将会遇到非常大的困难。
现有的手机平台软件,已经运行了非常复杂的逻辑,已有软件已占据了所有Hypervisor层的物理硬件资源,比如stage 2MMU页表,异常向量表,这样的话,第三方Hypervisor软件没有任何权限和机会在Hypervisor层去执行。
针对现有技术的不足,本申请实施例提出了一种多虚拟机同时运行的方法、装置及电子设备,实现了在硬件只支持一个虚拟化扩展的情况下,可以让多个虚拟机同时运行,并保证各自的功能独立运行。
下面进行详细说明。
实施例一、
图2示出了本申请实施例一中多虚拟机同时运行的方法实施的流程示意图,如图所示,所述多虚拟机同时运行的方法可以包括如下步骤:
步骤201、在Qemu中,发起运行第二操作系统的请求;
步骤202、在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
步骤203、在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
步骤204、在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
具体实施时,Qemu可以作为第一操作系统的一个进程,在Qemu启动后,可以发起运行第二操作系统的请求,本申请实施例可以在KVM模块中增加一个用于切换的功能模块Hypervisor Swap controller(简称Swap controller),由Hypervisor Swap controller负责触发异常到当前运行的第一操作系统的Hypervisor,每个Hypervisor均可以拥有一个用于上下文处理的功能模块Hypervisor Swap entry(简称Swap entry),通过Swap entry实现了对Hypervisor软件的动态切换运行,当一个操作系统需要加载到CPU运行时,Swap controller通过异常调用执行该操作系统的Hypervisor中Swap entry的代码,保存当前操作系统的Hypervisor的上下文,然后把要运行的Hypervisor的上下文写到物理硬件CPU的寄存器并开始运行,由要运行的Hypervisor的Swap entry保存要之前运行的操作系统的上下文并加载要运行的操作系统的上下文。
与现有虚拟化架构的方案相比,本申请实施例在保持原有硬件平台的Hypervisor软件框架不变的情况下,增加了Hypervisor Swap Controller和Hypervisor Swap Entry的功能,实现了在单一的硬件虚拟化扩展的基础上同 时运行多个虚拟机、Hypervisor层的软件动态切换运行,进而支持不同的上层虚拟操作系统即独立功能的实现。
本申请实施例可以应用于硬件平台为多核处理器的情况,对于多核处理器来说,每一个Core可以独立运行一个不同功能类型的虚拟机。
实施中,所述方法可以进一步包括:
在Qemu中监测到第二操作系统运行结束时,在所述第二操作系统的Hypervisor中保存第二操作系统的上下文并加载第一操作系统的上下文;
在KVM模块中,触发异常到第二操作系统的Hypervisor;
在所述第二操作系统的Hypervisor中保存所述第二操作系统的Hypervisor的上下文并加载第一操作系统的Hypervisor的上下文。
具体实施时,当第二操作系统运行结束后,退回到Qemu,本申请实施例在Qemu监测到第二操作系统运行结束后,可以在所述第二操作系统的Hypervisor中保存第二操作系统的上下文并加载第一操作系统的上下文,然后在KVM模块中触发异常到第二操作系统的Hypervisor,在所述第二操作系统的Hypervisor中保存所述第二操作系统的Hypervisor的上下文并加载第一操作系统的Hypervisor的上下文,恢复第一操作系统的Hypervisor及第一操作系统的正常运行。
实施中,在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文,具体可以为:
在所述第一操作系统的Hypervisor中回调KVM模块,在KVM模块中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文。
具体实施时,在Qemu中发起运行第二操作系统的请求后可以在KVM模块中异常调用触发第一操作系统的Hypervisor,由第一操作系统的 Hypervisor回调KVM模块,在KVM模块中对第一操作系统的Hypervisor的上下文进行保存,并加载所述第二操作系统的Hypervisor的上下文到物理硬件处理器的进程中,开始运行第二操作系统的Hypervisor的软件代码;第二操作系统的Hypervisor保存第一操作系统的上下文并加载第二操作系统的上下文到物理硬件上,处理器开始运行第二操作系统。
在第二操作系统运行结束后,可以退回到第二操作系统的Hypervisor中,保存第二操作系统的上下文,同时恢复第一操作系统的上下文。
KVM模块中通过异常调用触发第二操作系统的Hypervisor回调KVM模块,在KVM模块中对第二操作系统的Hypervisor的上下文进行保护,同时恢复第一操作系统的Hypervisor的上下文到物理硬件处理器上,此时,第一操作系统及其Hypervisor恢复正常运行。
实施中,所述第一操作系统可以为主机Host操作系统,所述第一操作系统的Hypervisor可以为平台Hypervisor,所述第二操作系统可以为客户机Guest操作系统,所述第二操作系统的Hypervisor可以为第三方Hypervisor。
具体实施时,系统运行时,可以在Host操作系统以及平台Hypervisor处于正常运行状态,然后收到Guest操作系统的运行请求后,动态切换至第三方Hypervisor,实现Guest操作系统的运行目的;也可以在系统运行时Guest操作系统以及第三方Hypervisor处于正常运行状态,然后收到Host操作系统的运行请求后,动态切换至平台Hypervisor,实现Host操作系统的运行目的。
在Guest操作系统运行结束后,本申请实施例可以自动切换回Host操作系统运行。
实施中,所述第一操作系统的内核为Host Linux kernel,所述第二操作系统的内核为Guest Linux kernel。
具体实施时,操作系统可以为Linux系统,第一虚拟操作系统的内核为 Host Linux kernel,所述第二虚拟操作系统的内核为Guest Linux kernel,本领域技术人员还可以采用其他操作系统内核,本申请对此不作限制。
具体实施时,对于Hypervisor的切换过程,可以预先设置一块空间来保存Hypervisor各自的上下文,本申请实施例可以将两个要切换的Hypervisor的上下文保存到即将加载到CPU上运行的Hypervisor中的栈(stack)空间中,也可以保存在KVM模块的存储空间中。
实施中,所述第三方Hypervisor可以用于对上层支持的主机Host操作系统以及至少一个Guest虚拟操作系统进行切换。
具体实施时,所述平台Hypervisor可以为高通Qualcomm Platform Hypervisor等,所述第三方Hypervisor可以为Xen架构Hypervisor、KVM Hypervisor等。
实施例二、
基于同一发明构思,本申请实施例中还提供了一种多虚拟机同时运行的装置,由于这些设备解决问题的原理与一种多虚拟机同时运行的方法相似,因此这些设备的实施可以参见方法的实施,重复之处不再赘述。
图3示出了本申请实施例二中多虚拟机同时运行的装置的结构示意图,如图所示,所述多虚拟机同时运行的装置可以包括如下步骤:
接收模块301,用于在Qemu中,发起运行第二操作系统的请求;
虚拟机切换模块Hypervisor swap controller 302,用于在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
第一切换接口模块swap entry 303,用于在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
第二切换接口模块swap entry 304,用于在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
实施中,所述第二切换接口模块swap entry可以进一步用于在Qemu中监测到第二操作系统运行结束时,在所述第二操作系统的Hypervisor中保存第二操作系统的上下文并加载第一操作系统的上下文;
所述虚拟机切换模块Hypervisor swap controller可以进一步用于在KVM模块中,触发异常到第二操作系统的Hypervisor;
所述第二切换接口模块swap entry还可以进一步用于在所述第二操作系统的Hypervisor中保存所述操作系统的Hypervisor的上下文并加载第一操作系统的Hypervisor的上下文。
实施中,第一切换接口模块swap entry具体可以用于在所述第一操作系统的Hypervisor中回调KVM模块,在KVM模块中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文。
实施中,所述第一操作系统可以为主机Host操作系统,所述第一操作系统的Hypervisor可以为平台Hypervisor,所述第二操作系统可以为客户机Guest操作系统,所述第二操作系统的Hypervisor可以为第三方Hypervisor。
实施中,所述第一操作系统的内核可以为Host Linux kernel,所述第二操作系统的内核可以为Guest Linux kernel。
为了描述的方便,以上所述装置的各部分以功能分为各种模块或单元分别描述。当然,在实施本申请时可以把各模块或单元的功能在同一个或多个软件或硬件中实现。
实施例三、
基于同一发明构思,本申请实施例还提供了一种电子设备,下面进行说明。
图4示出了本申请实施例三中电子设备的结构示意图,如图所示,所述电子设备可以包括:存储器401、一个或多个处理器402、以及一个或多个模块;
所述一个或多个模块被存储于所述存储器402中,并被配置成由所述一个或多个处理器402执行,所述一个或多个模块包括用于执行上述多虚拟机同时运行的方法中各个步骤的指令。
具体实施时,所述电子设备可以为手机、pad、平板电脑、个人计算机PC、智能机器人等产品。
实施中,所述电子设备还可以进一步包括:显示屏,所述显示屏可以用于显示图形用户界面,所述显示屏具体可以为触摸Touch屏幕、也可以为非触摸屏。
采用本申请实施例所提供的电子设备,即使在硬件只支持一个虚拟化扩展的情况下,也可以让多个虚拟机同时运行并保证各自的功能独立运行。
实施例四、
基于同一发明构思,本申请实施例还提供了一种与电子设备结合使用的计算机程序产品,下面进行说明。
本申请实施例所提供的与电子设备结合使用的计算机程序产品,包括:内嵌于计算机可读的存储介质中的计算机程序,所述计算机程序包括用于使所述电子设备执行上述多虚拟机同时运行的方法中各个步骤的指令。
为了便于本申请的实施,下面以实例进行说明。
实施例五、
本申请实施例以Linux Kernel的虚拟化架构为例进行说明,其中包括Platform Hypervisor和KVM Hypervisor。
图5示出了本申请实施例五中虚拟化架构示意图,如图所示,与现有技术中虚拟化架构方案相比,本申请实施例在保持原有硬件平台的Hypervisor软件框架不变的情况下,整合了Linux开源Hypervisor部分软件代码,并分别在架构图上增加了Hypervisor Swap Controller和Hypervisor Swap Entry的功能,实现了Hypervisor层的软件动态切换运行。
由Swap Controller负责对不同功能的Hypervisor进行动态切换运行,比如Qualcomm Platform Hypervisor、Xen架构Hypervisor、KVM Hypervisor等。再由Hypervisor本身实现对上层支持的操作系统进行切换,比如KVM Hypervisor负责Host Linux及多个Guest Linux虚拟操作系统的切换运行。本申请实施例所提供的技术方案可以在单一的硬件虚拟化扩展的基础上同时运行多个虚拟机,以支持不同的上层虚拟操作系统及独立功能的实现。
图6示出了本申请实施例五中多虚拟机同时运行的框架示意图,如图所示,Hypervisor Swap Controller负责触发Hypervisor的切换,每个Hypervisor拥有一个Swap entry。Swap Controller通过Swap entry实现了对Hypervisor上虚拟机(虚拟操作系统)的动态切换运行,当一个虚拟操作系统需要加载到CPU运行时,Swap Controller通过异常调用执行该虚拟操作系统对应的Hypervisor中Swap entry的代码,保存当前Hypervisor的上下文,然后把要运行的Hypervisor的上下文写到物理硬件CPU的寄存器并开始运行,由所述要运行的Hypervisor保存第一虚拟操作系统的上下文并加载第二虚拟操作系统的上下文,实现第二虚拟操作系统的运行。
图7示出了本申请实施例五中多虚拟机同时运行的流程示意图,如图所示,具体流程可以如下所示:
步骤701、上电复位;
步骤702、Host Linux及Platform Hypervisor处于正常运行状态;
步骤703、当Guest Linux需要运行时,KVM module通过异常调用触发Platform Hypervisor Swap entry回调KVM module Hypervisor swap controller对Platform Hypervisor运行上下文进行现场保护;
步骤704、KVM module Hypervisor swap controller加载KVM Hypervisor的上下文到物理硬件处理器上,开始运行KVM Hypervisor软件代码;
步骤705、KVM Hypervisor保存Host Linux kernel上下文并加载Guest  Linux kernel上下文到物理硬件上,处理器开始运行Guest Linux kernel;
步骤706、Guest Linux kernel运行结束后退回到KVM Hypervisor保存Guest Linux kernel上下文,同时恢复Host Linux kernel上下文;
步骤707、KVM module通过异常调用触发KVM Hypervisor Swap entry回调KVM module Hypervisor swap controller对KVM Hypervisor运行上下文进行现场保护,同时恢复Platform Hypervisor运行上下文到物理硬件处理器;
步骤708、Host Linux及Platform Hypervisor恢复正常运行。
实施例六、
本申请实施例以多核处理器为例进行说明。
图8示出了本申请实施例六中多核处理器的虚拟化架构示意图,如图所示,多核处理器可以为包括多个线程的Linux Kernel,实施时每个内核独立运行一个虚拟操作系统,例如:一个内核作为Host Linux Kernel独立运行Host操作系统,一个内核作为Guest1Linux Kernel独立运行Guest1操作系统(例如:个人操作系统),另外一个内核作为Guest2Linux Kernel独立运行Guest2操作系统(例如:企业操作系统),其中,Guest1操作系统(个人操作系统)可以由Qemu1提供和分配资源,Guest2操作系统(企业操作系统)可以由Qemu2提供和分配资源。
Hypervisor层可以包括多个不同的Hypervisor,例如:Platform Hypervisor、Xen架构Hypervisor、KVM Hypervisor、Linux Containers(LXC)等。
当需要这些虚拟操作系统之间进行切换时,与该虚拟操作系统对应的Hypervisor进行相应的切换,例如:从Platform Hypervisor切换至Xen架构Hypervisor、从Xen架构Hypervisor切换至KVM Hypervisor等,Hypervisor Swap Controller负责触发异常当前正在运行的Hypervisor,并运行该正在运 行的Hypervisor的Swap entry模块。
由该正在运行的Hypervisor的Swap entry模块将正在运行的Hypervisor的上下文保存到指定位置,并将保存在指定位置的目标Hypervisor的上下文加载到CPU寄存器,然后由目标Hypervisor保存之前运行的虚拟操作系统的上下文,并将保存在指定位置的目标Hypervisor对应的虚拟操作系统的上下文加载到CPU寄存器。
其中,所述指定位置可以为Platform Hypervisor、Xen架构Hypervisor、KVM Hypervisor、Linux Containers(LXC)等Hypervisor的一块空间,也可以为KVM模块中的一块空间,实际实施时,需要切换的虚拟操作系统的上下文可以保存在Host Linux Kernel的Qemu里。
具体实施时,Host Linux Kernel可以有多个Qemu,每个Qemu负责为一个虚拟操作系统的运行提供虚拟操作系统的硬件设备资源。
具体数据结构可以为栈,也可以采用其他的数据结构形式(例如:数组、队列等),只需具备存取数据的功能。
具体实施时,所述数据结构可以为多个,例如:两个栈,一个栈用来存放Platform Hypervisor的上下文、一个用来存放KVM Hypervisor的上下文等,上下文的记录状态可以在任意一个栈的底部。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流 程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。

Claims (12)

  1. 一种多虚拟机同时运行的方法,其特征在于,包括:
    在Qemu中,发起运行第二操作系统的请求;
    在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
    在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
    在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
  2. 如权利要求1所述的方法,其特征在于,进一步包括:
    在Qemu中监测到第二操作系统运行结束时,在所述第二操作系统的Hypervisor中保存第二操作系统的上下文并加载第一操作系统的上下文;
    在KVM模块中,触发异常到第二操作系统的Hypervisor;
    在所述第二操作系统的Hypervisor中保存所述第二操作系统的Hypervisor的上下文并加载第一操作系统的Hypervisor的上下文。
  3. 如权利要求1所述的方法,其特征在于,所述在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文,具体为:在所述第一操作系统的Hypervisor中回调KVM模块,在KVM模块中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文。
  4. 如权利要求1所述的方法,其特征在于,所述第一操作系统为主机Host操作系统,所述第一操作系统的Hypervisor为平台Hypervisor,所述第二操作系统为客户机Guest操作系统,所述第二操作系统的Hypervisor为第三方Hypervisor。
  5. 如权利要求1所述的方法,其特征在于,所述第一操作系统的内核为Host Linux kernel,所述第二操作系统的内核为Guest Linux kernel。
  6. 一种多虚拟机同时运行的装置,其特征在于,包括:
    接收模块,用于在Qemu中,发起运行第二操作系统的请求;
    虚拟机切换模块,用于在KVM模块中,触发异常到当前运行的第一操作系统的Hypervisor;
    第一切换接口模块,用于在所述第一操作系统的Hypervisor中保存第一操作系统的Hypervisor的上下文并加载所述第二操作系统的Hypervisor的上下文;
    第二切换接口模块,用于在所述第二操作系统的Hypervisor中保存第一操作系统的上下文并加载第二操作系统的上下文。
  7. 如权利要求6所述的装置,其特征在于,所述第二切换接口模块进一步用于在Qemu中监测到第二操作系统运行结束时,在所述第二操作系统的Hypervisor中保存第二操作系统的上下文并加载第一操作系统的上下文;所述虚拟机切换模块进一步用于在KVM模块中,触发异常到第二操作系统的Hypervisor;所述第二切换接口模块进一步用于在所述第二操作系统的Hypervisor中保存所述第二操作系统的Hypervisor的上下文并加载第一操作系统的Hypervisor的上下文。
  8. 如权利要求6所述的装置,其特征在于,第一切换接口模块具体用于在所述第一操作系统的Hypervisor中回调KVM模块,在KVM模块中保存第一操作系统的Hypervisor的上下文并加载第二操作系统的Hypervisor的上下文。
  9. 如权利要求6所述的装置,其特征在于,所述第一操作系统为主机Host操作系统,所述第一操作系统的Hypervisor为平台Hypervisor,所述第二操作系统为客户机Guest操作系统,所述第二操作系统的Hypervisor为第三方Hypervisor。
  10. 如权利要求6所述的装置,其特征在于,所述第一操作系统的内核 为Host Linux kernel,所述第二操作系统的内核为Guest Linux kernel。
  11. 一种电子设备,其特征在于,包括:存储器、一个或多个处理器、以及一个或多个模块;
    所述一个或多个模块被存储于所述存储器中,并被配置成由所述一个或多个处理器执行,所述一个或多个模块包括用于执行如权利要求1至5任一所述方法中各个步骤的指令。
  12. 一种与电子设备结合使用的计算机程序产品,其特征在于,所述计算机程序产品包括内嵌于计算机可读的存储介质中的计算机程序,所述计算机程序包括用于使所述电子设备执行权利要求1至5中任一所述方法中各个步骤的指令。
PCT/CN2016/112833 2016-12-29 2016-12-29 多虚拟机同时运行的方法、装置及电子设备 WO2018119811A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN201680002889.4A CN107223236B (zh) 2016-12-29 2016-12-29 多虚拟机同时运行的方法、装置及电子设备
PCT/CN2016/112833 WO2018119811A1 (zh) 2016-12-29 2016-12-29 多虚拟机同时运行的方法、装置及电子设备
US16/457,016 US10901766B2 (en) 2016-12-29 2019-06-28 Method and apparatus for simultaneously running multiple virtual machines, and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/112833 WO2018119811A1 (zh) 2016-12-29 2016-12-29 多虚拟机同时运行的方法、装置及电子设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/457,016 Continuation US10901766B2 (en) 2016-12-29 2019-06-28 Method and apparatus for simultaneously running multiple virtual machines, and electronic device

Publications (1)

Publication Number Publication Date
WO2018119811A1 true WO2018119811A1 (zh) 2018-07-05

Family

ID=59927903

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/112833 WO2018119811A1 (zh) 2016-12-29 2016-12-29 多虚拟机同时运行的方法、装置及电子设备

Country Status (3)

Country Link
US (1) US10901766B2 (zh)
CN (1) CN107223236B (zh)
WO (1) WO2018119811A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11080400B2 (en) * 2019-08-28 2021-08-03 Palo Alto Networks, Inc. Analyzing multiple CPU architecture malware samples
CN111745650B (zh) * 2020-06-15 2021-10-15 哈工大机器人(合肥)国际创新研究院 一种机器人操作系统的运行方法和机器人的控制方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1936845A (zh) * 2005-09-19 2007-03-28 联想(北京)有限公司 一种虚拟机系统输入/输出设备动态分配的方法及其设备
CN101051282A (zh) * 2007-05-09 2007-10-10 浙江大学 多操作系统协同工作实现方法
US20110271088A1 (en) * 2010-04-28 2011-11-03 Broadon Communications Corp. Operating system context switching
CN104598294A (zh) * 2015-01-07 2015-05-06 杨学仕 用于移动设备的高效安全的虚拟化方法及其设备

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6496847B1 (en) * 1998-05-15 2002-12-17 Vmware, Inc. System and method for virtualizing computer systems
US7424709B2 (en) * 2003-09-15 2008-09-09 Intel Corporation Use of multiple virtual machine monitors to handle privileged events
US7647589B1 (en) * 2005-02-07 2010-01-12 Parallels Software International, Inc. Methods and systems for safe execution of guest code in virtual machine context
US8886708B2 (en) * 2009-12-02 2014-11-11 Vmware, Inc. Centralized computer network virtualization environment
US9075642B1 (en) * 2011-09-30 2015-07-07 Emc Corporation Controlling access to resources using independent and nested hypervisors in a storage system environment
WO2012163017A1 (zh) * 2011-10-21 2012-12-06 华为技术有限公司 分布式虚拟机访问异常的处理方法以及虚拟机监控器
US9380456B1 (en) * 2013-01-22 2016-06-28 Hypori, Inc. System, method and computer program product for dynamically switching operating systems in a virtual mobile device platform
US9934047B2 (en) * 2014-03-20 2018-04-03 Intel Corporation Techniques for switching between operating systems
US9612926B2 (en) * 2014-05-15 2017-04-04 International Business Machines Corporation Host swap hypervisor that provides high availability for a host of virtual machines
US9658874B2 (en) * 2014-06-18 2017-05-23 International Business Machines Corporation Selecting optimal hypervisor platforms that satisfy application workload requirements
US10162655B2 (en) * 2014-06-23 2018-12-25 Vmware, Inc. Hypervisor context switching using TLB tags in processors having more than two hierarchical privilege levels
US9798567B2 (en) * 2014-11-25 2017-10-24 The Research Foundation For The State University Of New York Multi-hypervisor virtual machines
US10613886B2 (en) * 2015-06-30 2020-04-07 Vmware, Inc. Protecting virtual computing instances
CN105068859B (zh) * 2015-07-29 2017-12-15 上海谐桐信息技术有限公司 一种跨虚拟机的多服务调用方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1936845A (zh) * 2005-09-19 2007-03-28 联想(北京)有限公司 一种虚拟机系统输入/输出设备动态分配的方法及其设备
CN101051282A (zh) * 2007-05-09 2007-10-10 浙江大学 多操作系统协同工作实现方法
US20110271088A1 (en) * 2010-04-28 2011-11-03 Broadon Communications Corp. Operating system context switching
CN104598294A (zh) * 2015-01-07 2015-05-06 杨学仕 用于移动设备的高效安全的虚拟化方法及其设备

Also Published As

Publication number Publication date
US10901766B2 (en) 2021-01-26
US20190317785A1 (en) 2019-10-17
CN107223236A (zh) 2017-09-29
CN107223236B (zh) 2020-05-15

Similar Documents

Publication Publication Date Title
JP7087029B2 (ja) 中央処理装置(cpu)と補助プロセッサとの間の改善した関数コールバック機構
US8458709B2 (en) Dynamic switching of multithreaded processor between single threaded and simultaneous multithreaded modes
US10255090B2 (en) Hypervisor context switching using a redirection exception vector in processors having more than two hierarchical privilege levels
US10162655B2 (en) Hypervisor context switching using TLB tags in processors having more than two hierarchical privilege levels
US7454756B2 (en) Method, apparatus and system for seamlessly sharing devices amongst virtual machines
US9959134B2 (en) Request processing using VM functions
US9286097B2 (en) Switching a first OS in a foreground to a standby state in response to a system event and resuming a second OS from a background
JP2014219977A (ja) 動的仮想マシンサイジング
WO2018039967A1 (zh) 虚拟机切换方法、装置、电子设备和计算机程序产品
JP2011100431A (ja) 仮想マシン制御装置及び仮想マシン制御方法
US10019275B2 (en) Hypervisor context switching using a trampoline scheme in processors having more than two hierarchical privilege levels
US9208030B1 (en) Systems and methods of processing data associated with rapid snapshot and restore of guest operating system states
JP6438039B2 (ja) 装置、方法、コンピュータプログラムおよびコンピュータ可読記憶媒体
JP2012079357A5 (zh)
US20160357645A1 (en) Hardware-assisted application checkpointing and restoring
US20180232038A1 (en) Mobile device virtualization solution based on bare-metal hypervisor with optimal resource usage and power consumption
US20210342173A1 (en) Dynamic power management states for virtual machine migration
WO2018040845A1 (zh) 一种计算资源调度方法及装置
US20150347169A1 (en) Scheduler limited virtual device polling
CN113703924A (zh) 基于可信执行环境的安全虚拟机系统设计方法及系统
US10901766B2 (en) Method and apparatus for simultaneously running multiple virtual machines, and electronic device
WO2015012878A1 (en) Operating system switching method and apparatus
JP2011060225A (ja) オペレーティングシステム起動方法
US9766917B2 (en) Limited virtual device polling based on virtual CPU pre-emption
US10922126B2 (en) Context processing method and apparatus in switching process of multiple virtual machines, and electronic device

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: 16925257

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 28/10/2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16925257

Country of ref document: EP

Kind code of ref document: A1