Method and device for hot upgrade of virtual machine
By creating multi-child threaded QEMU components on the DPU and synchronizing status information during the virtual machine hot upgrade, the problem of long downtime during the virtual machine hot upgrade is solved, and the hot upgrade with zero downtime is achieved, and the performance of the virtual machine is improved.
Patent Information
- Application Number
- CN202411376852.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2044-09-29
Smart Images

Figure CN119201190B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the technical field of virtual machines, and in particular, to a method and device for hot upgrading a virtual machine. Background Art
[0002] In a virtualization scenario, to iterate the functions and fix the defects of a virtual machine, a new component version needs to be released. To avoid affecting the running virtual machine, the hot upgrade capability is usually used to upgrade the components of the virtual machine to the latest version.
[0003] In the prior art, the hot upgrade process of a virtual machine is similar to the hot migration of a virtual machine, which specifically includes: starting a new virtual machine using new KVM (Kernel - Based Virtual Machine) components and QEMU (Quick Emulator) components, then pausing the running virtual machine, synchronizing the states that the virtual machine needs to maintain to the new virtual machine, then starting the new virtual machine to run, and at the same time exiting the old virtual machine. In this way, the hot upgrade of QEMU components and KVM components can be achieved without restarting the virtual machine. Although the hot upgrade does not require the virtual machine to be shut down and restarted, it still needs to pause the virtual machine for state saving and restoration operations. Therefore, there will be a short - time state where the virtual machine service is unavailable during the hot upgrade, and this period is called the downtime of the virtual machine hot upgrade.
[0004] The inventors found that the prior art has at least the following technical problems: when hot - upgrading a virtual machine through the prior art, the downtime of the virtual machine is relatively long. Summary of the Invention
[0005] Embodiments of the present disclosure provide a method and device for hot - upgrading a virtual machine, which can reduce the downtime during the hot - upgrade process of the virtual machine.
[0006] In a first aspect, embodiments of the present disclosure provide a method for hot - upgrading a virtual machine, including:
[0007] Creating a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processor Unit (DPU), where the QEMU component includes multiple sub - threads, the sub - threads in the QEMU component correspond one - to - one with the VCPU threads on the physical machine side, and the sub - threads in the QEMU component are used to receive and process Input / Output (IO) requests sent by the corresponding VCPU threads;
[0008] Responding to a hot - upgrade instruction for a target QEMU component corresponding to a target virtual machine, creating a new QEMU component corresponding to the target virtual machine on the DPU;
[0009] Suspend the target QEMU component on the DPU, save the status information of each sub-thread in the target QEMU component, and synchronize the status information of each sub-thread to the new QEMU component;
[0010] Receive and process the IO requests sent by the VCPU thread through the new QEMU component.
[0011] In a second aspect, an embodiment of the present disclosure provides a hot upgrade device for a virtual machine, including:
[0012] A creation unit, configured to create a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processor Unit (DPU), where the QEMU component includes a plurality of sub-threads, and the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process the input / output (IO) requests sent by the corresponding VCPU threads;
[0013] A hot upgrade unit, configured to, in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, create a new QEMU component corresponding to the target virtual machine on the DPU;
[0014] A synchronization unit, configured to suspend the target QEMU component on the DPU, save the status information of each sub-thread in the target QEMU component, and synchronize the status information of each sub-thread to the new QEMU component;
[0015] A processing unit, configured to receive and process the IO requests sent by the VCPU thread through the new QEMU component.
[0016] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
[0017] The memory stores computer-executable instructions;
[0018] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the hot upgrade method of the virtual machine as described in the first aspect and various possible designs of the first aspect above.
[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the processor executes the computer-executable instructions, the hot upgrade method of the virtual machine as described in the first aspect and various possible designs of the first aspect above is implemented.
[0020] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program which, when executed by a processor, implements the hot upgrade method of the virtual machine as described in the first aspect above and various possible designs of the first aspect.
[0021] The hot upgrade method and device for a virtual machine provided in this embodiment include: creating a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processing Unit (DPU), where the QEMU component includes multiple sub-threads. The sub-threads in the QEMU component correspond one-to-one with the Virtual CPU (VCPU) threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input / output (IO) requests sent by the VCPU threads corresponding to them; in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, creating a new QEMU component corresponding to the target virtual machine on the DPU; pausing the target QEMU component on the DPU, saving the status information of each sub-thread in the target QEMU component, and synchronizing the status information of each sub-thread to the new QEMU component; and receiving and processing IO requests sent by the VCPU threads through the new QEMU component. In this technical solution, when upgrading the QEMU component, only the QEMU component running on the DPU card needs to be paused, without pausing the VCPU threads on the physical machine. In this way, when upgrading the QEMU component, the VCPU threads of the virtual machine are running normally, achieving zero downtime for the hot upgrade of the QEMU component, and thus reducing the downtime during the hot upgrade of the virtual machine. Description of the Drawings
[0022] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or in the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0023] Figure 1 It is a schematic diagram of the application scenario of the hot upgrade method of the virtual machine provided in the embodiment of the present disclosure;
[0024] Figure 2 It is the flow of the hot upgrade method of the virtual machine provided in the embodiment of the present disclosure Figure 1 ;
[0025] Figure 3 It is a schematic illustration of the hot upgrade method of the virtual machine provided in the embodiment of the present disclosure Figure 1 ;
[0026] Figure 4 It is the flow of the hot upgrade method of the virtual machine provided in the embodiment of the present disclosure Figure 2 ;
[0027] Figure 5 Schematic diagram of the hot upgrade method for a virtual machine provided by an embodiment of the present disclosure Figure 2 ;
[0028] Figure 6 Structural schematic diagram of the hot upgrade device for a virtual machine provided by an embodiment of the present disclosure;
[0029] Figure 7 Structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0030] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.
[0031] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.
[0032] In a virtualization scenario, for the function iteration and defect repair of a virtual machine, a new component version needs to be released. To avoid affecting the running virtual machine, the hot upgrade capability is usually used to upgrade the components of the virtual machine to the latest version. In some embodiments, the virtualized data plane components include the QEMU component and the KVM component. Among them, the QEMU component is a user-space program, and the KVM component is a kernel module. One virtual machine corresponds to one QEMU component, and the QEMU component contains multiple sub-threads. Each virtual central processing unit (VCPU) in the virtual machine corresponds to a sub-thread in the QEMU component.
[0033] In the prior art, the hot upgrade process of a virtual machine is similar to the hot migration of a virtual machine, which specifically includes: using a new KVM and QEMU to start a new virtual machine, then pausing the running virtual machine, synchronizing the state that the virtual machine needs to guarantee to the new virtual machine, and then starting the new virtual machine to run, while exiting the old virtual machine, so that there is no need to restart the virtual machine to achieve the hot upgrade of QEMU and KVM components. Although hot upgrades do not require the virtual machine to be shut down and restarted, they also need to pause the virtual machine to save and restore the state. Therefore, there will be a short period of virtual machine service unavailability during the hot upgrade. This period of time is called the downtime of the virtual machine hot upgrade. It can be understood that the less downtime the virtual machine hot upgrade has, the smaller the impact on the business performance jitter of the client virtual machine.
[0034] The inventors have discovered that the prior art has at least the following technical problems: when a virtual machine is hot-upgraded using the prior art, the virtual machine experiences a long downtime.
[0035] Therefore, it can be seen that how to reduce the downtime of the virtual machine during the hot upgrade of the virtual machine to improve the performance of the user's virtual machine is a technical problem that needs to be solved urgently.
[0036] In view of the technical problems in the prior art, the inventor's technical conception is as follows: First, a fast simulator QEMU component corresponding to each virtual machine is created on the data processor DPU, wherein the QEMU component includes multiple sub-threads, wherein the sub-threads in the QEMU component correspond one-to-one to the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process the input and output IO requests sent by the VCPU threads corresponding to them. Secondly, in response to the hot upgrade instruction of the target QEMU component corresponding to the target virtual machine, a new QEMU component corresponding to the target virtual machine is created on the DPU; finally, the target QEMU component on the DPU is paused, the state information of each sub-thread in the target QEMU component is saved, and the state information of each sub-thread is synchronized to the new QEMU component; the IO requests sent by the VCPU threads are received and processed through the new QEMU component.
[0037] In this technical solution, when upgrading the QEMU component, it is only necessary to pause the QEMU component running on the DPU card without pausing the VCPU thread on the physical machine. In this way, when upgrading the QEMU component, the VCPU thread of the virtual machine runs normally, achieving zero downtime for hot upgrade of the QEMU component, thereby reducing the downtime during the hot upgrade of the virtual machine.
[0038] The application scenarios of the embodiments of the present disclosure are explained below:
[0039] The hot upgrade method of a virtual machine provided in the embodiment of the present disclosure can be applied in a DPU scenario. Figure 1The figure is a schematic diagram of an application scenario of a hot upgrade method for a virtual machine provided by an embodiment of the present disclosure. As Figure 1 shown, using the DPU (Data Processing Unit) architecture, the QEMU component in the virtualization component is unloaded to the DPU card for operation, while the KVM component still runs on the physical machine. In this way, based on the DPU architecture, the independent hot upgrade capabilities of the QEMU component and the KVM component can be achieved. Among them, the QEMU component includes sub-thread X and sub-thread Y. Thread X corresponds to the VCPU thread X deployed on the physical machine for this virtual machine; thread Y corresponds to the VCPU thread Y deployed on the physical machine for this virtual machine. Among them, the sub-thread X in the QEMU component is used to receive and process the IO requests sent by the corresponding VCPU thread X. The sub-thread Y in the QEMU component is used to receive and process the IO requests sent by the corresponding VCPU thread Y.
[0040] When a hot upgrade is required for the virtual machine, the hot upgrade method for the virtual machine provided by the embodiment of the present disclosure can be used to perform a hot upgrade on the QEMU component and the KVM component.
[0041] The following is the specific implementation process of the hot upgrade method and device for the virtual machine involved in the embodiment of the present disclosure. Some examples are for illustration only and are not limited. The execution subject of the hot upgrade method for the virtual machine involved in the embodiment of the present disclosure is an electronic device, which can be a terminal, a server, etc.
[0042] Figure 2 The flowchart of the hot upgrade method for the virtual machine provided by the embodiment of the present disclosure Figure 1 As Figure 2 shown, the hot upgrade method for the virtual machine may include:
[0043] S201. Create a quick emulator QEMU component corresponding to each virtual machine on the data processor DPU. Among them, the QEMU component includes multiple sub-threads. Among them, the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process the input / output IO requests sent by the corresponding VCPU threads.
[0044] In the embodiment of the present disclosure, since the QEMU component runs on the DPU card and the KVM component is deployed on the physical machine, in the DPU architecture, there will also be a VCPU thread on the physical machine side to execute the KVM code, and the VCPU threads on the physical machine side correspond one-to-one with the sub-threads in the QEMU component.
[0045] It should be noted that when the virtual machine has an I / O request that requires the intervention of the QEMU component for processing, the VCPU thread on the physical machine will send the I / O request to the corresponding sub-thread on the DPU for processing. In some embodiments, there are a large number of I / O requests that require the QEMU component to process during startup; during the normal operation of the virtual machine, there are no I / O requests that exit to the QEMU component.
[0046] Exemplarily, the QEMU component corresponding to the virtual machine includes sub-thread X and sub-thread Y. The VCPU threads on the physical machine side include VCPU thread X and VCPU thread Y. Among them, sub-thread X corresponds one-to-one with VCPU thread X, and sub-thread Y corresponds one-to-one with VCPU thread Y.
[0047] S202. In response to a hot upgrade instruction for the target QEMU component corresponding to the target virtual machine, create a new QEMU component corresponding to the target virtual machine on the DPU.
[0048] In the embodiments of the present disclosure, the multiple sub-threads included in the new QEMU component created on the DPU are the same as the multiple sub-threads included in the target QEMU component.
[0049] Exemplarily, as Figure 3 shown, the target QEMU component corresponding to the target virtual machine includes sub-thread X and sub-thread Y. The new QEMU component includes sub-thread X and sub-thread Y.
[0050] S203. Pause the target QEMU component on the DPU, save the state information of each sub-thread in the target QEMU component, and synchronize the state information of each sub-thread to the new QEMU component.
[0051] In the embodiments of the present disclosure, during the hot upgrade process of the QEMU component, it is first necessary to pause processing the I / O requests from the VCPU threads on the physical machine side. Then, save the device state of the old QEMU component (i.e., the target QEMU component) and send it to the new QEMU component. After loading the device state, the new QEMU component starts to receive the I / O requests submitted by the VCPU threads on the physical machine. Among them, the device state of the old QEMU component includes the state information of each sub-thread.
[0052] In some embodiments, pausing the target QEMU component on the DPU is also to stop processing I / O requests.
[0053] Exemplarily, as Figure 3 shown, the target QEMU component corresponding to the target virtual machine includes sub-thread X and sub-thread Y. Correspondingly, pausing the target QEMU component on the DPU includes: pausing sub-thread X from processing I / O requests, and stopping sub-thread Y from processing I / O requests.
[0054] Optionally, the process of synchronizing the status information of each sub-thread to the new QEMU component is also the process of loading the status information of each sub-thread into the new QEMU component.
[0055] It should be noted that when pausing the target QEMU component on the DPU, it is not necessary to pause the VCPU threads on the physical machine. That is, when upgrading the QEMU component, the VCPU threads of the virtual machine are running normally.
[0056] In some embodiments, the target QEMU component includes multiple target sub-threads; each target sub-thread corresponds to a target VCPU thread on the physical machine; correspondingly, the method further includes: in response to a hot upgrade instruction for the target QEMU component corresponding to the target virtual machine, continuing to run the target VCPU thread on the physical machine.
[0057] S204. Receive and process the IO requests sent by the VCPU threads through the new QEMU component.
[0058] In some embodiments, as Figure 3 shown, this step includes: receiving and processing the IO requests sent by VCPU thread X through sub-thread X in the new QEMU component, and receiving and processing the IO requests sent by VCPU thread Y through sub-thread Y in the new QEMU component.
[0059] In some embodiments, as Figure 3 shown, after receiving and processing the IO requests sent by the VCPU threads through the new QEMU component, the method further includes: shutting down the target QEMU component on the DPU.
[0060] Embodiments of the present disclosure provide a method for hot upgrading a virtual machine: First, create a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processing Unit (DPU). The QEMU component includes multiple sub-threads, where the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input / output (IO) requests sent by the corresponding VCPU threads. Second, in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, create a new QEMU component corresponding to the target virtual machine on the DPU; finally, pause the target QEMU component on the DPU, save the status information of each sub-thread in the target QEMU component, and synchronize the status information of each sub-thread to the new QEMU component; and receive and process IO requests sent by the VCPU threads through the new QEMU component. In this technical solution, when upgrading the QEMU component, only the QEMU component running on the DPU card needs to be paused, without pausing the VCPU threads on the physical machine. In this way, when upgrading the QEMU component, the VCPU threads of the virtual machine are running normally, achieving zero downtime for the hot upgrade of the QEMU component, and thus reducing the downtime during the hot upgrade of the virtual machine.
[0061] In embodiments of the present disclosure, a Kernel-based Virtual Machine (KVM) component corresponding to a virtual machine is deployed on a physical machine, and multiple VCPU threads deployed by the virtual machine on the physical machine process service requests through the KVM component. In this case, by reconstructing the virtualized VCPU architecture, independent hot upgrades of virtualization components (QEMU component, KVM component) are achieved, and on this basis, the impact of hot upgrading the QEMU component on the performance of the virtual machine is eliminated.
[0062] In some embodiments, to optimize the downtime for the hot upgrade of the KVM component, the saving and restoring of the VCPU status can be performed in parallel to reduce the downtime. Correspondingly, as Figure 4 shown, the method further includes:
[0063] S401. In response to a hot upgrade instruction for a target KVM component corresponding to a target virtual machine, create a hot upgrade thread on the DPU, where the target KVM component corresponds to multiple target VCPU threads deployed by the target virtual machine on the physical machine.
[0064] In this step, as Figure 5 shown, the created hot upgrade thread only controls the upgrade process, and the saving and restoring of the virtual machine status are each completed by the old and new VCPU threads. Compared with the traditional hot upgrade scheme (where all processes are serially executed by the upgrade thread), the new hot upgrade scheme significantly optimizes the downtime. Among them, the virtual machine status includes the status information of each VCPU thread.
[0065] S402. Create a new VCPU thread corresponding to each target VCPU thread on the physical machine by invoking the hot upgrade thread.
[0066] In this step, as Figure 5 shown, the new VCPU thread can be initialized by the hot upgrade thread to create a new VCPU thread corresponding to each target VCPU thread. Among them, initializing the new VCPU thread can send a creation instruction of the new VCPU thread to the physical machine, and the physical machine receives this creation instruction and creates a new VCPU thread. It can be understood that the created new VCPU threads correspond one by one to the target VCPU threads.
[0067] Optionally, as Figure 5 shown, for each target VCPU thread, before saving and restoring the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding to it, the method further includes: pausing multiple target VCPU threads deployed by the target virtual machine on the physical machine by invoking the hot upgrade thread. In this way, the state information of the target VCPU thread can be saved through the target VCPU thread.
[0068] S403. For each target VCPU thread, save and restore the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding to it.
[0069] In some embodiments, the state information of the VCPU thread can be saved through the target VCPU thread (old VCPU thread), the state information of the VCPU thread can be loaded through the created new VCPU thread, and the state information of the target VCPU thread can be saved and restored through the upgrade of the old and new VCPU threads. Correspondingly, this step may include: for each target VCPU thread, saving the state information of the target VCPU thread through the target VCPU thread; synchronizing the state information of the target VCPU thread to the new VCPU thread corresponding to it.
[0070] Optionally, as Figure 5 shown, the step of synchronizing the state information of the target VCPU thread to the new VCPU thread corresponding to it may include: if the target VCPU thread finishes saving the state information of the target VCPU thread, feeding back a save completion message to the hot upgrade thread; sending an information loading instruction to the new VCPU thread corresponding to the target VCPU thread through the hot upgrade thread, and loading the state information of the target VCPU thread through the new VCPU thread.
[0071] It should be noted that the hot upgrade thread can send information loading instructions to the new VCPU threads corresponding to multiple target VCPU threads. At this time, the multiple new VCPU threads can load the status information of the target VCPU threads in parallel, that is, the VCPU status is saved and restored in a parallel manner, reducing the downtime.
[0072] Optionally, as Figure 5 shown, for each target VCPU thread, after saving and restoring the status information of the target VCPU thread through the target VCPU thread and its corresponding new VCPU thread, the method further includes: processing the service requests of the target virtual machine through the new VCPU threads corresponding to each target VCPU thread; shutting down the multiple target VCPU threads deployed by the target virtual machine on the physical machine.
[0073] In the embodiments of the present disclosure, the hot upgrade data of the VCPU thread is saved and restored by means of the VCPU thread, improving the concurrency of data saving and restoration, reducing the impact on the performance of the virtual machine when hot upgrading the KVM component of a large-scale virtual machine, and improving the user experience.
[0074] Figure 6 The following is a schematic structural diagram of the hot upgrade device for a virtual machine provided by the embodiments of the present disclosure. As Figure 6 shown, the hot upgrade device for the virtual machine includes:
[0075] A creation unit 601, configured to create a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processor Unit (DPU). Among them, the QEMU component includes multiple sub-threads, and the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process the input / output (IO) requests sent by the VCPU threads corresponding to them;
[0076] A hot upgrade unit 602, configured to create a new QEMU component corresponding to the target virtual machine on the DPU in response to a hot upgrade instruction for the target QEMU component corresponding to the target virtual machine;
[0077] A synchronization unit 603, configured to pause the target QEMU component on the DPU, save the status information of each sub-thread in the target QEMU component, and synchronize the status information of each sub-thread to the new QEMU component;
[0078] A processing unit 604, configured to receive and process the IO requests sent by the VCPU threads through the new QEMU component.
[0079] According to one or more embodiments of the present disclosure, the target QEMU component includes a plurality of target sub-threads; each target sub-thread corresponds to a target VCPU thread on the physical machine; the hot upgrade unit 602 is further configured to continue running the target VCPU thread on the physical machine in response to a hot upgrade instruction for the target QEMU component corresponding to the target virtual machine.
[0080] According to one or more embodiments of the present disclosure, the synchronization unit 603 is further configured to shut down the target QEMU component on the DPU.
[0081] According to one or more embodiments of the present disclosure, a KVM component corresponding to the virtual machine is deployed on the physical machine, and multiple VCPU threads deployed by the virtual machine on the physical machine process service requests through the KVM component; correspondingly, the device further includes: a saving unit, configured to create a hot upgrade thread on the DPU in response to a hot upgrade instruction for the target KVM component corresponding to the target virtual machine, where the target KVM component corresponds to multiple target VCPU threads deployed by the target virtual machine on the physical machine; create a new VCPU thread corresponding to each target VCPU thread on the physical machine by invoking the hot upgrade thread; for each target VCPU thread, save and restore the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto.
[0082] According to one or more embodiments of the present disclosure, for each target VCPU thread, the saving unit saves and restores the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto, including: for each target VCPU thread, saving the state information of the target VCPU thread through the target VCPU thread; synchronizing the state information of the target VCPU thread to the new VCPU thread corresponding thereto.
[0083] According to one or more embodiments of the present disclosure, the saving unit synchronizes the state information of the target VCPU thread to the new VCPU thread corresponding thereto, including: if the target VCPU thread finishes saving the state information of the target VCPU thread, feeding back a saving completion message to the hot upgrade thread; sending an information loading instruction to the new VCPU thread corresponding to the target VCPU thread through the hot upgrade thread, and loading the state information of the target VCPU thread through the new VCPU thread.
[0084] According to one or more embodiments of the present disclosure, the saving unit is further configured to pause multiple target VCPU threads deployed by the target virtual machine on the physical machine by invoking the hot upgrade thread.
[0085] According to one or more embodiments of the present disclosure, the processing unit 604 is further configured to process the service requests of the target virtual machine through the new VCPU threads corresponding to each target VCPU thread; and close the multiple target VCPU threads deployed by the target virtual machine on the physical machine.
[0086] Reference Figure 7 , which shows a schematic structural diagram of an electronic device 700 suitable for implementing the embodiments of the present disclosure. The electronic device 700 may be a terminal device or a server. Among them, the terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not impose any limitations on the functions and usage scopes of the embodiments of the present disclosure.
[0087] As Figure 7 shown, the electronic device 700 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 701, which may perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 702 or the programs loaded from the storage device 708 into the random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. The input / output (I / O) interface 705 is also connected to the bus 704.
[0088] Generally, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or wirelesly to exchange data. Although Figure 7An electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.
[0089] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by a processing device 701, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
[0090] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0091] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; or it can exist separately and not be assembled into the electronic device.
[0092] The above computer-readable medium stores one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0093] Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
[0094] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in an order different from that noted in the drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0095] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. Among them, the name of the unit does not constitute a limitation to the unit itself in some cases. For example, the first acquisition unit may also be described as "the unit for acquiring at least two Internet protocol addresses".
[0096] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), Systems on Chip (SOCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0097] In a first aspect, according to one or more embodiments of the present disclosure, there is provided a method for hot upgrading a virtual machine, including:
[0098] Create Quick Emulator (QEMU) components corresponding to each virtual machine on a Data Processor Unit (DPU), where each QEMU component includes a plurality of sub-threads, and the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input / output (IO) requests sent by the VCPU threads corresponding to them;
[0099] In response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, create a new QEMU component corresponding to the target virtual machine on the DPU;
[0100] Suspend the target QEMU component on the DPU, save the state information of each sub-thread in the target QEMU component, and synchronize the state information of each sub-thread to the new QEMU component;
[0101] Receive and process the IO requests sent by the VCPU threads through the new QEMU component.
[0102] According to one or more embodiments of the present disclosure, the target QEMU component includes a plurality of target sub-threads; each target sub-thread corresponds to a target VCPU thread on the physical machine; the method further includes: in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, continue to run the target VCPU thread on the physical machine.
[0103] According to one or more embodiments of the present disclosure, after receiving and processing the IO requests sent by the VCPU threads through the new QEMU component, the method further includes: shutting down the target QEMU component on the DPU.
[0104] According to one or more embodiments of the present disclosure, a KVM component corresponding to a virtual machine is deployed on the physical machine, and multiple VCPU threads deployed by the virtual machine on the physical machine process service requests through the KVM component; correspondingly, the method further includes: in response to a hot upgrade instruction for a target KVM component corresponding to a target virtual machine, creating a hot upgrade thread on the DPU, where the target KVM component corresponds to multiple target VCPU threads deployed by the target virtual machine on the physical machine; creating a new VCPU thread corresponding to each target VCPU thread on the physical machine by calling the hot upgrade thread; for each target VCPU thread, saving and restoring the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto.
[0105] According to one or more embodiments of the present disclosure, for each target VCPU thread, saving and restoring the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto includes: for each target VCPU thread, saving the state information of the target VCPU thread through the target VCPU thread; synchronizing the state information of the target VCPU thread to the new VCPU thread corresponding thereto.
[0106] According to one or more embodiments of the present disclosure, synchronizing the state information of the target VCPU thread to the new VCPU thread corresponding thereto includes: if the target VCPU thread finishes saving the state information of the target VCPU thread, feeding back a save completion message to the hot upgrade thread; sending an information loading instruction to the new VCPU thread corresponding to the target VCPU thread through the hot upgrade thread, and loading the state information of the target VCPU thread through the new VCPU thread.
[0107] According to one or more embodiments of the present disclosure, before saving and restoring the state information of each target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto, the method further includes: pausing multiple target VCPU threads deployed by the target virtual machine on the physical machine by calling the hot upgrade thread.
[0108] According to one or more embodiments of the present disclosure, after saving and restoring the state information of each target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto, the method further includes: processing the service requests of the target virtual machine through the new VCPU thread corresponding to each target VCPU thread; shutting down multiple target VCPU threads deployed by the target virtual machine on the physical machine.
[0109] Second aspect, according to one or more embodiments of the present disclosure, there is provided a hot upgrade device for a virtual machine, including:
[0110] A creation unit, configured to create a Quick Emulator (QEMU) component corresponding to each virtual machine on a Data Processing Unit (DPU), wherein the QEMU component includes a plurality of sub-threads, wherein the sub-threads in the QEMU component correspond one-to-one with the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input / output (IO) requests sent by the VCPU threads corresponding to them;
[0111] A hot upgrade unit, configured to, in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, create a new QEMU component corresponding to the target virtual machine on the DPU;
[0112] A synchronization unit, configured to pause the target QEMU component on the DPU, save the state information of each sub-thread in the target QEMU component, and synchronize the state information of each sub-thread to the new QEMU component;
[0113] A processing unit, configured to receive and process the IO requests sent by the VCPU threads through the new QEMU component.
[0114] According to one or more embodiments of the present disclosure, the target QEMU component includes a plurality of target sub-threads; the target sub-threads correspond to a target VCPU thread on the physical machine; the hot upgrade unit is further configured to, in response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, continue to run the target VCPU thread on the physical machine.
[0115] According to one or more embodiments of the present disclosure, the synchronization unit is further configured to close the target QEMU component on the DPU.
[0116] According to one or more embodiments of the present disclosure, a Kernel-based Virtual Machine (KVM) component corresponding to the virtual machine is deployed on the physical machine, and a plurality of VCPU threads deployed by the virtual machine on the physical machine process service requests through the KVM component; correspondingly, the device further includes: a saving unit, configured to, in response to a hot upgrade instruction for a target KVM component corresponding to a target virtual machine, create a hot upgrade thread on the DPU, wherein the target KVM component corresponds to a plurality of target VCPU threads deployed by the target virtual machine on the physical machine; create new VCPU threads corresponding to each target VCPU thread on the physical machine by invoking the hot upgrade thread; for each target VCPU thread, save and restore the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding to it.
[0117] According to one or more embodiments of the present disclosure, for each target VCPU thread, the saving unit saves and restores the state information of the target VCPU thread through the target VCPU thread and its corresponding new VCPU thread, including: for each target VCPU thread, saving the state information of the target VCPU thread through the target VCPU thread; and synchronizing the state information of the target VCPU thread to its corresponding new VCPU thread.
[0118] According to one or more embodiments of the present disclosure, the saving unit synchronizes the state information of the target VCPU thread to its corresponding new VCPU thread, including: if the target VCPU thread finishes saving the state information of the target VCPU thread, feeding back a saving completion message to the hot upgrade thread; sending an information loading instruction to the new VCPU thread corresponding to the target VCPU thread through the hot upgrade thread, and loading the state information of the target VCPU thread through the new VCPU thread.
[0119] According to one or more embodiments of the present disclosure, the saving unit is further configured to pause multiple target VCPU threads deployed by the target virtual machine on the physical machine by calling the hot upgrade thread.
[0120] According to one or more embodiments of the present disclosure, the processing unit is further configured to process the service requests of the target virtual machine through the new VCPU threads corresponding to each target VCPU thread; and close multiple target VCPU threads deployed by the target virtual machine on the physical machine.
[0121] In a third aspect, according to one or more embodiments of the present disclosure, an electronic device is provided, including: at least one processor and a memory;
[0122] The memory stores computer execution instructions;
[0123] The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the hot upgrade method of the virtual machine as described in the first aspect above and various possible designs of the first aspect.
[0124] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, in which computer execution instructions are stored, and when a processor executes the computer execution instructions, the hot upgrade method of the virtual machine as described in the first aspect above and various possible designs of the first aspect is implemented.
[0125] Fifth aspect, according to one or more embodiments of the present disclosure, there is provided a computer program product including a computer program which, when executed by a processor, implements the hot upgrade method of the virtual machine as described in the first aspect above and various possible designs of the first aspect.
[0126] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0127] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented combinatorially in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0128] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms for implementing the claims.
Claims
1. A hot upgrade method for a virtual machine, characterized in that: include: Create a fast simulator QEMU component corresponding to each virtual machine on the data processor DPU, wherein the QEMU component includes multiple sub-threads, wherein the sub-threads in the QEMU component correspond one-to-one to the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input and output IO requests sent by the VCPU threads corresponding to them; In response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, creating a new QEMU component corresponding to the target virtual machine on the DPU; Pausing the target QEMU component on the DPU, saving the status information of each sub-thread in the target QEMU component, and synchronizing the status information of each sub-thread to the new QEMU component, wherein when the target QEMU component on the DPU is suspended, the VCPU thread of the target virtual machine is in a normal operating state; The IO request sent by the VCPU thread is received and processed by the new QEMU component.
2. The method according to claim 1, characterized in that: The target QEMU component includes a plurality of target sub-threads; the target sub-thread corresponds to a target VCPU thread on the physical machine; the method further includes: In response to a hot upgrade instruction for a target QEMU component corresponding to a target virtual machine, the target VCPU thread on the physical machine continues to run.
3. The method according to claim 1, characterized in that After receiving and processing the IO request sent by the VCPU thread through the new QEMU component, the method further includes: Shut down the target QEMU component on the DPU.
4. The method according to claim 1, characterized in that: The physical machine is deployed with a kernel virtual machine KVM component corresponding to the virtual machine, and multiple VCPU threads deployed by the virtual machine on the physical machine process service requests through the KVM component; accordingly, the method further includes: In response to a hot upgrade instruction for a target KVM component corresponding to a target virtual machine, creating a hot upgrade thread on the DPU, wherein the target KVM component corresponds to a plurality of target VCPU threads deployed by the target virtual machine on a physical machine; Creating a new VCPU thread corresponding to each target VCPU thread on the physical machine by calling the hot upgrade thread; For each target VCPU thread, the state information of the target VCPU thread is saved and restored through the target VCPU thread and the new VCPU thread corresponding thereto.
5. The method according to claim 4, characterized in that For each target VCPU thread, saving and restoring the state information of the target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto includes: For each target VCPU thread, saving the state information of the target VCPU thread through the target VCPU thread; The state information of the target VCPU thread is synchronized to the new VCPU thread corresponding thereto.
6. The method according to claim 5, characterized in that The step of synchronizing the state information of the target VCPU thread to a new VCPU thread corresponding thereto includes: If the target VCPU thread completes saving the state information of the target VCPU thread, feedback the saving completion information to the hot upgrade thread; An information loading instruction is sent to a new VCPU thread corresponding to the target VCPU thread through the hot upgrade thread, and the state information of the target VCPU thread is loaded through the new VCPU thread.
7. The method according to claim 4, characterized in that Before saving and restoring the state information of each target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto, the method further includes: The multiple target VCPU threads deployed by the target virtual machine on the physical machine are paused by calling the hot upgrade thread.
8. The method according to claim 4, characterized in that After saving and restoring the state information of each target VCPU thread through the target VCPU thread and the new VCPU thread corresponding thereto, the method further comprises: Processing the service request of the target virtual machine through the new VCPU thread corresponding to each target VCPU thread; Shut down multiple target VCPU threads deployed by the target virtual machine on the physical machine.
9. A hot upgrade device for a virtual machine, characterized in that: include: A creation unit, used to create a fast simulator QEMU component corresponding to each virtual machine on a data processor DPU, wherein the QEMU component includes a plurality of sub-threads, wherein the sub-threads in the QEMU component correspond one-to-one to the VCPU threads on the physical machine side, and the sub-threads in the QEMU component are used to receive and process input and output IO requests sent by the VCPU threads corresponding thereto; A hot upgrade unit, configured to create a new QEMU component corresponding to the target virtual machine on the DPU in response to a hot upgrade instruction for the target QEMU component corresponding to the target virtual machine; a synchronization unit, configured to pause the target QEMU component on the DPU, save the status information of each sub-thread in the target QEMU component, and synchronize the status information of each sub-thread to the new QEMU component, wherein when the target QEMU component on the DPU is paused, the VCPU thread of the target virtual machine is in a normal operating state; A processing unit is used to receive and process the IO request sent by the VCPU thread through the new QEMU component.
10. An electronic device, characterized in that: include: Processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the hot upgrade method for a virtual machine according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the hot upgrade method of the virtual machine according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the hot upgrade method of a virtual machine according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
A software watchdog system and method
CN103793288B
Virtual machine hot upgrade method, host device and storage medium
CN113296802A