Virtual processor scheduling method, device, equipment and computer storage medium

By dividing the virtual machine into management and execution virtual machines in a multi-domain system, and creating a virtual processor switching task in a management virtual machine, switching the virtual processor to perform virtual machine operation, the Hypervisor VCPU in a multi-domain system is solved. Scheduling increases the amount of code and security issues, improving the security and efficiency of virtual machine monitors.

CN113238832BActive Publication Date: 2024-12-27PRANUS BEIJING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110553760.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-20
Publication Date
2024-12-27
Estimated Expiration
2041-05-20

AI Technical Summary

Technical Problem

The existing two-level scheduling method of CPUs in multi-domain system causes Hypervisor to handle VCPU scheduling, increasing the code volume and potential attack surface, which is not conducive to the security of Hypervisor.

Method used

By dividing the virtual machine into a management virtual machine and an execution virtual machine, and determining the relationship between each execution virtual machine and a virtual processor, managing the virtual machine creation and performing virtual processor switching tasks, causing the virtual processor to be switched to be trapped in the virtual machine and switch it to the corresponding execution virtual machine running.

Benefits of technology

It simplifies the amount of program code of the virtual machine monitor, enhances its security, and effectively solves the scheduling problem of virtual processors in multi-domain systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113238832B_ABST
    Figure CN113238832B_ABST
Patent Text Reader

Abstract

The present application provides a virtual processor scheduling method, device, electronic device and computer storage medium, and relates to the field of computer system technology. The method includes: determining a management virtual machine and at least one execution virtual machine; the management virtual machine selects and executes a virtual processor switching task to cause the virtual processor to be switched to fall into the virtual machine monitor; the virtual processor to be switched that falls into the virtual machine monitor is switched to the target execution virtual machine with a corresponding relationship for operation. The embodiment of the present application divides the virtual machine into a management virtual machine and an execution virtual machine, creates a virtual processor switching task for each virtual processor in each execution virtual machine through the management virtual machine, and schedules the virtual processor switching task. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computer systems, and in particular to a method, apparatus, device and computer storage medium for scheduling a virtual processor. Background Art

[0002] With the improvement of CPU performance, the limitation of system power consumption and size in actual applications, as well as the technical support of multi-core CPU and hardware virtualization, it has become possible and necessary to run multiple operating systems on a single hardware platform using virtualization technology.

[0003] Hypervisor (virtual machine monitor) is an intermediate software layer running between the physical machine and the Guest OS (virtual machine) operating system. The current Hypervisor virtualization has two levels of CPU scheduling. The first level is the scheduling of the VCPU assigned to the virtual machine by the Hypervisor, and the second level is the scheduling of the virtual machine's own tasks by the virtual machine. In a multi-domain system under a virtualized environment, the Hypervisor runs at a layer closer to the physical hardware, with a higher privilege level than the virtual machine, and controls the startup of multiple domains and the system resources allocated to each domain. Therefore, the Hypervisor needs to have a higher security level.

[0004] In the existing two-level CPU scheduling method for multi-domain systems, the Hypervisor needs to handle the scheduling of the VCPU, which increases the amount of Hypervisor code and also expands the potential attack surface of the Hypervisor, which is not conducive to the security of the Hypervisor. Summary of the invention

[0005] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the existing two-level scheduling method of the CPU of the multi-domain system, in which the Hypervisor needs to handle the scheduling of the VCPU, which increases the amount of code, expands the potential attack surface of the system, and is not conducive to the security of the Hypervisor.

[0006] In a first aspect, a scheduling method for a virtual processor is provided, which is applied to a virtual machine monitor of a multi-domain system, wherein the multi-domain system further includes the virtual processor and at least two virtual machines, and the scheduling method includes:

[0007] Determine a management virtual machine from the at least two virtual machines, and use the other virtual machines except the first virtual machine as execution virtual machines;

[0008] Determining the corresponding relationship between each of the execution virtual machines and the virtual processors;

[0009] Starting the management virtual machine so that the management virtual machine creates and executes a virtual processor switching task; wherein the virtual processor switching task includes an identity of the virtual processor to be switched, and the virtual processor switching task is used to indicate that the virtual processor to be switched falls into the virtual machine monitor;

[0010] The to-be-switched virtual processor trapped in the virtual machine monitor is switched to a target execution virtual machine with a corresponding relationship for execution.

[0011] As a possible implementation manner of the present application, in this implementation manner, determining the correspondence between each of the execution virtual machines and the virtual processors includes:

[0012] Based on a preset configuration file, a corresponding relationship between the execution virtual machine and at least one virtual processor is determined.

[0013] As a possible implementation manner of the present application, in this implementation manner, the starting of the management virtual machine further includes:

[0014] Instructing all virtual processors to run in the management virtual machine;

[0015] Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes:

[0016] The running content of the virtual processor to be switched in the management virtual machine is saved.

[0017] As a possible implementation of the present application, in this implementation,

[0018] Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes:

[0019] The running content of the virtual processor to be switched in the target execution virtual machine is restored.

[0020] As a possible implementation of the present application, in this implementation,

[0021] Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes:

[0022] Creating and starting a running timer, wherein the running timer is used to limit the running time of the virtual processor to be switched in the target execution virtual machine;

[0023] After switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes:

[0024] When the running timer times out, stopping the running of the virtual processor to be switched in the target execution virtual machine;

[0025] The virtual processor to be switched is switched to the management virtual machine for execution.

[0026] In a second aspect, a scheduling method for a virtual processor is provided, which is applied to a management virtual machine of a multi-domain system, wherein the multi-domain system further includes the virtual processor, a virtual machine monitor, and at least one execution virtual machine, and the scheduling method includes:

[0027] Acquire the correspondence between the virtual processor information allocated by the virtual machine monitor to each of the executing virtual machines;

[0028] Creating a virtual processor switching task, wherein the virtual processor switching task is used to instruct the virtual monitor to switch the virtual processor to be switched to a target execution virtual machine corresponding to the virtual processor to be switched for execution;

[0029] The virtual processor switching task is executed.

[0030] In a third aspect, a scheduling device for a virtual processor is provided, which is applied to a virtual machine monitor of a multi-domain system, wherein the multi-domain system further includes a first virtual machine and at least one second virtual machine, and the device includes:

[0031] A virtual machine confirmation module, used to determine a management virtual machine from the at least two virtual machines, and use other virtual machines except the first virtual machine as execution virtual machines;

[0032] A relationship correspondence module, used to determine the correspondence between each of the execution virtual machines and the virtual processors;

[0033] A task creation module, used for starting the management virtual machine so that the management virtual machine creates and executes a virtual processor switching task; wherein the virtual processor switching task includes an identity of the virtual processor to be switched, and the virtual processor switching task is used to indicate that the virtual processor to be switched falls into the virtual machine monitor;

[0034] The scheduling module is used to switch the to-be-switched virtual processor trapped in the virtual machine monitor to a target execution virtual machine with a corresponding relationship for execution.

[0035] In a fourth aspect, a scheduling device for a virtual processor is provided, which is applied to a management virtual machine of a multi-domain system, wherein the multi-domain system further includes the virtual processor, a virtual machine monitor, and at least one execution virtual machine, and the scheduling method includes:

[0036] A relationship acquisition module, used for acquiring the corresponding relationship of the virtual processor information allocated by the virtual machine monitor to each of the executing virtual machines;

[0037] A task creation module, used for creating a virtual processor switching task, wherein the virtual processor switching task is used for instructing the virtual monitor to switch the virtual processor to be switched to a target execution virtual machine corresponding to the virtual processor to be switched for execution;

[0038] The task execution module is used to execute the virtual processor switching task.

[0039] In a fifth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned virtual processor scheduling method when executing the program.

[0040] In a fourth aspect, a computer storage medium is provided, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the above-mentioned virtual processor scheduling method.

[0041] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each virtual machine is created by the management virtual machine, and the scheduler in the management virtual machine schedules and executes the virtual processor switching task, so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor, and the virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0043] Figure 1 A flowchart of a virtual processor scheduling method provided in an embodiment of the present application;

[0044] Figure 2A schematic diagram of a multi-domain system framework provided in an embodiment of the present application;

[0045] Figure 3 A processor switching timing diagram provided in an embodiment of the present application;

[0046] Figure 4 A flowchart of a scheduling method for managing a virtual processor of a virtual machine provided in an embodiment of the present application;

[0047] Figure 5 A schematic diagram of the structure of a scheduling device applied to a virtual machine monitor provided in an embodiment of the present application;

[0048] Figure 6 A schematic diagram of the structure of a scheduling device for managing virtual machines provided in an embodiment of the present application;

[0049] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0050] The above and other features, advantages and aspects of the embodiments of the present application will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. DETAILED DESCRIPTION

[0051] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0052] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0053] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0054] The virtual processor scheduling method, device, electronic device and computer storage medium provided in the present application are intended to solve the above technical problems in the prior art.

[0055] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0056] In an embodiment of the present application, a scheduling method for a virtual processor is provided, and the method is applied to a virtual machine monitor of a multi-domain system, wherein the multi-domain system also includes a virtual processor and at least two virtual machines, such as Figure 1 As shown, the method includes:

[0057] Step S101 : determining a management virtual machine from the at least two virtual machines, and using the other virtual machines except the first virtual machine as execution virtual machines.

[0058] In an embodiment of the present application, a scheduling method for a virtual processor is provided for a multi-domain system in a virtual environment, wherein the multi-domain system includes a virtual machine monitor, multiple virtual machines, and multiple virtual processors, wherein the multiple virtual processors are obtained by virtualizing physical processors by the virtual machine monitor. When the virtual machine monitor manages the virtual machines, it first determines one of the virtual machines as a management virtual machine, determines the other virtual machines except the management virtual machine as execution virtual machines, and allocates all virtual processors to the management virtual machine, and the management virtual machine schedules the virtual processors.

[0059] Step S102, determining the correspondence between each of the executing virtual machines and the virtual processors.

[0060] In an embodiment of the present application, after the multi-domain system is initialized, the correspondence between each execution virtual machine and the virtual processor is determined according to a preset configuration file. The correspondence between each execution virtual machine and the virtual processor refers to which virtual processor or processors can be switched to which execution virtual machine for operation. For the convenience of explanation, taking a specific embodiment as an example, the management virtual machine is VM0, the execution virtual machines include VM1 and VM2, and the virtual processors include VCPU0, VCPU1, VCPU2 and VCPU3. When the system starts, VCPU0, VCPU1, VCPU2 and VCPU3 are all running in the management virtual machine VM0. At this time, the virtual machine monitor needs to confirm the correspondence between each execution virtual machine and each virtual processor, such as determining that VCPU0 can be switched to VM1 for operation, and VCPU1, VCPU and VCPU3 can be switched to VM2 for operation. Of course, the number of execution virtual machines and the number of virtual processors can be more, and the correspondence between the execution virtual machine and the virtual processor can also be different, which can be changed according to actual conditions.

[0061] Step S103, starting the management virtual machine to enable the management virtual machine to create and execute a virtual processor switching task; wherein the virtual processor switching task includes an identity of the virtual processor to be switched, and the virtual processor switching task is used to instruct the virtual processor to be switched to fall into the virtual machine monitor.

[0062] In an embodiment of the present application, after the multi-domain system is initialized, a management virtual machine is started. A mature operating system, such as a Windows system, a Linux system, etc., runs in the management virtual machine. After the management virtual machine is started, the operating system in the management virtual machine falls into the virtual machine monitor, obtains the correspondence between each execution virtual machine and the virtual processor, and creates a virtual processor switching task for the virtual processor of each execution virtual machine based on the correspondence. The virtual processor switching task includes at least the identity of the virtual processor to be switched. For the convenience of explanation, taking the aforementioned embodiment as an example, the management virtual machine is VM0, the execution virtual machines include VM1 and VM2, and the virtual processors include VCPU0, VCPU1, VCPU2, and VCPU3. When the system starts, VCPU0, VCPU1, VCPU2, and VCPU3 are all in the management virtual machine VM0. Running, at this time, the virtual machine monitor needs to confirm the correspondence between each executing virtual machine and each virtual processor, such as determining that VCPU0 can be switched to VM1 for running, VCPU1, VCPU2, and VCPU3 can be switched to VM2 for running, then when creating a virtual processor switching task for each virtual processor executing the virtual machine, as a possible implementation mode of the present application, the virtual processor switching task can be a daemon task, such as the tasks that can be created are VM1_VCPU0_daemon, VM1_VCPU1_daemon, VM2_VCPU2_daemon, and VM2_VCPU3_daemon, wherein VM1 and VM2 respectively represent the identity information of the virtual machines, and VCPU0, VCPU1, VCPU2, and VCPU3 respectively represent the identity identifiers of the virtual processors.

[0063] In the embodiment of the present application, after the system initialization is completed, the management virtual machine will cyclically select new tasks to execute in the task queue. When a virtual processor switching task of a certain virtual processor is selected, if the executed virtual processor switching task is VM1_VCPU0_daemon, then based on this task, VCPUO will fall into the virtual machine monitor.

[0064] Step S104: Switch the to-be-switched virtual processor trapped in the virtual machine monitor to a target execution virtual machine with a corresponding relationship for execution.

[0065] In an embodiment of the present application, based on the above embodiment, the virtual machine monitor will switch the trapped virtual processor to be switched to the corresponding execution virtual machine for execution. For example, if the virtual processor switching task is VM1_VCPU0_daemon, then the virtual processor to be switched is VCPU0, and the virtual machine monitor will switch VCPU0 to the execution virtual machine VM1 for execution.

[0066] In the embodiments of the present application, Figure 2 As shown, it is a framework diagram of a multi-domain system provided by an embodiment of the present application, wherein Task tasks exist in both the management virtual machine VM0 and the execution virtual machine, and the management virtual machine also has a virtual processor switching task for each virtual processor in each execution virtual machine.

[0067] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the scheduler in the management virtual machine schedules and executes the virtual processor switching task, so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor, and the virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0068] As a possible implementation manner of the present application, in this implementation manner, determining the correspondence between each of the execution virtual machines and the virtual processors includes:

[0069] Based on a preset configuration file, a corresponding relationship between the execution virtual machine and at least one virtual processor is determined.

[0070] In an embodiment of the present application, when determining the correspondence between each execution virtual machine and the virtual processor, it can be determined based on a preset configuration file, wherein the preset configuration file can be determined by the staff based on the complexity of the program running in the execution virtual machine, wherein the complexity of the program running in each of the execution virtual machines can be determined according to the type of program running in each execution virtual machine, or can be determined according to the amount of code of the program running in each execution virtual machine. Of course, these are determined by the staff based on prior knowledge.

[0071] In the embodiments of the present application, for the convenience of explanation, a specific embodiment is taken as an example, based on the complexity of the program running in each execution virtual machine, the virtual processor corresponding to each execution virtual machine is determined, for example, the management virtual machine is VM0, the execution virtual machines include VM1 and VM2, and the virtual processors include VCPU0, VCPU1, VCPU2, and VCPU3. When the system starts, VCPU0, VCPU1, VCPU2, and VCPU3 are all in the management virtual machine VM0, wherein the execution virtual machine VM1 runs a complete operating system, such as the Linux system, which is a relatively complex program and needs to be allocated two virtual processors, and a corresponding relationship can be established between VCPU0 and VCPU1 and the execution virtual machine VM1, and a simple bare metal program is run in the execution virtual machine VM2, which only needs one virtual processor, and a corresponding relationship can be established between VCPU2 and the execution virtual machine VM2. Of course, the number of execution virtual machines can be more, the number of virtual processors can also be more, and the corresponding relationship between the execution virtual machine and the virtual processor can be configured according to the actual situation.

[0072] The embodiment of the present application determines the correspondence between each execution virtual machine and at least one virtual processor based on the complexity of the program running in the execution virtual machine, thereby ensuring maximum resource utilization of the virtual processor.

[0073] As a possible implementation manner of the present application, in this implementation manner, the starting of the management virtual machine further includes:

[0074] Instructing all virtual processors to run in the management virtual machine;

[0075] Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes:

[0076] The running content of the virtual processor to be switched in the management virtual machine is saved.

[0077] In the embodiment itself, after starting the management virtual machine, the virtual machine monitor switches all virtual processors to the management virtual machine to run, so that the management virtual machine can select tasks to execute. At this time, all virtual processors are running in the management virtual machine. When the management virtual machine selects a virtual processor switching task of a virtual processor, the corresponding virtual processor will fall into the virtual machine monitor. At this time, the virtual monitor will save the context of the running content of the virtual processor in the management virtual machine. For the convenience of explanation, taking a specific embodiment as an example, the management virtual machine is VM0, the execution virtual machines include VM1 and VM2, and the virtual processors include VCPU0, VCPU1, VCPU2, and VCPU3. When the system starts, VCPU0, VCPU1, VCPU2, and VCPU3 are all in the management virtual machine VM0. At this time, the virtual machine monitor needs to confirm the corresponding relationship between each execution virtual machine and each virtual processor. If it is determined that VCPU0 can be switched to VM1 for operation, and VCPU1 and VCPU2 can be switched to VM2 for operation, then when creating a virtual processor switching task for each virtual processor of the execution virtual machine, the task that can be created is VM1_VCPU0_daem. on, VM1_VCPU1_daemon, VM2_VCPU2_daemon, where VM1 and VM1 represent the identity information of the virtual machines respectively, and VCPU0, VCPU1, and VCPU2 represent the identities of the virtual processors respectively. After the management virtual machine is started, VCPU0, VCPU1, VCPU2, and VCPU3 all run in the management virtual machine. When the management virtual machine selects the virtual processor switching task VM1_VCPU0_daemon, the task is switched to VCPU0 for execution. At this time, VCPU0 will fall into the virtual machine monitor, and the virtual machine monitor begins to save the context of the running content of VCPU0 in the management virtual machine VM0.

[0078] The embodiment of the present application saves the context of the content of the virtual processor to be switched running in the management virtual machine, thereby ensuring that the virtual processor to be switched can return to the management virtual machine to continue to complete the task after completing the operation in the execution virtual machine.

[0079] As a possible implementation manner of the present application, in this implementation manner, the executing the virtual processor switching task, before switching the virtual processor to be switched to the target execution virtual machine for execution, further includes:

[0080] The running content of the virtual processor to be switched in the target execution virtual machine is restored.

[0081] In an embodiment of the present application, before the processor of the virtual machine to be switched is assigned to the target execution virtual machine, it is necessary to first restore the running content of the virtual processor to be switched in the target execution virtual machine, so that the process can continue to be executed after the virtual processor to be switched is switched to the target execution virtual machine.

[0082] The embodiment of the present application restores the running content of the virtual processor to be switched in the target execution virtual machine, so that the virtual processor to be switched can continue to execute tasks after being allocated to the target execution virtual machine.

[0083] As a possible implementation manner of the present application, in this implementation manner, the executing the virtual processor switching task, before switching the virtual processor to be switched to the target execution virtual machine for execution, further includes:

[0084] Creating and starting a running timer, wherein the running timer is used to limit the running time of the virtual processor to be switched in the target execution virtual machine;

[0085] After executing the virtual processor switching task and switching the virtual processor to be switched to the target execution virtual machine for execution, the method further includes:

[0086] When the running timer times out, stopping the running of the virtual processor to be switched in the target execution virtual machine;

[0087] The virtual processor to be switched is switched to the management virtual machine for execution.

[0088] In an embodiment of the present application, when scheduling a virtual processor, it is necessary to create a run timer, which is used to limit the running time of the virtual processor to be switched in the target execution virtual machine. When the run timer times out, the running of the virtual processor to be switched in the target execution virtual machine is stopped; and the virtual processor to be switched is switched to the management virtual machine for running.

[0089] For the embodiment of the present application, for the convenience of description, a specific embodiment is taken as an example, the management virtual machine is VM0, the execution virtual machine is VM1, and the virtual processor is VCPU0. Figure 3 As shown, it is a scheduling timing diagram of a virtual processor provided in an embodiment of the present application. The management virtual machine selects a new task to execute. When the virtual processor switching task of VCPU0 is selected, the execution timer is started, and VCPU0 falls into the virtual machine monitor. The virtual machine monitor executes the switching of VCPU0 between VM0 and VM1. When the timer times out, an interrupt occurs and returns to VM0. VM0 reselects other tasks to execute.

[0090] The embodiment of the present application sets an execution timer to ensure the running time of the virtual processor to be switched in the target execution virtual machine, thereby ensuring work efficiency.

[0091] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the management virtual machine reads the virtual processor switching task so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor. The virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0092] The present application embodiment provides a scheduling method for a virtual processor, which is applied to a management virtual machine of a multi-domain system, wherein the multi-domain system further includes the virtual processor, a virtual machine monitor, and at least one execution virtual machine, such as Figure 4 As shown, the scheduling method includes:

[0093] Step S401: Obtain the correspondence between the virtual processor information allocated by the virtual machine monitor to each of the executing virtual machines.

[0094] In an embodiment of the present application, the scheduling method of the virtual processor is applied to a management virtual machine. After the management virtual machine is started, it falls into a virtual machine monitor to obtain the correspondence between the virtual processor information allocated by the virtual machine monitor to each of the execution virtual machines. For the convenience of explanation, taking the aforementioned embodiment as an example, the management virtual machine is VM0, the execution virtual machines include VM1 and VM2, and the virtual processors include VCPU0, VCPU1, VCPU2, and VCPU3. When the system starts, VCPU0, VCPU1, VCPU2, and VCPU3 are all in the management virtual machine VM0. At this time, the virtual machine monitor needs to confirm the correspondence between each execution virtual machine and each virtual processor, such as determining that VCPU0 can be switched to VM1 for operation, and VCPU1, VCPU2, and VCPU3 can be switched to VM2 for operation.

[0095] Step S402: creating a virtual processor switching task, wherein the virtual processor switching task is used to instruct the virtual monitor to switch the virtual processor to be switched to a target execution virtual machine corresponding to the virtual processor to be switched for execution.

[0096] In an embodiment of the present application, after obtaining the correspondence between each executing virtual machine and each virtual processor, a virtual processor switching task is created for each virtual processor in each executing virtual machine. For example, if it is determined that VCPU0 can be switched to VM1 for execution, and VCPU1 and VCPU2 can be switched to VM2 for execution, then when creating a virtual processor switching task for each virtual processor executing virtual machine, the tasks that can be created are VM1_VCPU0_daemon, VM1_VCPU1_daemon, VM2_VCPU2_daemon, and VM2_VCPU3_daemon, wherein VM1 and VM1 respectively represent the identity information of the virtual machines, and VCPU0, VCPU1, VCPU2, and VCPU3 respectively represent the identity identifiers of the virtual processors, and these virtual processor switching tasks are sent to the task queue.

[0097] Step S403: executing the virtual processor switching task.

[0098] In an embodiment of the present application, the management virtual machine cyclically selects tasks in the task queue to execute, and when a virtual processor switching task is selected, the virtual processor switching task is executed, wherein the execution process has been described in the aforementioned embodiment and will not be repeated here.

[0099] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the management virtual machine reads the virtual processor switching task so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor. The virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0100] The present application embodiment provides a scheduling device for a virtual processor, such as Figure 5 As shown, the virtual processor scheduling device 50 may include: a virtual machine confirmation module 501, a relationship correspondence module 502, a task creation module 503, and a scheduling module 504, wherein:

[0101] A virtual machine confirmation module 501 is used to determine a management virtual machine from the at least two virtual machines, and use other virtual machines except the first virtual machine as execution virtual machines;

[0102] A relationship correspondence module 502, used to determine the correspondence between each of the executing virtual machines and the virtual processors;

[0103] The task creation module 503 is used to start the management virtual machine so that the management virtual machine creates and executes a virtual processor switching task; wherein the virtual processor switching task includes an identity of the virtual processor to be switched, and the management virtual machine switches the virtual processor switching task to the corresponding virtual processor to be switched so that the virtual processor to be switched falls into the virtual machine monitor;

[0104] The scheduling module 504 is used to switch the to-be-switched virtual processor trapped in the virtual machine monitor to a target execution virtual machine with a corresponding relationship for execution.

[0105] As a possible implementation of the present application, when determining the correspondence between each of the executing virtual machines and the virtual processors, the relationship correspondence module 502 may be used to:

[0106] Based on a preset configuration file, a corresponding relationship between the execution virtual machine and at least one virtual processor is determined.

[0107] As a possible implementation of the present application, after starting the management virtual machine, the task creation module 503 may also be used to:

[0108] Instructing all virtual processors to run in the management virtual machine;

[0109] Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the scheduling module 504 may also be used to:

[0110] The running content of the virtual processor to be switched in the management virtual machine is saved.

[0111] As a possible implementation of the present application, in this implementation, before the scheduling module 504 switches the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, it can also be used to:

[0112] The running content of the virtual processor to be switched in the target execution virtual machine is restored.

[0113] As a possible implementation of the present application, in this implementation, before the scheduling module 504 switches the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, it can also be used to:

[0114] Creating and starting a running timer, wherein the running timer is used to limit the running time of the virtual processor to be switched in the target execution virtual machine;

[0115] After switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the scheduling module 504 may also be used to:

[0116] When the running timer times out, stopping the running of the virtual processor to be switched in the target execution virtual machine;

[0117] The virtual processor to be switched is switched to the management virtual machine for execution.

[0118] The virtual processor scheduling device of the embodiment of the present application can execute the virtual processor scheduling method shown in the aforementioned embodiment of the present application, and its implementation principle is similar and will not be repeated here.

[0119] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the management virtual machine reads the virtual processor switching task so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor. The virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0120] The present application embodiment provides a scheduling device for a virtual processor, such as Figure 6 As shown, the virtual processor scheduling device 60 may include: a relationship acquisition module 601, a task creation module 602, and a task execution module 603, wherein:

[0121] A relationship acquisition module 601 is used to acquire the corresponding relationship of the virtual processor information allocated by the virtual machine monitor to each of the executing virtual machines;

[0122] A task creation module 602 is used to create a virtual processor switching task, wherein the virtual processor switching task is used to instruct the virtual monitor to switch the virtual processor to be switched to the target execution virtual machine corresponding to the virtual processor to be switched for execution;

[0123] The task execution module 603 is used to execute the virtual processor switching task.

[0124] The virtual processor scheduling device of the embodiment of the present application can execute the virtual processor scheduling method shown in the aforementioned embodiment of the present application, and its implementation principle is similar and will not be repeated here.

[0125] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the management virtual machine reads the virtual processor switching task so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor. The virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0126] An electronic device is provided in an embodiment of the present application, and the electronic device includes: a memory and a processor; at least one program, stored in the memory, and used to, when executed by the processor, determine a management virtual machine from the at least two virtual machines, and use other virtual machines except the first virtual machine as execution virtual machines; determine the correspondence between each of the execution virtual machines and the virtual processor; start the management virtual machine so that the management virtual machine creates and executes a virtual processor switching task; wherein the virtual processor switching task includes an identity identifier of the virtual processor to be switched, and the management virtual machine switches the virtual processor switching task to the corresponding virtual processor to be switched, so that the virtual processor to be switched falls into the virtual machine monitor; and switches the virtual processor to be switched that falls into the virtual machine monitor to run in a target execution virtual machine with a corresponding relationship.

[0127] The embodiment of the present application divides a virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor. A virtual processor switching task for each virtual processor in each execution virtual machine is created by the management virtual machine, and the management virtual machine reads the virtual processor switching task so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor. The virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in a multi-domain system at the same time.

[0128] In an alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0129] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0130] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0131] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0132] The memory 4003 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the application code stored in the memory 4003 to implement the contents shown in the above method embodiment.

[0133] Among them, electronic devices include but are not limited to: computers, servers, cloud servers, tablet computers, etc.

[0134] The embodiment of the present application provides a computer storage medium, on which a computer program is stored, and when the computer is run on a computer, the computer can execute the corresponding content in the above method embodiment. Compared with the prior art, the embodiment of the present application divides the virtual machine into a management virtual machine and an execution virtual machine, and determines the relationship between each execution virtual machine and each virtual processor, creates a virtual processor switching task for each virtual processor in each execution virtual machine through the management virtual machine, and reads the virtual processor switching task by the management virtual machine, so that the virtual processor corresponding to the virtual processor switching task falls into the virtual machine monitor, and the virtual machine monitor switches the virtual processor to the corresponding execution virtual machine for operation. The virtual machine monitor only needs to execute the switching of the virtual processor, which greatly simplifies the program code amount of the virtual machine monitor, enhances the security of the virtual machine monitor, and can solve the scheduling problem of virtual processors in multi-domain systems at the same time.

[0135] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0136] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A virtual processor scheduling method, applied to a virtual machine monitor of a multi-domain system, characterized in that: The multi-domain system further includes a virtual processor and at least two virtual machines, and the scheduling method includes: Determine a management virtual machine from the at least two virtual machines, use the other virtual machines except the management virtual machine among the at least two virtual machines as execution virtual machines, allocate all virtual processors to the management virtual machine, and schedule the virtual processors by the management virtual machine; Determining a correspondence between each of the execution virtual machines and the virtual processor based on the complexity of the program running in the execution virtual machine; the correspondence includes: a candidate virtual processor running in the execution virtual machine; The management virtual machine is started, so that the management virtual machine creates a virtual processor switching task for each virtual processor of the execution virtual machine according to the corresponding relationship, and the scheduler in the management virtual machine schedules and executes the virtual processor switching task, and the virtual processor to be switched is trapped in the virtual machine monitor; wherein the virtual processor switching task includes the identity of the virtual processor to be switched and the identity information of the target execution virtual machine corresponding to the virtual processor to be switched, and the virtual processor switching task is used to instruct the virtual machine monitor to switch the virtual processor to be switched to the target execution virtual machine for operation; The to-be-switched virtual processor trapped in the virtual machine monitor is switched to a target execution virtual machine with a corresponding relationship for execution; the candidate virtual processors corresponding to the target execution virtual machine include the to-be-switched virtual processor.

2. The virtual processor scheduling method according to claim 1, characterized in that: The determining of the correspondence between each of the executing virtual machines and the virtual processors includes: Based on a preset configuration file, a corresponding relationship between the execution virtual machine and at least one virtual processor is determined.

3. The virtual processor scheduling method according to claim 1, characterized in that: The step of starting the management virtual machine further includes: Instructing all virtual processors to run in the management virtual machine; Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes: The running content of the virtual processor to be switched in the management virtual machine is saved.

4. The virtual processor scheduling method according to claim 1, characterized in that: Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes: The running content of the virtual processor to be switched in the target execution virtual machine is restored.

5. The virtual processor scheduling method according to claim 1, characterized in that: Before switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes: Creating and starting a running timer, wherein the running timer is used to limit the running time of the virtual processor to be switched in the target execution virtual machine; After switching the to-be-switched virtual processor trapped in the virtual machine monitor to the target execution virtual machine with a corresponding relationship for execution, the method further includes: When the running timer times out, stopping the running of the virtual processor to be switched in the target execution virtual machine; The virtual processor to be switched is switched to the management virtual machine for execution.

6. A virtual processor scheduling method, applied to a management virtual machine of a multi-domain system, characterized in that: The multi-domain system further includes a virtual processor, a virtual machine monitor, and at least one execution virtual machine, wherein the management virtual machine is used to schedule the virtual processor, and the scheduling method includes: Obtaining a correspondence between virtual processor information allocated by the virtual machine monitor to each of the executing virtual machines based on the complexity of the program running in the executing virtual machine; the correspondence includes: candidate virtual processors running in the executing virtual machine; According to the corresponding relationship, a virtual processor switching task is created for each virtual processor of the execution virtual machine, wherein the virtual processor switching task is used to instruct the virtual machine monitor to switch the virtual processor to be switched to the target execution virtual machine corresponding to the virtual processor to be switched for execution; wherein the virtual processor switching task includes the identity of the virtual processor to be switched and the identity information of the target execution virtual machine; the candidate virtual processors corresponding to the target execution virtual machine include the virtual processor to be switched; and the candidate virtual processors corresponding to the target execution virtual machine include the virtual processor to be switched; The virtual processor switching task is executed to trap the virtual processor to be switched into the virtual machine monitor.

7. A virtual processor scheduling device, applied to a virtual machine monitor of a multi-domain system, wherein the multi-domain system further comprises a virtual processor and at least two virtual machines, characterized in that: include: a virtual machine confirmation module, configured to determine a management virtual machine from the at least two virtual machines, use the other virtual machines except the management virtual machine among the at least two virtual machines as execution virtual machines, allocate all virtual processors to the management virtual machine, and schedule the virtual processors by the management virtual machine; A relationship correspondence module, used to determine the correspondence between each of the execution virtual machines and the virtual processor based on the complexity of the program running in the execution virtual machine; The corresponding relationship includes: a candidate virtual processor running in the execution virtual machine; A task determination module is used to start the management virtual machine so that the management virtual machine creates and executes a virtual processor switching task for each virtual processor of the execution virtual machine according to the corresponding relationship, and traps the virtual processor to be switched into the virtual machine monitor; wherein the virtual processor switching task includes the identity of the virtual processor to be switched and the identity information of the target execution virtual machine corresponding to the virtual processor to be switched, and the virtual processor switching task is used to instruct the virtual machine monitor to switch the virtual processor to be switched to the target execution virtual machine for operation; The scheduling module is used to switch the to-be-switched virtual processor trapped in the virtual machine monitor to a corresponding target execution virtual machine for execution; the candidate virtual processors corresponding to the target execution virtual machine include the to-be-switched virtual processor.

8. A virtual processor scheduling device, applied to a management virtual machine of a multi-domain system, characterized in that: The multi-domain system further includes a virtual processor, a virtual machine monitor and at least one execution virtual machine, the management virtual machine is used to schedule the virtual processor, and the device includes: A relationship acquisition module, used to obtain the correspondence between the virtual processor information allocated by the virtual machine monitor to each of the execution virtual machines based on the complexity of the program running in the execution virtual machine; the correspondence includes: candidate virtual processors running in the execution virtual machine; A task creation module, used for creating a virtual processor switching task for each virtual processor of the execution virtual machine according to the corresponding relationship, wherein the virtual processor switching task is used to instruct the virtual machine monitor to switch the virtual processor to be switched to the target execution virtual machine corresponding to the virtual processor to be switched for execution; wherein the virtual processor switching task includes the identity of the virtual processor to be switched and the identity information of the target execution virtual machine; the candidate virtual processors corresponding to the target execution virtual machine include the virtual processor to be switched; the candidate virtual processors corresponding to the target execution virtual machine include the virtual processor to be switched; The task execution module is used to execute the virtual processor switching task and trap the virtual processor to be switched into the virtual machine monitor.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the virtual processor scheduling method according to any one of claims 1 to 6 is implemented.

10. A computer storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the virtual processor scheduling method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multicore platform-orientated asymmetrical dispatcher for monitor of virtual machine and dispatching method thereof

    CN101727351A

  • Xen virtual machine scheduling control method in multi-core environment

    CN102253857A