Hot upgrade method of virtual machine monitor (VMM), computer equipment, computer readable medium and program product

By saving and refreshing the virtual machine's status information and memory management structure, a fast and imperceptible upgrade of the virtual machine monitor (VMM) is achieved, solving the problems of service performance jitter and long interruption time during the upgrade process in existing technologies. It is suitable for cloud computing and critical business scenarios.

CN120780409APending Publication Date: 2025-10-14ZTE CORP
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510887297.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-10-14

AI Technical Summary

Technical Problem

Existing technologies suffer from service performance jitter and long interruption time during the virtual machine monitor (VMM) upgrade process, and are unable to meet the stringent service continuity requirements of cloud computing platforms.

Method used

By pausing the virtual machine, saving the original VMM's state information and memory management structure, reserving the page global directory and virtual machine RAM area, refreshing the process address space for the new VMM to execute the program, and having the new VMM inherit the KVM extended page table, the original VMM is switched to the new VMM.

Benefits of technology

It achieves rapid upgrades of large-scale VMM programs with almost no customer awareness, avoids page fault interruptions, and shortens interruption time. It is suitable for cloud computing platforms and critical business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120780409A_ABST
    Figure CN120780409A_ABST
Patent Text Reader

Abstract

The invention provides a hot upgrade method for a virtual machine monitor (VMM), which comprises the following steps of: pausing the operation of a virtual machine, storing state information of an original VMM, and reserving a kernel-based virtual machine KVM extension page table and a memory management structure of the original VMM; reserving a page global directory and a virtual memory area VMA corresponding to a virtual machine RAM area according to the memory management structure, and refreshing a process address space described by the memory management structure into a new VMM execution program so as to complete switching of the original VMM into the new VMM; and executing the new VMM, recovering the state information to the new VMM, and inheriting the KVM extension page table by the new VMM to recover the operation of the virtual machine. The invention further provides computer equipment, a computer readable medium and a computer program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a hot upgrade method for a virtual machine monitor (VMM), a computer device, a computer-readable medium, and a computer program product. Background Art

[0002] Cloud computing platforms often use VMM (Virtual Machine Monitor) programs, such as QEMU (Machine Virtualizer) and KVM-TOOL (KVM Lightweight Management Tool), to host and run virtual machines (VMs). These VMs run guest operating systems and execute business applications. In the cloud computing field, how to rapidly upgrade VMM programs on a large scale, virtually without customer notice, is a key technical challenge that needs to be addressed.

[0003] The current mainstream technical solution is to hand over the virtual machine client system memory RAM area between two VMMs in a very short time, save the device status simulated by the original VMM and restore it on the new VMM, then shut down the original VMM and switch the virtual machine to the new VMM to run. Among them, the rapid handover of the memory RAM area is the most core technical challenge. An existing solution is to modify the virtual machine memory model and use shared memory or PMEM (Persistent Memory) to retain memory data during the VMM upgrade process. However, after the new VMM is started, this method will generate a large number of page fault interrupts caused by rebuilding the page table, resulting in jitter in the business performance of the virtual machine and long interruption time, which cannot meet the stringent requirements of the cloud computing platform for business continuity. Summary of the Invention

[0004] The present disclosure provides a hot upgrade method for a virtual machine monitor (VMM), a computer device, a computer-readable medium, and a computer program product.

[0005] In a first aspect, an embodiment of the present disclosure provides a hot upgrade method for a virtual machine monitor VMM, comprising: pausing the operation of the virtual machine, saving the state information of the original VMM, retaining the kernel virtual machine KVM extended page table and memory management structure of the original VMM; reserving a virtual memory area VMA corresponding to a global directory of pages and a RAM area of ​​the virtual machine according to the memory management structure, and refreshing the process address space described by the memory management structure to a new VMM execution program to complete the switching of the original VMM to the new VMM; executing the new VMM, restoring the state information to the new VMM, and having the new VMM inherit the KVM extended page table to resume the operation of the virtual machine.

[0006] In a second aspect, an embodiment of the present disclosure provides a computer device comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by one or more processors, the one or more processors implement the hot upgrade method of the virtual machine monitor VMM as in the first aspect.

[0007] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which implements the hot upgrade method of the virtual machine monitor VMM according to the first aspect when the computer program is executed by a processor.

[0008] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the hot upgrade method of the virtual machine monitor VMM of the first aspect.

[0009] The hot upgrade method, computer device, computer-readable medium, and computer program product for a virtual machine monitor (VMM) in the disclosed embodiments retain the page global directory and the VMA corresponding to the virtual machine RAM area in the original VMM memory management structure, thereby maintaining the memory attributes of the original virtual machine. On this basis, only the process address space is refreshed to the new VMM execution program, thereby quickly completing the switch from the original VMM to the new VMM on the same host machine. While retaining the page global directory and the VMA corresponding to the virtual machine RAM area, the new VMM further inherits the KVM extended page table of the original VMM, effectively inheriting the complete page table mapping without changing the virtual machine memory. Consequently, after the new VMM is started, there is no need to rebuild the page table, thus avoiding page fault interrupts and enabling rapid, large-scale VMM program upgrades that are virtually imperceptible to customer services. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 A flowchart of a hot upgrade method of a virtual machine monitor VMM provided in an embodiment of the present disclosure;

[0011] Figure 2 A schematic diagram of a system structure corresponding to a hot upgrade method of a virtual machine monitor VMM provided in an embodiment of the present disclosure;

[0012] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0013] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0014] The present disclosure will be described more fully hereinafter with reference to the accompanying drawings, but the illustrated embodiments may be embodied in different forms, and the present disclosure should not be construed as limited to the embodiments set forth below. Rather, these embodiments are provided so that the present disclosure will be thorough and complete and will fully understand the scope of the present disclosure to those skilled in the art.

[0015] The accompanying drawings of the embodiments of the present disclosure are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the detailed embodiments, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing the detailed embodiments with reference to the accompanying drawings.

[0016] The present disclosure may be described with reference to plan views and / or cross-sectional views by way of ideal schematic views of the present disclosure. Therefore, the exemplary illustrations may be modified according to manufacturing techniques and / or tolerances.

[0017] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0018] The terms used in this disclosure are only used to describe specific embodiments and are not intended to limit the disclosure. As used in this disclosure, the term "and / or" includes any and all combinations of one or more related enumerated items. As used in this disclosure, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. As used in this disclosure, the terms "comprising" and "made of" specify the presence of the features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof.

[0019] Unless otherwise defined, all terms (including technical and scientific terms) used in this disclosure have the same meanings as those commonly understood by those skilled in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined in this disclosure.

[0020] The present disclosure is not limited to the embodiments shown in the drawings, but includes modifications of the configurations formed based on the manufacturing process. Therefore, the regions illustrated in the drawings have schematic properties, and the shapes of the regions shown in the drawings illustrate the specific shapes of the regions of the elements, but are not intended to be limiting.

[0021] In some related technologies, mainstream VMM upgrade technical solutions all have significant limitations.

[0022] (1)Cold upgrade solution: the way of completely terminating and restarting the VMM program, which will cause long-time interruption of the service.

[0023] (2)Hot migration solution: the way of upgrading by migrating the virtual machine from the original VMM to the new VMM, which needs to reserve enough resources before migration, but in most engineering scenarios, the resources have been carefully calculated and allocated for the service in advance, and the virtual machine for server use has hundreds of GB of memory, so it is difficult to reserve enough resources.

[0024] (3)User mode hot patch solution: although the upgrade can be completed without stopping the service process, there are inherent defects: the consistency of patch effectiveness needs to be considered when multiple threads are concurrent; it cannot handle inline function and data structure changes, and is prone to program crashes and other major losses due to upgrade failure.

[0025] (4)Memory persistence solution: modify the virtual machine memory model, and use shared memory or PMEM (Persistent Memory) to retain memory data during VMM upgrade to complete the fast handover of the memory RAM area, however, this solution needs to rebuild the page table after the new VMM restarts, which causes a surge in page fault interrupts, resulting in performance jitter of the service in the virtual machine, long interruption time, and cannot meet the stringent requirements of cloud computing platforms for service continuity.

[0026] The hot upgrade method of the virtual machine monitor VMM of the embodiments of the present disclosure can realize fast upgrade of large-scale VMM programs with almost no awareness of the customer service.

[0027] In a first aspect, the embodiments of the present disclosure provide a hot upgrade method of a virtual machine monitor VMM, applied to a server, the server including a cloud computing cloud platform server, a core network cloud platform server, and other key service scenario servers. The other key service scenarios include financial transaction systems and real-time computing nodes of industrial control cloud platforms.

[0028] With reference to Figure 1 The hot upgrade method of the virtual machine monitor VMM of the embodiments of the present disclosure includes:

[0029] S101, pause the running of the virtual machine, and save the state information of the original VMM and reserve the kernel-based virtual machine KVM extended page table and memory management structure of the original VMM.

[0030] S102, reserve the virtual memory area VMA corresponding to the global directory of the page and the virtual machine RAM area according to the memory management structure, and refresh the process address space described by the memory management structure to the new VMM execution program to complete the switching of the original VMM to the new VMM.

[0031] S103, executing the new VMM, restoring the state information into the new VMM, and inheriting the KVM extended page table by the new VMM to restore the virtual machine to run.

[0032] The suspension of the virtual machine running can be understood as that all virtual CPU threads exit the virtual machine running state. The state information includes device state and host virtual address (HVA) corresponding to the virtual machine RAM region. The KVM extended page table includes an extended page table (EPT) / Stage-2 page table. In Intel virtualization technology, the EPT refers to a two-level page table for converting a virtual machine physical address (GPA) into a host physical address (HPA), which is managed by a KVM module and directly participates in address conversion by hardware to accelerate memory access of the virtual machine. The Stage-2 page table refers to an equivalent implementation in ARM (Advanced RISC Machines) virtualization, which has the same function as the EPT. The memory management structure, i.e., the memory management mm structure (struct mm_struct), refers to a core data structure in the kernel for each process to describe its own memory layout, which manages the address space of the process. Key fields of the memory management structure include: pgd, which points to the page global directory (PGD) of the process; mmap, which is a VMA linked list or red-black tree; start and end addresses of memory space layouts such as code segment, data segment, and stack segment. According to the memory management structure, the page global directory and the virtual memory region VMA corresponding to the virtual machine RAM region can be understood as reserving or inheriting the page global directory and the VMA corresponding to the virtual machine RAM region of the original VMM in advance, and then refreshing the process address space described by the memory management structure to the new VMM execution program, so that the original VMM is switched to the new VMM on the same host.

[0033] The embodiments of the present disclosure reserve the page global directory and the VMA corresponding to the virtual machine RAM area in the original VMM memory management structure, so that the memory attributes of the original virtual machine are not changed, and on this basis, only the process address space is refreshed as a new VMM execution program, so that the original VMM is quickly switched to the new VMM on the same host, that is, the VMM upgrade is completed. On the basis of reserving the page global directory and the VMA corresponding to the virtual machine RAM area, the KVM extended page table of the original VMM is further inherited by the new VMM, which is equivalent to not changing the virtual machine memory while also inheriting the complete page table mapping, so that after the new VMM starts, the page table does not need to be rebuilt, the page fault interrupt can be avoided, the performance of the virtual machine is not disturbed, and the virtual machine internal service is almost not perceived. In addition, since the embodiments of the present disclosure use the memory management structure (that is, management information) inheritance method during the upgrade process, the page table does not need to be copied or remapped, and for a virtual machine with hundreds of GB of memory, the service interruption time will not be increased, that is, the long interruption time caused by copying the page table can be avoided. And since the upgrade process occurs on the same host, that is, in-place upgrade, resources do not need to be reserved in advance, and the upgrade speed is extremely fast (seconds can complete), therefore, the hot upgrade method of the embodiments of the present disclosure can realize almost no perception of customer service Large-scale VMM program fast upgrade.

[0034] In some embodiments, saving the state information of the original VMM includes: saving device state (such as registers, configurations); saving the virtual machine RAM area corresponding to the host virtual address; clearing the FD_CLOEXEC flag of the external file handle and saving; saving the command line parameter passing. The embodiments of the present disclosure make light state information saving, which can avoid the overhead of full snapshot and improve upgrade efficiency.

[0035] In some embodiments, reserving the kernel virtual machine (KVM) extended page table based on the original VMM includes: detecting that a first identifier is carried in a message in which the KVM module exits the virtual machine running; and instructing the KVM module to skip the KVM extended page table release process of the original VMM according to the first identifier.

[0036] The first identifier is used to instruct the KVM module to skip the KVM extended page table release procedure of the original VMM. The first identifier includes arch.ept_preserve=true or a Hypercall custom parameter (such as KVM_HC_PRESERVE_EPT). The arch.ept_preserve=true needs to be sent to the KVM module in advance before the hot upgrade is performed. The Hypercall custom parameter can be used to let the Guest OS (guest operating system) actively inform the VMM whether the KVM extended page table needs to be preserved. In the related art, the KVM extended page table of the original VMM is released when the hot upgrade is performed, and the KVM extended page table needs to be rebuilt after the new VMM is started. In the embodiment of the present disclosure, the release procedure of the KVM extended page table is skipped by modifying the KVM module logic, so that the new VMM can directly inherit the KVM extended page table, and the overhead of rebuilding the page table is avoided.

[0037] In some embodiments, the method further includes: detecting that the second identifier is carried in a message before the execution module empties the process address space; and instructing the execution module to skip the memory management structure release procedure of the original VMM according to the second identifier.

[0038] The second identifier is used to instruct the execution module to skip the memory management structure release procedure of the original VMM. The execution module refers to the exec function family. The second identifier includes EXEC_KEEP_MM or a cgroup attribute (such as KEEP_MM). In the related art, the exec empties the process address space of the original VMM and loads the new VMM execution program. In order to realize the fast recovery of the virtual machine state, the memory management structure of the original VMM is preserved by extending the logic of the exec in the embodiment of the present disclosure.

[0039] In some embodiments, the method further includes: detecting whether all virtual CPU threads and input / output threads are ended; and saving the state information of the original VMM in response to all virtual CPU threads and input / output threads being ended.

[0040] As a way of the embodiment of the present disclosure, the state information of the original VMM is saved after all virtual CPU threads and input / output threads are ended, which can ensure that the saved state information is complete, avoid data tearing or inconsistent intermediate state caused by thread concurrency, and reduce resource conflicts during recovery.

[0041] In some embodiments, the memory management structure includes a page global directory and a VMA linked list.

[0042] The method comprises the following steps: reserving a page global directory in the memory management structure and a virtual memory area VMA corresponding to the RAM area of ​​the virtual machine; traversing a VMA linked list in the memory management structure, reserving the VMA corresponding to the RAM area of ​​the virtual machine, and pruning the VMA corresponding to the non-RAM area of ​​the virtual machine.

[0043] Among them, the page global directory is the top-level structure of the multi-level page table. The memory management structure of each process contains a pgd pointer, which locates the next level page table (such as PUD or PMD) by indexing the PGD table entry with the high bit of the virtual address. Traverse the VMA linked list in the memory management structure, identify the VMA corresponding to the virtual machine RAM area and reserve it, which will be directly inherited and used by the new VMM later. Pruning the VMA corresponding to the non-RAM area of ​​the virtual machine includes: releasing the physical memory of the VMA corresponding to the non-RAM area of ​​the virtual machine (such as the code segment and stack segment), and updating the VMA linked list in the memory management structure.

[0044] The disclosed embodiment enables the new VMM to directly inherit and use the reserved page global directory and the VM's RAM area, which is equivalent to keeping the memory page and the VM's RAM area mapping unchanged, thus avoiding the overhead of memory reallocation and mapping after the upgrade. Compared with the related art, the disclosed embodiment not only retains the memory page and does not release it, but also retains and reuses the existing memory management structure and page table, where the page table refers to the host memory page table (based on the page global directory for step-by-step search when accessing the memory) and the KVM extended page table, avoiding any page table polling, copying or remapping. Therefore, it can significantly shorten the interruption time of the virtual machine upgrade, which is especially important for large memory virtual machines with hundreds of GB. The purpose of pruning the VM corresponding to the non-RAM area is to make room for the loading of the new VMM and to avoid memory leaks introduced by the upgrade process.

[0045] In some embodiments, the process address space includes a code segment, a data segment, a BSS segment, a stack segment, and an MMAP area.

[0046] Refreshing the process address space described by the memory management structure to a new VMM execution program includes: refreshing the code segment, data segment, and BSS segment described by the memory management structure to the new VMM execution program; recalculating the starting address of the stack segment and the starting address of the MMAP area to accommodate the VMA corresponding to the virtual machine RAM area, and refreshing the recalculated results to the new VMM execution program.

[0047] The memory management structure is used to describe and manage the process address space. Refreshing the code, data, and BSS segments described by the memory management structure to the new VMM execution program is equivalent to replacing the code, data, and BSS segments of the original VMM, achieving seamless switching between the old and new VMM execution programs.

[0048] As one approach in the disclosed embodiments, recalculating the stack segment's starting address and the MMAP area's starting address ensures that the refreshed new VMM's stack segment and MMAP area do not conflict with the VMA corresponding to the reserved virtual machine RAM area. This also prevents address space fragmentation, thereby ensuring memory mapping continuity. Specifically, the stack segment's starting address and the MMAP area's starting address, recalculated using random numbers, are constrained so that they can accommodate the VMA corresponding to the virtual machine RAM area.

[0049] In some embodiments, refreshing the code segment, data segment, and BSS segment described by the memory management structure to a new VMM execution program includes mapping the new VMM execution program to the address range of the code segment, data segment, and BSS segment described by the memory management structure.

[0050] The MAP_FIXED flag can be used to overwrite the code, data, and BSS segments of the original VMM to ensure that the new VMM's executable program can be loaded correctly. At the same time, the memory management structure is updated to reflect the memory layout of the new VMM.

[0051] In some embodiments, after completing the switch from the original VMM to the new VMM and before executing the new VMM, the hot upgrade method of the virtual machine monitor VMM further includes: setting the instruction pointer of the current process to the entry address of the new VMM and jumping to execution.

[0052] As one method of an embodiment of the present disclosure, the instruction pointer of the current process is set to the entry address of the new VMM, and the purpose of jumping execution is to bypass process rescheduling, which can significantly reduce the virtual machine interruption time during the upgrade process and further achieve fast switching.

[0053] In some embodiments, restoring the state information to the new VMM includes: the new VMM reading the device state and restoring the device register; and the new VMM using the host machine virtual address corresponding to the virtual machine RAM area as the starting address of the virtual machine RAM area.

[0054] Restoring the state information to the new VMM further includes: reopening external file handles (such as disk images, network interfaces); and reading and passing command line parameters.

[0055] In some related technologies, memory persistence solutions also have other difficult-to-solve technical problems: because the memory model of the virtual machine is changed to shared memory. For old versions of VMM virtual machines currently running on the network, it is impossible to change the memory model through hot upgrades. The only way is to first perform a cold shutdown and upgrade the VMM to a baseline version that supports hot upgrades. After that, it is restarted using shared memory (changing the memory model). Only then can subsequent versions of the VMM be hot upgraded without shutting down. It should be noted that the old versions of VMM virtual machines currently running on the network have diverse VMM program versions. Some versions are very old, and some are even VMM programs from other manufacturers. Since the virtual machine business continues to run and cannot be shut down, the old VMM program generally does not have the function of in-place hot upgrade.

[0056] The disclosed embodiment enables the VMM program of the old version virtual machine currently running in the network to obtain the ability of in-situ hot upgrade through code hot patching, and can be upgraded to the subsequent VMM version without any business impact.

[0057] In some embodiments, retaining the original VMM's memory management structure includes:

[0058] S201, by scanning the process status file system (such as / proc / <pid> / smaps) or based on the VMM monitoring protocol, identify the memory management structure of the original VMM and locate the host machine virtual address range corresponding to the virtual machine RAM area.

[0059] S202 , skipping the saving process and the releasing process of the virtual machine RAM corresponding to the host machine virtual address range.

[0060] S203: Detecting that the message before the execution module clears the process address space carries a second identifier; instructing the execution module to skip the original VMM memory management structure release process according to the second identifier.

[0061] An example of a VMM monitoring protocol is QMP (QEMU Machine Protocol). In S202, the process of saving and releasing the virtual machine RAM corresponding to the host machine's virtual address range can be skipped based on user-mode hot patching technologies such as upatch. The second flag is used to instruct the execution module to skip the original VMM's memory management structure release process.

[0062] In some embodiments, the KVM extended page table is retained based on kernel hot patching technology. Specifically, based on kernel hot patching technology such as kpatch, the KVM module is instructed to skip the KVM extended page table release process of the original VMM, and the entry point of the release process is saved separately, and a system call interface is provided for inheriting the KVM extended page table from the saved entry point and restoring the use. If the release process needs to be skipped, a first identifier can be carried in the message of exiting the virtual machine operation, and the first identifier is used to instruct the KVM module to skip the KVM extended page table release process of the original VMM.

[0063] Since the embodiment of the present disclosure does not change the memory model, the old VMM in the current network can be directly hot-upgraded to the latest version without first cold-upgrading the old VMM to the baseline version.

[0064] In some embodiments, the memory management structure includes a page global directory. Retaining the memory management structure of the original VMM includes: retaining the value of the page global directory of the original VMM; creating a new memory management structure in the execution module and copying the retained page global directory value.

[0065] During the refresh process from the original VMM to the new VMM, the disclosed embodiment retains the global page table directory value unchanged, creates a new memory management structure in the execution module, and then copies the global page directory value. Subsequently, the VMA pointer corresponding to the virtual machine RAM is attached to the VMA list of the newly created memory management structure, thus completing the reservation and reuse of page table mappings.

[0066] Example 1:

[0067] By way of example, a hot upgrade method for a virtual machine monitor (VMM) in an existing network old VMM upgrade scenario is provided, comprising:

[0068] S301, based on kernel hot patching technologies such as kpatch, instructs the KVM module to skip the original VMM's KVM extended page table release process when the virtual CPU exits the virtual machine, saves the release process's entry point, and provides a system call interface that inherits the KVM extended page table from the saved entry point. Specifically, a first identifier can be included in the virtual machine exit message, which is used to instruct the KVM module to skip the original VMM's KVM extended page table release process.

[0069] S302: Modify the execution module based on kernel hot patching technology such as kpatch (e.g., modify the exec system call to obtain a modified exec system call) so that the execution module can execute S102. Alternatively, extract the process of S102 and integrate it into a new system call, which is provided to the user mode through a hot-inserted kernel module.

[0070] S303, by scanning the process status file system (such as / proc / <pid> / smaps) or based on the VMM monitoring protocol, identify the memory management structure of the original VMM and locate the host machine virtual address range corresponding to the virtual machine RAM area.

[0071] S304: Using user-mode hot patching technologies such as upatch, the process of saving and releasing the virtual machine RAM corresponding to the host machine's virtual address range is skipped. In other words, the process of saving and releasing the virtual machine RAM corresponding to the host machine's virtual address range is skipped by using user-mode hot patching technologies. Finally, before the end of the process, a modified execution module (such as a modified exec system call) or a new system call provided by the hot-plug kernel is called to start the new VMM program.

[0072] S305: After S102 is completed, S103 is continued to complete the in-place hot upgrade of the VMM program. Subsequent versions of the in-place hot upgrade already have the in-place hot upgrade capability and do not need code hot patching again.

[0073] Example 2:

[0074] For example, as a specific form of an embodiment of the present disclosure, a hot upgrade method for a virtual machine monitor VMM is provided, which is applied to a virtualization scenario. The virtual machine runs on the VMM program, and the VMM program is monitored by the libvirtd (Libvirt daemon) program. Libvirtd forwards user instructions (such as virtual machine creation, reconstruction, and other operations), including in-place upgrade commands, to the VMM through the file descriptor (FD) of the Unix domain socket. During the hot upgrade of the VMM, the embodiment of the present disclosure takes a very short interruption time to replace the code segment, data segment, and BSS segment data of the new VMM to upgrade it to the new version. The intermediate process reuses FDs and inherits the process design of the virtual machine RAM memory page and page table, which will not cause session renegotiation or handle reopening, will not cause a large number of page fault interrupts, and minimize the impact of the upgrade. Since the process identification ID will not change, users and libvirtd are almost unaware of the VMM upgrade process.

[0075] A method for hot upgrading a virtual machine monitor (VMM) is described using a QEMU virtual machine as a specific embodiment of the VMM. The method includes:

[0076] S401, suspend the virtual machine operation and retain the KVM extended page table of the original VMM (QEMU).

[0077] In the original QEMU, the device state is saved through the QEMU_savevm_state function. At this time, the virtual CPU thread of the original QEMU will exit the virtual machine running mode through KVM_RUN (when all virtual CPU threads exit the virtual machine running mode, it means pausing the virtual machine running). The KVM module will capture the exit event and enter the processing flow. In the related art, the KVM module will release the KVM extended page table (EPT (x86) / Stage-2 page table (ARM)) to recycle resources, but in order to achieve the reuse of the KVM extended page table after the local hot upgrade, the embodiment of the present disclosure, such as Figure 2 As shown, the KVM module logic is modified, a first identifier is preset in the message of the KVM module exiting the virtual machine operation, and the KVM module is instructed to skip the KVM extended page table release process according to the first identifier, that is, the EPT / Stage-2 page table is retained. Specifically, a conditional judgment can be added to the message of exiting the virtual machine operation of kvm_vcpu_ioctl(KVM_RUN). If it is detected that the message of the KVM module exiting the virtual machine operation carries the first identifier (such as vcpu->arch.ept_preserve=true, which is issued in advance before the original QEMU performs the hot upgrade), the KVM extended page table is retained to avoid the overhead of rebuilding the page table due to a page fault after the subsequent upgrade, and the retained KVM extended page table is inherited when the virtual machine operation is restored. If it is detected that the message of the KVM module exiting the virtual machine operation does not carry the first identifier, the KVM extended page table of the original QEMU is released.

[0078] S402: Save the state information of the original VMM, where the state information includes the device state and the host virtual address HVA corresponding to the virtual machine RAM area.

[0079] In the VMM main thread, you need to ensure that the file handle used by the virtual machine is not closed in subsequent exec calls, such as Figure 2 As shown, calling fcntl(fd,F_SETFD,0) clears the FD_CLOEXEC flag of the external file handle and saves it to ensure that the file handle remains valid after the process is replaced. Use the original QEMU vmstate framework to serialize the device state (such as registers, configuration) into a temporary buffer (such as a ramfs memory file), that is, save the device state. Save the host virtual address HVA corresponding to the virtual machine RAM area. It should be noted that step 402 performs lightweight state information preservation to avoid the overhead of a full snapshot.

[0080] S403: retain the original VMM memory management structure.

[0081] Since the core of the disclosed embodiment is to replace the code segment, data segment and BSS segment of the thread group, it is necessary to ensure that all threads are executed to completion before replacement. That is, the virtual CPU and non-critical threads (such as input / output threads) are all finished, and only the original QEMU main thread is left to execute to the end, at which time the modified execution module (such as the exec system call (such as Figure 2 The new exec*syscal l)) shown in the figure enters the kernel state. In the related art, the execution module will clear the process address space and load a new program, but in order to achieve rapid recovery of the virtual machine state, the logic of the execution module needs to be expanded. In the kernel's fs / exec.c, a new branch judgment is added. If it is detected that the message before the execution module clears the process address space carries a second identifier (such as EXEC_KEEP_MM), the execution module is instructed to skip the original QEMU memory management structure release process according to the second identifier, that is, skip mm_release() and exit_mm() to retain the memory management structure of the original QEMU process.

[0082] S404, reserve a page global directory in the memory management structure.

[0083] Because the memory management structure includes the page global directory, the modified execution module (exec) skips mm_release() and exit_mm() to preserve the original QEMU process group's memory management structure, mm_struct, and the page global directory. The page global directory in the memory management structure is then reserved. The mm_struct is a core data structure in the Linux kernel that manages the process address space, while pgd points to the root node of the host memory page table. Preserving these structures means that the virtual machine's RAM region mapping (i.e., HVA to host physical address HPA) remains unchanged, avoiding the overhead of memory reallocation and mapping after the upgrade. The key to this mechanism is that it not only preserves memory pages but also retains and reuses existing memory management structures and host memory page tables, avoiding any page table polling, copying, or remapping. This significantly reduces the downtime during VM upgrades, which is particularly important for VMs with hundreds of GB of memory.

[0084] S405: Reserve a virtual memory area VMA corresponding to the RAM area of ​​the virtual machine according to the memory management structure, and pruned the VMA corresponding to the non-RAM area of ​​the virtual machine.

[0085] While retaining the mm_struct, the original QEMU process's virtual memory area VMA linked list is traversed to identify the VMAs corresponding to the virtual machine's RAM area. The QEMU main thread can pre-define the start and end addresses of these VMAs. For VMAs in non-RAM areas (such as code segments and stack segments), madvise(MADV_DONTNEED) is called to release their physical memory and update the VMA linked list in mm_struct. This step frees up space for the new QEMU to load while avoiding memory leaks introduced during the upgrade process.

[0086] S406: Refresh the code segment, data segment, and BSS segment described by the memory management structure into a new VMM execution program.

[0087] After pruning the VMA in the non-RAM area, the binary file of new QEMU (i.e., the executable program) is mapped to the address range of the code segment, data segment, and BSS segment described by the memory management structure through the mmap system call. Specifically, the address range of the original code segment, data segment, and BSS segment is covered by the MAP_FIXED flag to ensure that the code segment, data segment, and BSS segment of the new QEMU can be correctly loaded. At the same time, the fields such as start_code and end_code in the mm_struct are updated to reflect the new memory layout. The key to step 406 is to directly replace the code segment, data segment, and BSS segment of the original QEMU process to achieve seamless switching between the old and new codes of QEMU.

[0088] S407: recalculate the starting address of the stack segment and the starting address of the MMAP area to accommodate the VMA corresponding to the virtual machine RAM area, and refresh the recalculated results to the new VMM execution program.

[0089] After the new QEMU is loaded into the code, data, and BSS segments, the starting address of the QEMU process's stack segment and MMAP area are recalculated to ensure that they do not conflict with the reserved virtual machine RAM area. That is, the kernel's random number-based calculations of the stack segment and MMAP area start addresses are restricted to ensure that the new QEMU's stack and MMAP areas can accommodate the virtual machine's RAM mapping while avoiding address space conflicts.

[0090] S408, setting the instruction pointer of the current process to the entry address of the new VMM, and jumping to execution.

[0091] Before the exec system call returns, kernel code is modified to bypass the process rescheduling logic, effectively skipping the process rescheduling process. In related technologies, the return of exec triggers the scheduler to reselect the running process, using the sched_exec() function. However, to achieve a faster switch, the current process's instruction pointer (current->thread.ip) can be directly set to the entry point of the new QEMU process and then redirected. By bypassing the process rescheduling mechanism, service interruption time during a virtual machine hot upgrade can be significantly reduced and stabilized.

[0092] S409: The IP register of the current CPU jumps to the entry address of the new VMM program for execution.

[0093] The kernel continues executing the remaining exec steps, mmap ing the new QEMU executable and its dynamically dependent libraries into the current process's free space. It then sets the current CPU's instruction pointer (IP register) to the new QEMU program's entry point, jumping directly to the new QEMU program's entry point and starting execution. The kernel also stores the necessary startup parameters in the startup parameters (args area), letting the new QEMU program know that this is a hot upgrade process.

[0094] S410, after the VMM main thread returns to the user state, it reads the device state, reopens the external file handle, and reads and uses the HVA address corresponding to the RAM area.

[0095] Specifically, after the new QEMU main thread returns to user mode from kernel mode, it reads the device state from a temporary buffer (e.g., a ramfs file) and restores the device registers via the vmstate framework. Since the FD is inherited during exec, external file handles (e.g., disk images, network interfaces) can be reopened to ensure the normal operation of the device. The HVA address corresponding to the previously saved RAM area is used as the starting HVA address of the virtual machine's RAM area. Since the memory pages and page tables in this area are retained, there is no need to re-allocate memory or establish page table mappings.

[0096] S411, derive a virtual CPU thread from the VMM main thread, and inherit and use the KVM extended page table (EPT / Stage-2 page table) stored in each CPU.

[0097] After restoring the device state and memory mapping, the new QEMU main thread derives a new virtual CPU thread through pthread_create(), and by calling kvm_vm_ioctl(KVM_CREATE_VCPU), the kernel initializes the virtual CPU structure of the KVM module and inherits the previously reserved KVM extended page table (EPT(x86) / Stage-2 page table(ARM)). The reserved kvm_mmu page table root node is passed to the new virtual CPU to avoid the overhead of rebuilding the page table.

[0098] S412, call kvm_vcpu_ioctl(KVM_RUN) to resume the operation of the virtual CPU thread. Since the KVM extended page table, page global directory, and VMA corresponding to the virtual machine RAM area are all retained, the virtual CPU can immediately continue to execute instructions of the virtual machine internal process without waiting for the page table to be rebuilt due to the page fault interrupt.

[0099] The hot upgrade method for a virtual machine monitor (VMM) in the disclosed embodiment directly inherits the original VMM's memory management structure (mm_struct) and its most critical page global directory, refreshing the code segment, data segment, and BSS segment of the process address space to the new VMM execution program. The VMA corresponding to the virtual machine memory area is retained in the MMAP area and not revoked, and is directly inherited by the new VMM. Aside from the code segment, data segment, and BSS segment updates, the new VMM and the original VMM are essentially the same process. After the new VMM is started, when recreating the virtual CPU process, it continues to inherit the original pre-saved EPT page table (x86 architecture) or Stage-2 page table (ARM architecture). Because the disclosed embodiment does not use shared memory and does not affect the configuration and memory model of the original virtual machine, it has a smaller attack surface and higher security. After the virtual machine resumes operation, it fully inherits the original VMM's page global directory and the VMA corresponding to the virtual machine RAM area (inheriting both is equivalent to inheriting the original VMM's host memory page table and memory) and KVM extended page table, thereby preventing page faults from occurring during virtual machine operation and undisturbed virtual machine performance. Because the upgrade process avoids page table copies, service interruption for VMs with large memory specifications remains minimal, making it virtually unnoticeable to VM services. Furthermore, this in-place upgrade eliminates the need for pre-reserved resources and offers exceptionally fast upgrade speeds, enabling large-scale batch upgrades of VMs to the new VMM, saving time and effort.

[0100] Reference Figure 3 In the second aspect, an embodiment of the present disclosure provides a computer device, comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by one or more processors, the one or more processors implement the hot upgrade method of the virtual machine monitor VMM of the embodiment of the present disclosure.

[0101] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon. When the computer program is executed by a processor, the hot upgrade method of the virtual machine monitor VMM of the embodiment of the present disclosure is implemented.

[0102] In a fourth aspect, an embodiment of the present disclosure provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the hot upgrade method of the virtual machine monitor VMM of the embodiment of the present disclosure is implemented.

[0103] Among them, the processor is a device with data processing capabilities, including but not limited to the central processing unit (CPU); the memory is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically such as SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface (read-write interface) is connected between the processor and the memory, which can realize information exchange between the memory and the processor, including but not limited to the data bus (Bus), etc.

[0104] Those skilled in the art will appreciate that all or some of the steps, systems, and functional modules / units in the apparatus disclosed above may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0105] In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation.

[0106] Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit (CPU), a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH) or other disk storage; compact disc (CD-ROM), digital versatile disc (DVD) or other optical disc storage; magnetic cassettes, tapes, disk storage or other magnetic storage; any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0107] The present disclosure has disclosed example embodiments, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly indicated, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, it will be understood by those skilled in the art that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.< / pid> < / pid>

Claims

1. A method for hot upgrading a virtual machine monitor (VMM), comprising: Pause the virtual machine, save the original VMM state information, and retain the original VMM's kernel virtual machine (KVM) extended page table and memory management structure. Reserving a virtual memory area VMA corresponding to a global directory of pages and a RAM area of ​​a virtual machine according to the memory management structure, and refreshing the process address space described by the memory management structure to execute a program of the new VMM to complete the switching of the original VMM to the new VMM; The new VMM is executed, the state information is restored to the new VMM, and the new VMM inherits the KVM extended page table to resume the operation of the virtual machine.

2. The method according to claim 1, wherein The method of retaining the original VMM-based kernel virtual machine KVM extended page table includes: The message detecting that the KVM module has exited the virtual machine operation carries a first identifier; The KVM module is instructed to skip a KVM extended page table release process of the original VMM according to the first identifier.

3. The method according to claim 1, wherein The memory management structures of the original VMM are retained, including: Detecting that the message before the execution module clears the process address space carries the second identifier; The execution module is instructed to skip the memory management structure release process of the original VMM according to the second identifier.

4. The method according to claim 1, wherein Saving the state information of the original VMM includes: Check whether all virtual CPU threads and input / output threads have ended; In response to all virtual CPU threads and input / output threads being terminated, the state information of the original VMM is saved.

5. The method according to claim 1, wherein The memory management structure includes a page global directory and a VMA linked list. The virtual memory area VMA corresponding to the global directory of reserved pages and the virtual machine RAM area according to the memory management structure includes: Reserving a page global directory in the memory management structure; Traverse the VMA linked list in the memory management structure, reserve the VMA corresponding to the virtual machine RAM area, and pruned the VMA corresponding to the virtual machine non-RAM area.

6. The method according to claim 1, wherein The process address space includes code segment, data segment, BSS segment, stack segment, and MMAP area. Refreshing the process address space described by the memory management structure to a new VMM execution program includes: Refresh the code segment, data segment, and BSS segment described by the memory management structure into a new VMM execution program; The starting address of the stack segment and the starting address of the MMAP area are recalculated to accommodate the VMA corresponding to the virtual machine RAM area, and the recalculated results are refreshed to the new VMM execution program.

7. The method according to claim 6, wherein: Refreshing the code segment, data segment, and BSS segment described by the memory management structure into a new VMM execution program includes: The new VMM execution program is mapped to the address range of the code segment, the data segment and the BSS segment described by the memory management structure.

8. The method according to claim 1, wherein After the original VMM is switched to the new VMM, and before the new VMM is executed, the following steps are further included: Set the instruction pointer of the current process to the entry address of the new VMM and jump to execution.

9. The method according to claim 1, wherein The status information includes the device status and the host machine virtual address corresponding to the virtual machine RAM area. Restoring the state information to the new VMM includes: The new VMM reads the device status and restores the device registers; The new VMM uses the host machine virtual address corresponding to the virtual machine RAM area as the starting address of the virtual machine RAM area.

10. The method according to claim 1, wherein The memory management structure of retaining the original VMM includes: By scanning the process status file system or based on the VMM monitoring protocol, the original VMM's memory management structure is identified, and the host machine virtual address range corresponding to the virtual machine RAM area is located; Skipping the saving process and releasing process of the virtual machine RAM corresponding to the host machine virtual address range; Detecting that the message before the execution module clears the process address space carries the second identifier; The execution module is instructed to skip the memory management structure release process of the original VMM according to the second identifier.

11. The method according to claim 1, wherein The memory management structure includes a page global directory, The memory management structures of the original VMM are retained, including: Keep the value of the original VMM's page global directory; Create a new memory management structure in the execution module and copy the value of the reserved page global directory.

12. A computer device comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the hot upgrade method of the virtual machine monitor VMM according to any one of claims 1 to 11.

13. A computer-readable medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for hot upgrading a virtual machine monitor (VMM) according to any one of claims 1 to 11 is implemented.

14. A computer program product comprising a computer program, wherein when the computer program is executed by a processor, the method for hot upgrading a virtual machine monitor (VMM) according to any one of claims 1 to 11 is implemented.

Citation Information

Cited By

  • Updating method and device of dynamic link library, equipment and medium

    CN121233197A

  • A dynamic link library updating method, device, equipment and medium

    CN121233197B

  • Memory management method and device

    CN121364950A