Virtual machine QEMU program hot upgrade method, system and equipment
Through the shared memory mechanism and Unix Domain Socket channel, the hot upgrade of the virtual machine QEMU program is achieved, solving the problems of low resource occupation and success rate in the existing technology, improving migration speed and upgrade efficiency, and ensuring business continuity.
Patent Information
- Application Number
- CN202411900185.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-03-28
AI Technical Summary
The existing virtual machine QEMU program hot upgrade method occupies a large number of network and host resources, and the success rate depends on network bandwidth and virtual machine memory migration speed, and affects business operations.
By building a shared memory mechanism, new and old QEMU processes share physical memory, realizing hot upgrades of QEMU programs, avoiding virtual machine memory migration, and using Unix Domain Socket channel to transfer file descriptors.
It improves migration speed and QEMU upgrade efficiency, saves system and network resources, significantly improves the upgrade success rate, reduces the impact of thermal upgrades on business, and ensures business continuity and service stability.
Smart Images

Figure CN119718547A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual machine technology, and in particular to a method, system and device for hot upgrading a virtual machine QEMU program. Background Art
[0002] QEMU+KVM is an open source virtualization solution widely used in the field of cloud computing. KVM (Kernel-based Virtual Machine) is a virtualization function module embedded in the Linux kernel. It uses some operating system capabilities provided by the Linux kernel, such as task scheduling, memory management, and hardware device interaction, and then adds virtualization capabilities to it, making the Linux kernel have the conditions to become a hypervisor (virtualization management software). KVM supports x86, x86_64, ARM and other architectures, and requires the CPU to provide hardware-assisted virtualization features (such as Intel VT-x or AMD-V), and is mainly responsible for the virtualization functions of the CPU and memory. The main work of QEMU (Quick EMUlator) is to simulate hardware devices. QEMU+KVM provides a complete hardware environment for the operation of virtual machines. QEMU components exist in the form of processes, and one virtual machine corresponds to one QEMU process.
[0003] In actual applications, it is often necessary to upgrade QEMU components due to bug fixes or new features. Customer services run inside virtual machines. In most scenarios, it is not allowed to shut down all virtual machines on the physical host to upgrade QEMU components. Shutting down virtual machines will have a fatal impact on user services. Therefore, it is necessary to perform a hot upgrade of the virtual machine QEMU program.
[0004] The existing method for hot upgrading the QEMU program of the virtual machine is to hot migrate all virtual machines to another server, upgrade the QEMU components after vacating the server, and then migrate the virtual machines back. Figure 1 This is an example diagram of the process of virtual machine migration in the prior art, such as Figure 1As shown in the figure, the process of virtual machine migration is divided into two stages. The first stage is the migration of virtual machine memory. In this stage, all the memory of the virtual machine will be iteratively migrated to the destination. After the migration, the memory will continue to migrate if it becomes dirty. It will continue to iterate until the remaining dirty page memory meets the migration completion time within the downtime, and then proceed to the second stage. The second stage is to migrate the remaining memory and device status information to the destination. From the migration process, it can be seen that virtual machine migration brings the following problems to the entire system: 1. Virtual machine hot migration will occupy a large amount of network and host resources, causing resource competition for system and user business operations; 2. The success rate of hot migration is largely determined by the business running in the virtual machine and the network bandwidth. If the speed of customer business updating memory is greater than the speed of memory migration, the migration cannot be completed; 3. By reducing the frequency of virtual machine CPU operation, the speed of memory dirtiness can be reduced and the migration success rate can be improved, but this method will affect the operation of customer business.
[0005] Therefore, how to provide a virtual machine QEMU program hot upgrade method to release and save system resources while improving migration and upgrade efficiency has become a technical problem that needs to be solved urgently. Summary of the invention
[0006] In view of this, in order to overcome the deficiencies of the prior art, the present application aims to provide a method, system and device for hot upgrading a virtual machine QEMU program.
[0007] According to a first aspect of the present application, a method for hot upgrading a virtual machine QEMU program is provided, the method comprising: Start the source virtual machine to generate an old version of QEMU process, and use the old version of QEMU process to allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine; Configure the startup parameters of the target virtual machine, start the target virtual machine on the same host using the new version of the QEMU file and the configured startup parameters of the target virtual machine, and generate a new version of the QEMU process; The old version of QEMU process establishes a connection with the target virtual machine according to the startup parameters of the target virtual machine, performs the initialization of the backend device of the target virtual machine and updates the virtual machine status information; After the destination virtual machine backend device is initialized and the virtual machine state information is updated, the destination virtual machine is run and the source virtual machine is shut down.
[0008] Optionally, in the QEMU program hot upgrade method of the present application, starting the source virtual machine to generate an old version of the QEMU process, and allocating corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version of the QEMU process, including: Start the source virtual machine by running the old version of QEMU file to generate the old version of QEMU process; An anonymous memory file descriptor is created through the memfd create function, and the mmap function is called through the anonymous memory file descriptor to allocate the corresponding virtual memory to the physical memory block of the source virtual machine.
[0009] Optionally, in the QEMU program hot upgrade method of the present application, corresponding virtual memory and anonymous memory file descriptors are allocated to the physical memory block of the source virtual machine through the old version QEMU process, including: saving all anonymous memory file descriptors and setting the attributes of the physical memory block to shared.
[0010] Optionally, in the QEMU program hot upgrade method of the present application, configuring the destination virtual machine startup parameters includes: configuring the destination virtual machine startup parameters by setting virtual machine state information migration channel parameters and anonymous memory file descriptor transfer parameters in the source virtual machine startup parameters.
[0011] Optionally, in the QEMU program hot upgrade method of the present application, configuring the startup parameters of the destination virtual machine also includes: setting a Unix Domain Socket file after the anonymous memory file descriptor is set to pass the parameters, and the new version of the QEMU process creates a listening task on the UnixDomain Socket file, and monitors the connection of the source virtual machine through the created listening task.
[0012] Optionally, in the QEMU program hot upgrade method of the present application, the old version QEMU process establishes a connection with the target virtual machine according to the target virtual machine startup parameters, performs initialization of the target virtual machine backend device and updates the virtual machine state information, including: Set up an anonymous memory file descriptor transfer channel and a virtual machine status information migration channel for the old version of QEMU process according to the target virtual machine startup parameters; The old version of QEMU process establishes a connection with the destination virtual machine through the anonymous memory file descriptor transmission channel, and transmits the anonymous memory file descriptor to the new version of QEMU process; After receiving the anonymous memory file descriptor passed by the old version of QEMU process, the new version of QEMU process performs the initialization of the backend device of the destination virtual machine; The old version of QEMU process establishes a connection with the destination virtual machine according to the virtual machine state information migration channel, suspends the operation of the destination virtual machine, and transmits the source virtual machine state information to the new version of QEMU process; The new version QEMU process receives the source virtual machine state information transmitted by the old version QEMU process, and updates the destination virtual machine state information in the virtual memory of the destination virtual machine.
[0013] Optionally, in the QEMU program hot upgrade method of the present application, after the new version QEMU process receives the anonymous memory file descriptor passed by the old version QEMU process, it executes initialization of the back-end device of the destination virtual machine, including: mapping the physical memory block corresponding to the anonymous memory file descriptor to a virtual address so that the new version QEMU process shares the physical memory of the old version QEMU process, and allocating corresponding virtual memory to the physical memory shared by the destination virtual machine.
[0014] Optionally, in the QEMU program hot upgrade method of the present application, after the initialization of the backend device of the destination virtual machine and the update of the virtual machine status information, the destination virtual machine is run and the source virtual machine is shut down, including: after the source virtual machine status information is transmitted, the new version of the QEMU process runs the destination virtual machine by executing and turning on the virtual central processor, and shuts down the source virtual machine by exiting the old version of the QEMU process.
[0015] According to a second aspect of the present application, a virtual machine QEMU program hot upgrade system is provided, the system comprising a hot upgrade server, the hot upgrade server comprising: The source virtual machine startup module is used to start the source virtual machine to generate an old version of the QEMU process, and allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version of the QEMU process; The target virtual machine startup module is used to configure the startup parameters of the target virtual machine, start the target virtual machine on the same host using the new version of QEMU file and the configured target virtual machine startup parameters, and generate a new version of QEMU process; The migration connection module is used for the old version of the QEMU process to establish a connection with the destination virtual machine according to the destination virtual machine startup parameters, perform the initialization of the destination virtual machine backend device and the update of the virtual machine status information; after the initialization of the destination virtual machine backend device and the update of the virtual machine status information, run the destination virtual machine and shut down the source virtual machine.
[0016] According to a third aspect of the present application, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present application when executing the program.
[0017] The virtual machine QEMU program hot upgrade method, system and device of the present application have the following beneficial technical effects: 1. By building a shared memory mechanism, the purpose of sharing physical memory between the new and old QEMU processes is achieved. Without migrating the entire memory of the virtual machine, the hot upgrade of the QEMU program is realized, which greatly improves the migration speed, can complete the migration process of the virtual machine more efficiently, and improves the QEMU upgrade efficiency.
[0018] 2. Create a unix socket channel method that supports the SCM_RIGHTS feature, implement a shared transmission mechanism for file descriptors, achieve efficient memory sharing between new and old QEMU processes, and further optimize the virtual machine hot migration process.
[0019] 3. Since there is no need to migrate virtual machine memory, a large amount of system and network resources are saved, reducing the demand for additional resources, which is especially beneficial for resource-constrained environments.
[0020] 4. Through the shared memory mechanism and shared transmission mechanism, hot migration has no requirements for network bandwidth and system resources, which significantly improves the success rate of QEMU upgrades. By controlling the pause time of the virtual machine during the hot upgrade process, the impact of the hot upgrade on the business is further reduced, ensuring business continuity and service stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 This is an example diagram of a virtual machine migration process in the prior art; Figure 2 This is an example diagram of the architecture of a virtual machine QEMU program hot upgrade system according to an embodiment of the present application; Figure 3 This is an example diagram of the architecture of a hot upgrade server of a virtual machine QEMU program hot upgrade system according to an embodiment of the present application; Figure 4 This is an example diagram of the steps of a method for hot upgrading a virtual machine QEMU program according to an embodiment of the present application; Figure 5 This is another step flow diagram of a method for hot upgrading a virtual machine QEMU program according to an embodiment of the present application; Figure 6 A schematic diagram of the structure of the device provided in this application. DETAILED DESCRIPTION
[0023] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0024] It should be noted that the following embodiments and features in the embodiments may be combined with each other in the absence of conflict; and, based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making any creative work are within the scope of protection of the present disclosure.
[0025] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0026] Figure 2 FIG. 1 is an example diagram of the architecture of a virtual machine QEMU program hot upgrade system according to an embodiment of the present application, such as Figure 2 As shown, the system may include a hot upgrade server 101, a communication network 102 and / or one or more hot upgrade clients 103. Figure 2 The example in the figure is a plurality of hot upgrade clients 103 .
[0027] The hot upgrade server 101 can be any appropriate server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the hot upgrade server 101 can perform appropriate functions. For example, in some embodiments, the hot upgrade server 101 can be used for hot upgrade of the virtual machine QEMU program. As an optional example, in some embodiments, the hot upgrade server 101 can be used to: start the source virtual machine to generate an old version of the QEMU process, and allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version of the QEMU process; configure the target virtual machine startup parameters, and use the new version of the QEMU file and the configured target virtual machine startup parameters on the same host to start the target virtual machine and generate a new version of the QEMU process; the old version of the QEMU process establishes a connection with the target virtual machine according to the target virtual machine startup parameters, performs the initialization of the target virtual machine backend device and the virtual machine status information update; after the initialization of the target virtual machine backend device and the virtual machine status information update, the target virtual machine is run and the source virtual machine is shut down.
[0028] Figure 3 FIG. 1 is an example diagram of the architecture of a hot upgrade server of a virtual machine QEMU program hot upgrade system according to an embodiment of the present application, such as Figure 3 As shown, the hot upgrade server of this embodiment includes: The source virtual machine startup module is used to start the source virtual machine to generate an old version of the QEMU process, and allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version of the QEMU process; The target virtual machine startup module is used to configure the startup parameters of the target virtual machine, start the target virtual machine on the same host using the new version of QEMU file and the configured target virtual machine startup parameters, and generate a new version of QEMU process; The migration connection module is used for the old version of the QEMU process to establish a connection with the destination virtual machine according to the destination virtual machine startup parameters, perform the initialization of the destination virtual machine backend device and the update of the virtual machine status information; after the initialization of the destination virtual machine backend device and the update of the virtual machine status information, run the destination virtual machine and shut down the source virtual machine.
[0029] As another example, in some embodiments, the hot upgrade server 101 may send the QEMU program hot upgrade method to the hot upgrade client 103 for the user to use according to the request of the hot upgrade client 103 .
[0030] As an optional example, in some embodiments, the hot upgrade client 103 is used to provide a visual hot upgrade interface, which is used to receive a selection input operation for hot upgrading the user's virtual machine QEMU program, and, in response to the selection input operation, obtain a hot upgrade interface corresponding to the option selected by the selection input operation from the hot upgrade server 101 and display the hot upgrade interface, wherein the hot upgrade interface at least displays information on the hot upgrade of the virtual machine QEMU program and operation options for the information on the hot upgrade of the virtual machine QEMU program.
[0031] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The hot upgrade client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the hot upgrade service end 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the hot upgrade client 103 and the hot upgrade service end 101, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.
[0032] The hot upgrade client 103 may include any one or more clients that present an interface related to high-speed access to an ORC external table in an appropriate form for use and operation by a user. In some embodiments, the hot upgrade client 103 may include any suitable type of device. For example, in some embodiments, the hot upgrade client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.
[0033] Although the hot upgrade server 101 is illustrated as one device, in some embodiments, any appropriate number of devices may be used to perform the functions performed by the hot upgrade server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by the hot upgrade server 101. Alternatively, a cloud service may be used to implement the functions of the hot upgrade server 101.
[0034] Based on the above system, an embodiment of the present application provides a cloud platform interface design walkthrough method based on a rule engine, which is described below through the following embodiments.
[0035] Figure 4 FIG. 1 is a flowchart of a method for hot upgrading a virtual machine QEMU program according to an embodiment of the present application. The method for hot upgrading a virtual machine QEMU program according to this embodiment can be executed at a hot upgrade server, such as Figure 4 As shown, the virtual machine QEMU program hot upgrade method includes the following steps: Step S201: Start the source virtual machine to generate an old version QEMU process, and allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version QEMU process.
[0036] As an optional example, this embodiment starts the source virtual machine by running the old version of QEMU file to generate the old version of QEMU process; creates an anonymous memory file descriptor through the memfd create function, and calls the mmap function through the anonymous memory file descriptor to allocate the corresponding virtual memory to the physical memory block of the source virtual machine. It should be noted that in this embodiment, all anonymous memory file descriptors are also saved and the attributes of the physical memory block are set to shared.
[0037] Step S202: configuring the startup parameters of the target virtual machine, starting the target virtual machine on the same host using the new version of the QEMU file and the configured startup parameters of the target virtual machine, and generating a new version of the QEMU process.
[0038] As an optional example, by setting the virtual machine state information migration channel parameters and anonymous memory file descriptor transfer parameters in the source virtual machine startup parameters, the destination virtual machine startup parameters are configured. After setting the anonymous memory file descriptor transfer parameters, a Unix Domain Socket file is set, and the new version of the QEMU process creates a listening task on the UnixDomain Socket file, and monitors the connection of the source virtual machine through the created listening task.
[0039] Step S203: the old version QEMU process establishes a connection with the target virtual machine according to the target virtual machine startup parameters, and performs initialization of the target virtual machine backend device and update of the virtual machine status information.
[0040] As an optional example, in this embodiment, an anonymous memory file descriptor transmission channel and a virtual machine state information migration channel are set for the old version QEMU process according to the startup parameters of the target virtual machine; the old version QEMU process establishes a connection with the target virtual machine through the anonymous memory file descriptor transmission channel, and transmits the anonymous memory file descriptor to the new version QEMU process; after the new version QEMU process receives the anonymous memory file descriptor transmitted by the old version QEMU process, it performs the initialization of the backend device of the target virtual machine; in this embodiment, by mapping the physical memory block corresponding to the anonymous memory file descriptor to a virtual address, the new version QEMU process shares the physical memory of the old version QEMU process, and allocates the corresponding virtual memory to the physical memory shared by the target virtual machine. The old version QEMU process establishes a connection with the target virtual machine according to the virtual machine state information migration channel, suspends the operation of the target virtual machine, and transmits the source virtual machine state information to the new version QEMU process; the new version QEMU process receives the source virtual machine state information transmitted by the old version QEMU process, and updates the target virtual machine state information in the virtual memory of the target virtual machine. It should be noted that in this embodiment, the pause time of the target virtual machine can be controlled within 10 milliseconds. Figure 5 This is another step flow diagram of a virtual machine QEMU program hot upgrade method according to an embodiment of the present application. In Figure 5, PC-RAM refers to the random access memory (Random Access Memory) in the computer, and VGA-RAM refers to the random access memory used with the VGA interface, which is used to store image data for display on the VGA display. PC-ROM refers to the read-only memory (Read-Only Memory) in the computer, VGA.ROM refers to the read-only memory (Read-Only Memory) used in the VGA display system, and PC.BIOS is the computer's basic input / output system (Basic Input / Output System), which is the first firmware program that runs when the computer starts, responsible for initializing the hardware devices and starting the operating system.
[0041] Step S204: After the destination virtual machine backend device is initialized and the virtual machine state information is updated, the destination virtual machine is run and the source virtual machine is shut down.
[0042] As an optional example, in this embodiment, after the source virtual machine state information is transmitted, the new version QEMU process starts the virtual central processor to run the destination virtual machine, and shuts down the source virtual machine by exiting the old version QEMU process.
[0043] The following is a further detailed description of the virtual machine QEMU program hot upgrade method of this embodiment in a specific scenario. In this scenario, the virtual machine QEMU program hot upgrade method of this embodiment is implemented according to the following steps: 1. Use the old version of QEMU file to start the virtual machine. This version of QEMU file does not contain fault fixes or new features. The old version of QEMU process is generated. This virtual machine is called the source virtual machine.
[0044] 2. The old version of QEMU process allocates corresponding virtual memory and obtains the corresponding anonymous memory file descriptor (hereinafter referred to as fd) for all memory blocks of the source virtual machine by calling memfd_create and mmap functions, and saves all fds.
[0045] 3. On the same host, start the destination virtual machine using the new version of the QEMU binary file and different startup parameters from the source virtual machine. This version of the QEMU binary file contains a bug fix patch or new features, and generates a new QEMU process. In this step, the difference between the startup parameters of the destination virtual machine and the source virtual machine is that an -incoming parameter and a -cprtransfer parameter are added. The -incoming parameter provides a channel for the migration of the source virtual machine and the destination virtual machine, and the -cprtransfer parameter is followed by a unix domain socket file. The new version of the QEMU process will create a listener on the file provided by this parameter, wait for the source virtual machine to connect, and transfer the fd. It should be noted that the new version of the QEMU process does not initialize the virtual machine's back-end device at this time.
[0046] 4. Set the unix domain socket file path for fd transmission for the old version of QEMU process. This channel is the unix socket file path used by the -cprtransfer parameter when the destination virtual machine is started; set the channel mode for migrating device status information for the old version of QEMU process, which is specified by the -incoming parameter.
[0047] 5. Trigger the migration. The first step of the migration is that the old version of QEMU process establishes a connection with the destination virtual machine through the set unix domainsocket file path, and passes the fd to the new version of QEMU process through the connection channel.
[0048] 6. The new version of QEMU process receives the fd passed by the old version of QEMU process and performs the initialization action of the backend device of the destination virtual machine. Since the corresponding fd exists, there is no need to reallocate the file descriptor. The fd is directly used as the parameter of mmap, that is, the physical memory block corresponding to the fd is mapped to a virtual address, so as to achieve the purpose of sharing physical memory between the new version of QEMU process and the old version of QEMU process. At this time, the destination virtual machine only completes the initialization action of the device, and the virtual central processing unit (hereinafter referred to as vcpu) thread of the destination virtual machine is not running.
[0049] 7. The old version of QEMU process will establish a connection with the destination virtual machine according to the connection method provided by the -incoming parameter, and continue the normal virtual machine migration process. First, the source virtual machine will be paused. Because the source virtual machine memory does not need to be migrated, the device status information will be transmitted through this channel.
[0050] 8. The new version of QEMU process receives the device status information and updates the device status information in the memory until the device information transmission is completed.
[0051] 9. After the migration is completed, the new version of QEMU process executes the start vcpu action, the destination virtual machine starts running, and the old version of QEMU process exits, that is, the source virtual machine shuts down.
[0052] Through the above steps, the hot upgrade of QEMU components is completed.
[0053] In this application, the QEMU program uses the memfd create function to allocate all memory blocks of the virtual machine. This function creates an anonymous memory file descriptor, uses fd to call mmap to allocate actual virtual memory, and then saves these fds and sets the attributes of these memory blocks to shared (shared), so that the new version and the old version of QEMU process can share memory. When the new version of QEMU process restores the virtual machine, when allocating memory to the ram block, it directly uses these fds to mmap to allocate virtual memory, so that the two QEMU processes can achieve the purpose of sharing physical memory. The cross-process fd transmission is achieved by creating a unix socket channel that supports the SCM_RIGHTS (control message type) feature.
[0054] In practical applications, the virtual machine QEMU program hot upgrade method and system of the embodiment of the present application has the following beneficial technical effects: 1. By building a shared memory mechanism, the purpose of sharing physical memory between the new and old QEMU processes is achieved. Without migrating the entire memory of the virtual machine, the hot upgrade of the QEMU program is realized, which greatly improves the migration speed, can complete the migration process of the virtual machine more efficiently, and improves the QEMU upgrade efficiency.
[0055] 2. Create a unix socket channel method that supports the SCM_RIGHTS feature, implement a shared transmission mechanism for file descriptors, achieve efficient memory sharing between new and old QEMU processes, and further optimize the virtual machine hot migration process.
[0056] 3. Since there is no need to migrate virtual machine memory, a large amount of system and network resources are saved, reducing the demand for additional resources, which is especially beneficial for resource-constrained environments.
[0057] 4. Through the shared memory mechanism and shared transmission mechanism, hot migration has no requirements for network bandwidth and system resources, which significantly improves the success rate of QEMU upgrades. By controlling the pause time of the virtual machine during the hot upgrade process, the impact of the hot upgrade on the business is further reduced, ensuring business continuity and service stability.
[0058] like Figure 6 As shown, the present application also provides a device, including a processor 310, a communication interface 320, a memory 330 for storing a processor executable computer program, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 implements the above-mentioned virtual machine QEMU program hot upgrade method by running the executable computer program.
[0059] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0060] The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected based on actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0061] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0062] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A virtual machine QEMU program hot upgrade method, characterized in that: The method comprises: Start the source virtual machine to generate an old version of QEMU process, and use the old version of QEMU process to allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine; Configure the startup parameters of the target virtual machine, start the target virtual machine on the same host using the new version of the QEMU file and the configured startup parameters of the target virtual machine, and generate a new version of the QEMU process; The old version of QEMU process establishes a connection with the target virtual machine according to the startup parameters of the target virtual machine, performs the initialization of the backend device of the target virtual machine and updates the virtual machine status information; After the destination virtual machine backend device is initialized and the virtual machine state information is updated, the destination virtual machine is run and the source virtual machine is shut down.
2. The QEMU program hot upgrade method according to claim 1, characterized in that: Start the source virtual machine to generate an old version of QEMU process, and use the old version of QEMU process to allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine, including: Start the source virtual machine by running the old version of QEMU file to generate the old version of QEMU process; An anonymous memory file descriptor is created through the memfd create function, and the mmap function is called through the anonymous memory file descriptor to allocate the corresponding virtual memory to the physical memory block of the source virtual machine.
3. The QEMU program hot upgrade method according to claim 1, characterized in that: The old version of QEMU process is used to allocate corresponding virtual memory and anonymous memory file descriptors to the physical memory block of the source virtual machine, including: saving all anonymous memory file descriptors and setting the attributes of the physical memory block to be shared.
4. The QEMU program hot upgrade method according to claim 1, characterized in that: Configuring the startup parameters of the destination virtual machine includes: configuring the startup parameters of the destination virtual machine by setting the virtual machine state information migration channel parameters and the anonymous memory file descriptor transfer parameters in the startup parameters of the source virtual machine.
5. The QEMU program hot upgrade method according to claim 4, characterized in that: Configuring the startup parameters of the destination virtual machine also includes: setting a Unix Domain Socket file after passing the parameters through the set anonymous memory file descriptor, the new version of the QEMU process creating a listening task on the Unix Domain Socket file, and listening to the connection of the source virtual machine through the created listening task.
6. The virtual machine QEMU program hot upgrade method according to claim 1, characterized in that: The old version of QEMU process establishes a connection with the target virtual machine according to the target virtual machine startup parameters, performs the initialization of the target virtual machine backend device and updates the virtual machine status information, including: Set up an anonymous memory file descriptor transfer channel and a virtual machine state information migration channel for the old version of QEMU process according to the target virtual machine startup parameters; The old version of QEMU process establishes a connection with the destination virtual machine through the anonymous memory file descriptor transmission channel, and transmits the anonymous memory file descriptor to the new version of QEMU process; After receiving the anonymous memory file descriptor passed by the old version of QEMU process, the new version of QEMU process performs the initialization of the backend device of the destination virtual machine; The old version of QEMU process establishes a connection with the destination virtual machine according to the virtual machine state information migration channel, suspends the operation of the destination virtual machine, and transmits the source virtual machine state information to the new version of QEMU process; The new version QEMU process receives the source virtual machine state information transmitted by the old version QEMU process, and updates the destination virtual machine state information in the virtual memory of the destination virtual machine.
7. The method for hot upgrading a virtual machine QEMU program according to claim 6, characterized in that: After receiving the anonymous memory file descriptor passed by the old version QEMU process, the new version QEMU process executes the initialization of the backend device of the destination virtual machine, including: mapping the physical memory block corresponding to the anonymous memory file descriptor to a virtual address so that the new version QEMU process shares the physical memory of the old version QEMU process, and allocating corresponding virtual memory to the physical memory shared by the destination virtual machine.
8. The virtual machine QEMU program hot upgrade method according to claim 1, characterized in that: After the destination virtual machine backend device is initialized and the virtual machine state information is updated, the destination virtual machine is run and the source virtual machine is shut down, including: after the source virtual machine state information is transmitted, the new version QEMU process runs the destination virtual machine by executing and starting the virtual central processor, and shuts down the source virtual machine by exiting the old version QEMU process.
9. A virtual machine QEMU program hot upgrade system, characterized in that: The system includes a hot upgrade server, and the hot upgrade server includes: The source virtual machine startup module is used to start the source virtual machine to generate an old version of the QEMU process, and allocate corresponding virtual memory and anonymous memory file descriptors to the memory of the source virtual machine through the old version of the QEMU process; The target virtual machine startup module is used to configure the startup parameters of the target virtual machine, start the target virtual machine on the same host using the new version of QEMU file and the configured target virtual machine startup parameters, and generate a new version of QEMU process; The migration connection module is used for the old version of the QEMU process to establish a connection with the destination virtual machine according to the destination virtual machine startup parameters, perform the initialization of the destination virtual machine backend device and the update of the virtual machine status information; after the initialization of the destination virtual machine backend device and the update of the virtual machine status information, run the destination virtual machine and shut down the source virtual machine.
10. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 8 when executing the program.
Citation Information
Cited By
Windows virtual machine starting acceleration method and device, computer equipment and storage medium
CN119902858A
Hot update method and device of vhost device management program and server
CN120950096A
Method, device and server for hot updating of vhost device manager
CN120950096B