CN115390876A - Virtual machine QEMU program hot upgrading method, device and equipment - Google Patents

Virtual machine QEMU program hot upgrading method, device and equipment Download PDF

Info

Publication number
CN115390876A
CN115390876A CN202211046854.4A CN202211046854A CN115390876A CN 115390876 A CN115390876 A CN 115390876A CN 202211046854 A CN202211046854 A CN 202211046854A CN 115390876 A CN115390876 A CN 115390876A
Authority
CN
China
Prior art keywords
qemu
old
virtual
qemu process
new
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211046854.4A
Other languages
Chinese (zh)
Inventor
王勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Technologies Co Ltd
Original Assignee
New H3C Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New H3C Technologies Co Ltd filed Critical New H3C Technologies Co Ltd
Priority to CN202211046854.4A priority Critical patent/CN115390876A/en
Publication of CN115390876A publication Critical patent/CN115390876A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method, a device and equipment for hot upgrading of a virtual machine QEMU (QEMU) program, which are used for solving the technical problem of the hot upgrading efficiency of the virtual machine QEMU program. The method starts a new QEMU process on a host machine running an old QEMU process, inherits all running parameters of the old QEMU process, enables the new QEMU process to be consistent in kernel space, user space and virtual equipment state by copying a virtual memory area data structure of the old QEMU process, an associated page table and a synchronous virtual equipment state during the period of suspending the running of the virtual machine, and uses the new QEMU process to replace the old QEMU process, thereby realizing the online hot upgrade of the QEMU program. The scheme provided by the invention does not need to carry out the thermal migration of the virtual machine, reduces the consumption of software and hardware resources such as memory, bandwidth and the like, reduces the upgrade failure rate, reduces the upgrade time and further improves the upgrade efficiency.

Description

Virtual machine QEMU program hot upgrading method, device and equipment
Technical Field
The invention relates to the technical field of communication and cloud computing, in particular to a method, a device and equipment for hot upgrading of a virtual machine QEMU program.
Background
KVM (Kernel-based Virtual Machine) is a Linux Kernel-based virtualization technology. The Linux kernel can be directly converted into a Hypervisor (virtual machine monitoring manager) by using a KVM (keyboard video mouse) technology, so that the Linux kernel can directly manage the virtual machines and directly call a memory management subsystem and a process management subsystem in the Linux kernel to manage the virtual machines. As long as the current Linux system is loaded with a KVM program module, the Linux kernel directly becomes a virtual machine monitoring manager (Hypervisor), the Hypervisor can directly run related management commands on the system to manage KVM virtual machines, and each created virtual machine has its own user space and kernel space.
QEMU (Quick Emulator) is simulator software used to simulate processors and peripherals for a virtual machine.
The KVM Hypervisor simulates a device through a user mode program QEMU (Quick Emulator), and one Virtual Machine (VM) corresponds to one QEMU process.
In an actual application scenario, the QEMU program often needs to be updated, for example, a software BUG is repaired or a large version of the QEMU program is upgraded, and the upgrading of the QEMU program most importantly ensures that the normal operation of the virtual machine is not affected, and simultaneously reduces the downtime of the virtual machine to the maximum extent, which is very important for a virtualization service provider.
The existing QEMU program upgrading method needs to execute the live migration of a virtual machine, for example, a server A and a server B form a cluster to use shared storage, a virtual disk file of a virtual machine vm1 on the server A is stored on the shared storage, when the QEMU program of the server A needs to be upgraded, in order to not influence the service running on vm1, vm1 on the server A needs to be firstly live migrated to the server B, then a QEMU binary program on the server A is updated, and finally the virtual machine vm1 is migrated back to the server A. After the virtual machine is migrated back to the server A, the QEMU process of the virtual machine on the server A is created by using the upgraded QEMU binary program, so that the purpose of upgrading the QEMU program is achieved.
Although the existing QEMU program upgrading method can achieve the purpose of QEMU program upgrading and does not affect the service on the virtual machine, the existing QEMU program upgrading method has the following defects:
(1) The upgrading efficiency is low: due to the need of live migration of the virtual machines, live migration of the virtual machines among the hosts consumes a large amount of network resources and host memory resources, and particularly consumes a large amount of resources and time when upgrading a large cluster environment, which results in low upgrading efficiency.
(2) The failure is easy to generate: besides the long migration time, the situation that the virtual machine needs to be closed to be upgraded due to the migration timeout failure may occur for a part of the large-memory virtual machines, so that the normal operation of the service on the virtual machine is influenced.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, and a device for virtual machine QEMU program hot upgrade, which are used to solve the technical problem of virtual machine QEMU program hot upgrade efficiency.
Based on one aspect of the embodiment of the invention, the invention provides a method for hot upgrading of a virtual machine QEMU program, which is applied to a host of the virtual machine, and comprises the following steps:
storing address information of memory blocks (ram blocks) of an old QEMU process, wherein the old QEMU process is created by operating an old version QEMU program file;
replacing the old version QEMU program file with the new version QEMU program file;
suspending the running of the virtual machine, and storing the state information of the virtual equipment in the old QEMU process;
operating the new version QEMU program file to create a new QEMU process, wherein the new QEMU process inherits the program operating parameters of the old QEMU process;
copying all virtual memory area (vma) data structures in the old QEMU process along with a page table into the new QEMU process;
initializing the new QEMU process using address information of the memory blocks (ram blocks) of the old QEMU process;
and after the state information of the virtual equipment in the old QEMU process is restored to the new QEMU process, the virtual machine is enabled to restore to a normal running state.
Further, the old QEMU process manages the memory region (vma) data structure by an address space descriptor (mm _ struct); and the start-stop address information of the memory blocks (ram blocks) is recorded in the data structure of the virtual memory area (vma).
Further, when all virtual memory region (vma) data structures in the old QEMU process are copied into the new QEMU process along with the page table, only the marked memory region data structures and their associated page tables are copied.
Further, the address information of the old QEMU process memory blocks (ram blocks) is stored in an environment variable; and when the new QEMU process is initialized, reading the address information of the memory blocks (ram blocks) of the old QEMU process from the environment variable.
Further, the state information of the virtual equipment in the old QEMU process is stored in a specified state file;
and when the state information of the virtual equipment in the old QEMU process is recovered to the new QEMU process, reading the state information of the virtual equipment in the old QEMU process from the specified state file.
Further, the virtual address of the memory block (ram blocks) recorded in the virtual memory area (vma) data structure in the old QEMU process is a four-level page table address;
the page table copy refers to a copy of a four-level page table address associated with a virtual address recorded in the virtual memory region (vma) data structure.
Based on one aspect of the embodiment of the present invention, the present invention further provides a device for hot upgrade of a virtual machine QEMU program, which can be implemented in software, hardware, or a combination of software and hardware. When implemented in the form of a software module, when the program code of the software module is loaded into a storage medium of an electronic device, the program code in the storage medium is read by a processor and executed, so as to implement the functions of each constituent module in the apparatus. The device is applied to the host machine of the virtual machine, and comprises the following components:
the system comprises a block address storage module, a memory module and a memory module, wherein the block address storage module is used for storing address information of memory blocks (ram blocks) of an old QEMU process, and the old QEMU process is created by running an old version QEMU program file;
the file upgrading module is used for replacing the old version QEMU program file with the new version QEMU program file;
the state saving module is used for suspending the running of the virtual machine and saving the state information of the virtual equipment in the old QEMU process;
the new process creation module is used for operating the new version QEMU program file to create a new QEMU process, and the new QEMU process inherits the program operation parameters of the old QEMU process;
a memory copy module, configured to copy all virtual memory area (vma) data structures in the old QEMU process and the page table to the new QEMU process; and initializing the new QEMU process using address information of the old QEMU process memory blocks (ram blocks);
and the state recovery module is used for recovering the state information of the virtual equipment in the old QEMU process to the new QEMU process and then enabling the virtual machine to recover the normal running state.
Further, the block address saving module saves the address information of the old QEMU process memory blocks (ram blocks) in an environment variable;
when the new QEMU process is initialized, the state recovery module reads the address information of the memory blocks (ram blocks) of the old QEMU process from the environment variables;
the state saving module saves the state information of the virtual equipment in the old QEMU process in an appointed state file;
and the state recovery module reads the state information of the virtual equipment in the old QEMU process from the specified state file.
Further, the virtual address of the memory block (ram blocks) recorded in the virtual memory area (vma) data structure in the old QEMU process is a four-level page table address;
the page table copy by the memory copy module is a copy of a four-level page table address associated with a virtual address.
The method starts a new QEMU process on a host machine running an old QEMU process, inherits all running parameters of the old QEMU process, keeps the new and old QEMU processes consistent in kernel space, user space and virtual equipment state by copying a virtual memory area data structure of the old QEMU process, an associated page table and a synchronous virtual equipment state during the period of suspending the running of the virtual machine, and replaces the old QEMU process with the new QEMU process, thereby realizing the online hot upgrade of the QEMU program. The scheme provided by the invention does not need to carry out the thermal migration of the virtual machine, reduces the consumption of software and hardware resources such as memory, bandwidth and the like, reduces the upgrade failure rate, reduces the upgrade time and further improves the upgrade efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments of the present invention or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and for those skilled in the art, other drawings may be obtained according to the drawings of the embodiments of the present invention.
FIG. 1 is a schematic diagram illustrating upgrading of a QEMU program of a virtual machine in a host according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a management structure of a QEMU process address space according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a data structure for allocating and managing process address space in accordance with an embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating a hot copy of a memory and a page table in a QEMU program hot upgrade scheme according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating steps of a method for hot upgrade of a QEMU program of a virtual machine according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device for implementing the virtual machine QEMU program hot upgrade provided in the embodiment of the present invention.
Detailed Description
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the embodiments of the invention. As used in this embodiment of the invention, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used to describe various information in embodiments of the present invention, the information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of embodiments of the present invention. Depending on the context, moreover, the word "if" is used may be interpreted as "at … …" or "at … …" or "in response to a determination".
The invention provides a virtual machine QEMU program hot-upgrading scheme for solving the problem that the requirements and consumption of network and server resources are higher when QEMU program upgrading is carried out in a virtual machine hot migration mode, and upgrading efficiency is lower, and the basic idea of the invention is as follows: the method comprises the steps of starting a new QEMU process on a host machine running an old QEMU process, inheriting all running parameters of the old QEMU process, copying a virtual memory area data structure and an associated page table of the old QEMU process and synchronizing virtual equipment states during the period of suspending the running of a virtual machine, enabling the new QEMU process to be consistent in kernel space, user space and virtual equipment states, after the new QEMU process runs, enabling the virtual machine to achieve switching of the new QEMU process, replacing the old QEMU process with the new QEMU process, and continuing running on an original virtual address space and a mapped physical memory space of the old QEMU process, so that the purpose of online thermal upgrading of the QEMU program is achieved.
The QEMU program hot-upgrading scheme provided by the invention does not need hot migration of the virtual machine, reduces the consumption of software and hardware resources such as memory, bandwidth and the like, reduces the upgrading fault rate, shortens the upgrading time and further improves the upgrading efficiency.
Based on the basic idea of the invention, the following describes a specific implementation process of the invention with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a schematic diagram illustrating an overview of upgrading a QEMU program of a virtual machine in a host according to an embodiment of the present invention. The main process of upgrading the QEMU program of the virtual machine is carried out in the host machine for bearing the virtual machine, after the binary file of the QEMU program of the old version (called the old QEMU program for short) runs in the host machine, the old QEMU user process (called the old QEMU process for short) can be generated in the user space, and before the version of the QEMU program is updated, the old QEMU process is bound by the virtual machine. When the QEMU version is to be updated, a new version of the QEMU secondary system file is needed to replace an old version of the QEMU secondary system file, then a new QEMU secondary system file is loaded through a program starting interface of an operating system so as to start a new version of a QEMU user process (called a new QEMU process for short), and when the new QEMU process is started, the running parameters of the old QEMU process are obtained through a preset interface when the new QEMU process is started, so that the new QEMU process and the old QEMU process use the same running parameters when the new QEMU process is started. Generally, some configuration parameters of the virtual machine are provided to the QEMU process in the form of operation parameters when the QEMU process is started, and the configuration parameters such as the size of virtual memory allocated to the virtual machine can be maintained by saving the program operation parameters in the global variables in the program entry function, and reading the contents of the global variables when a new QEMU process is started, so as to maintain the consistency of configuration of the new and old QEMU processes.
According to the QEMU program hot-upgrading scheme provided by the invention, in the upgrading process, the virtual machine does not need to be shut down, only the virtual machine needs to be shut down (Pause) for a short time, after the switching of new and old QEMU processes is executed, the virtual machine can resume normal operation again, the time scale required by the whole hot-upgrading can be measured in milliseconds, a user hardly feels the QEMU program hot-upgrading process, and the normal operation of the virtual machine bearing service is not influenced. As can be seen from the example in fig. 1, the QEMU program hot upgrade scheme provided by the present invention does not need to perform hot migration of virtual machines between servers, that is, host machines, and can complete the upgrade process of QEMU only on the host machines, thereby avoiding occupation of network bandwidth resources and reducing the upgrade failure probability.
The QEMU program hot upgrade process provided by the present invention will be described in detail below with reference to a Linux operating system, and can be implemented based on the same basic idea for other types of operating systems, and the present invention does not make specific limitations on the type of operating system to which the technical solution provided by the present invention is applied.
Fig. 2 is a schematic diagram of a management structure of a QEMU process address space in an embodiment of the present invention, where each process has an independent address space and does not affect each other in a Linux operating system. The process address space is managed in a segmented manner, and fig. 2 illustrates an address space composition structure of the QEMU process by taking a 64-bit address space as an example. Each process may include three parts, user Space (User Space), kernel Space (Kernel Space), and reserved Space (Reserve). The user space and the kernel space have similar composition structures, and both the user space and the kernel space can comprise space address sections such as Code sections (Code), data sections (Data), stack sections (Heap), mapping sections (Mapping), stack sections (Stack) and the like according to the use of the space. The process address space is a virtual address space, when a process applies for a memory space, an operating system allocates the memory space for the process in a continuous address block manner, and virtual addresses are mapped to a physical address space through a Page Table (Page Table).
Fig. 3 is a schematic diagram of a data structure for allocating and managing a process address space in an embodiment of the present invention, where an operating system allocates a process descriptor (task _ struct) to each process, the process descriptor is associated with a process address space descriptor (mm _ struct), the process address space descriptor stores and manages a Virtual Memory Area (VMA) data structure (vm _ Area _ struct) applied by the process in various address fields in a linked list data structure form, and the VMA data structure stores address information such as a start address (vm _ start) and an end address (vm _ end) of the Virtual Memory Area. For example, the address information of a block of memory area applied by the old QEMU process in the Code segment is stored by vma1, the address information of a block of memory area applied in the Heap segment heal is stored by vma3, and so on. When an application uses a memory request function (e.g., malloc) to request a block of memory (from Heap segment Heap), virtual memory is allocated and physical memory is not allocated until the block of memory is not used, and when the block of memory is accessed for the first time, a physical page is allocated through a page fault exception, and a mapping relation with a virtual address is established through a page table (page table).
FIG. 4 is a schematic diagram illustrating a hot copy of the memory and the page table in the QEMU program hot upgrade scheme according to an embodiment of the present invention. FIG. 4 illustrates how the memory and page table of the Old QEMU process (Old QEMU) is completely copied into the New QEMU process (New QEMU) during a hot upgrade of the QEMU program. The QEMU process may simulate multiple devices (devices), such as a virtual memory, a virtual graphics card, a virtual network card, etc., for the virtual machine, and to ensure normal use of these virtual devices after the hot upgrade, it is necessary to copy the states of these virtual devices in the old QEMU process to the new QEMU process.
In the QEMU process, the virtual memory applied by the virtual device and the service application is allocated to the virtual device and the service application in the form of ram blocks (ram blocks), and as described above, the operating system records and manages these memory blocks in a vma data structure of a virtual memory region, for example, the ram blocks in the figure have a virtual machine memory (pc.ram) memory block, a virtual machine video card memory (vga.vm) memory block, a virtual machine read-only memory (pc.rom) memory block, and the like. During the hot upgrade process, the vmas corresponding to ram blocks need to be completely copied to a new QEMU process. The address information recorded in vma is a virtual address in a virtual address space of the QEMU process, and the virtual address of the QEMU process is mapped into a physical memory space through a Page Table (Page Table).
Although only the vma of the memory blocks (ram blocks) allocated in the Heap segment (Heap) is illustrated in fig. 4, it can be understood by those skilled in the art that ram blocks can be allocated in both the user space and the kernel space of the QEMU process, and during the hot upgrade, the vma in both the user space and the kernel space of the old QEMU process will be copied into the new QEMU process in a same manner, so as to completely recover the memory field state of the old QEMU process on the new QEMU after the upgrade.
In Linux, the mapping between virtual addresses and physical addresses is generally divided into 4 levels, which are a Page Global Directory (PGD), a Page Upper Directory (PUD), a Page Middle Directory (PMD), and a Page Table (PTE). The Page Table (Page Table) in the present invention refers to a data structure for completely recording the mapping relationship between virtual addresses and physical addresses, and not to refer to only the PTE part in the above four-level structure. The page table copy described in the present invention refers to a copy of the complete mapping relationship between virtual addresses and physical addresses.
Fig. 5 is a schematic flowchart of a step of a method for hot upgrading a QEMU program of a virtual machine according to an embodiment of the present invention, where the method is applied to a host of the virtual machine, and the host may run one or more virtual machines to be upgraded with the QEMU program. The invention calls the process created by the QEMU program of the old version used by the virtual machine before upgrading as the old QEMU process, and calls the process created by the QEMU program of the upgraded target new version as the new QEMU process.
Step 501, operating an old version QEMU program file to create an old QEMU process;
and after the virtual machine is started, loading a secondary process program file for running an old version QEMU program so as to create an old QEMU process, wherein the configuration of the virtual machine can be transmitted into the old QEMU process in a program running parameter mode.
After the virtual machine runs, in the process of providing service for the outside, the virtual machine can use virtual equipment, service applications can also apply for a virtual memory space to store service data, the virtual equipment of the virtual machine and the virtual memory applied by the service applications are distributed and managed in the form of ram blocks, and the address information of the ram blocks can be recorded in the user space of the QEMU process. Accordingly, in the kernel space of the QEMU process, the operating system stores information of the allocated memory blocks (ram blocks) in a virtual memory region (vma) data structure, such as start-stop addresses of the memory blocks.
Step 502, storing the address information of the memory blocks (ram blocks) of the old QEMU process;
in a preferred embodiment of the present invention, address information of a memory block in a user space of an old QEMU process is stored in an environment variable, and when a memory block is copied to a new QEMU process by hot upgrade, the address information of the memory block of the old QEMU process is obtained by reading the environment variable.
The method for storing the memory block address information in the old QEMU process may also be a method of writing a file or a data base, as long as the new QEMU can read the memory block address information, and the invention is not particularly limited.
Step 503, replacing the old version QEMU program file with the new version QEMU program file;
after an old version QEMU program file (referring to a secondary system program file generated after the old version QEMU program is compiled) is operated to generate an old QEMU process, the old QEMU process and the old version QEMU program file are mutually independent, the old QEMU process operates in a memory space of an operating system, and the QEMU program file is stored in a physical disk, so that the old version QEMU program file can be replaced by the new version QEMU program file in a covering mode before hot upgrading is carried out, and the QEMU program file is upgraded firstly.
Step 504, suspending the running of the virtual machine, and storing the state information of the virtual equipment in the old QEMU process;
in a preferred embodiment of the present invention, the old QEMU process writes the state information of the virtual device into the specified state file, and at the end of the hot upgrade, before the new QEMU process is run to make the virtual machine provide the service to the outside, the new QEMU process obtains the virtual device state at the time of suspending the running of the virtual machine by reading the specified state file, so as to recover the virtual device state in the new QEMU process.
The same object can be achieved by other means besides the way of storing and transferring the virtual device state by writing a file, and the invention is not limited specifically, for example, by writing an environment variable, by writing a database, and the like.
In the step, the suspension of the running of the virtual machine is equivalent to the suspension of the old QEMU process, after the suspension of the virtual machine, the virtual machine does not provide service to the outside, and the state of the virtual equipment is kept unchanged. For the upper system, although the new and old QEMU processes are two different processes, the switching of the bottom QEMU process is not aware to the upper system because the virtual machine name is unchanged.
Step 505, operating the new version QEMU program file to create a new QEMU process;
in one embodiment of the invention, the new QEMU process is created by calling an interface (such as an excecvp interface) of the running program of the operating system in the old QEMU process to run the new version QEMU program and inheriting the program running parameters for creating the old QEMU process to the new version QEMU program. Because the same program operating parameters are used when the new and old QEMU processes are created, the new and old QEMU processes can ensure the complete identity in configuration, including the configuration of the virtual process address space of the new and old QEMU processes. The process address spaces of the new and old QEMU processes are configured identically, so that it can be ensured that the virtual address spaces based on the subsequent copying of the contents of the virtual memory area data structure (vma) and the page table are identical, and further, after the hot upgrade, the mapping relation between the virtual address and the physical address in the vma of the new QEMU process is ensured to be consistent with the old QEMU.
Step 506, copying all virtual memory area (vma) data structures in the old QEMU process and the page table to the new QEMU process;
the step is a key step of hot upgrade, and after the hot upgrade is ensured, the contents of the user space and the kernel space of the new QEMU process and the old QEMU process are consistent, and the mapping relation between the virtual address and the physical address is consistent, all the vma data structures of the old QEMU process are required to be copied to the new QEMU process, and the page tables associated in the vmas are required to be copied to the new QEMU process together, so that the new QEMU process can access the same physical address as the old QEMU process through the virtual address in the vma.
In a preferred embodiment of the present invention, the virtual memory area (vma) data structure to be copied may be marked, and only the marked vma data structure may be copied during a hot upgrade. The present invention does not specifically limit the means of marking, for example, the type of the vma data structure that needs to be copied may be fixed marked in the program, or marked by a configuration file, etc.
Step 507, initializing a new QEMU process by using address information of memory blocks (ram blocks) of the old QEMU process;
after copying the contents of the vma data structure, initializing a new QEMU process by using address information of memory blocks (ram blocks) of the old QEMU process, and thus reestablishing the association relationship between the ram blocks and the vma in the old QEMU process in the new QEMU.
Based on the foregoing example, the same ram blocks are created by reading ram blocks address information of the old QEMU process from the environment variable, and then initializing in the new QEMU according to the read ram blocks address information.
And step 508, restoring the state information of the virtual equipment in the old QEMU process to the new QEMU process, and then restoring the normal running state of the virtual machine.
And after the steps are executed, the hot upgrade of the QEMU program of the virtual machine is completed.
Through the steps, the efficient and quick upgrading of the QEMU program of the virtual machine is realized under the condition that the virtual machine is temporarily suspended (Pause), the key is that the virtual address space of the old QEMU process is completely mapped to the new QEMU process, the new QEMU process replaces the old QEMU process, and the normal operation of the virtual machine is hardly influenced.
The technical scheme of the invention realizes the hot upgrade of the QEMU program by utilizing the process virtual address space mapping technology, has small memory consumption, does not need to reserve the memory space of a new version QEMU virtual machine on a physical host machine, and can implement the hot upgrade under the scene that the residual memory space of the host machine is tense.
The technical scheme of the invention avoids migrating virtual machines among host computers of different virtual machines, avoids the consumption of resources and bandwidth, improves the speed and the reliability of the QEMU program thermal upgrade, has more obvious effect on the upgrade of the QEMU program of the large-memory virtual machine, can measure the time magnitude required by the whole thermal upgrade process by milliseconds, such as about 100ms, and greatly improves the upgrade efficiency.
Fig. 6 is a schematic structural diagram of an electronic device for implementing a virtual machine QEMU program hot upgrade provided in an embodiment of the present invention, where the device 600 includes: a processor 610 such as a Central Processing Unit (CPU), a communication bus 620, a communication interface 640, and a storage medium 630. Wherein the processor 610 and the storage medium 630 may communicate with each other through a communication bus 620. The storage medium 630 has stored therein a computer program that, when executed by the processor 610, performs the functions of one or more steps of the virtual machine QEMU program hot upgrade provided by the present invention.
The storage medium may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), for example, at least one disk Memory. In addition, the storage medium may be at least one memory device located remotely from the processor. The Processor may be a general-purpose Processor including a Central Processing Unit (CPU), a Network Processor (NP), etc.; but also Digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
It should be recognized that embodiments of the present invention can be realized and implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory memory. The method may be implemented in a computer program using standard programming techniques, including a non-transitory storage medium configured with the computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner. Each program may be implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language. Furthermore, the program can be run on a programmed application specific integrated circuit for this purpose. Further, operations of processes described herein may be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and/or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) collectively executed on one or more processors, by hardware, or combinations thereof. The computer program includes a plurality of instructions executable by one or more processors.
Further, the method may be implemented in any type of computing platform operatively connected to a suitable connection, including but not limited to a personal computer, mini computer, mainframe, workstation, networked or distributed computing environment, separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, or the like. Aspects of the invention may be embodied in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optically read and/or write storage medium, RAM, ROM, or the like, such that it may be read by a programmable computer, which when read by the storage medium or device, is operative to configure and operate the computer to perform the procedures described herein. Further, the machine-readable code, or portions thereof, may be transmitted over a wired or wireless network. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. The invention also includes the computer itself when programmed according to the methods and techniques described herein.
The above description is only an example of the present invention, and is not intended to limit the present invention. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for hot upgrading of a virtual machine QEMU program is applied to a host of a virtual machine, and comprises the following steps:
storing address information of memory blocks of an old QEMU process, wherein the old QEMU process is created by operating an old version QEMU program file;
replacing the old version QEMU program file with the new version QEMU program file;
suspending the running of the virtual machine, and storing the state information of the virtual equipment in the old QEMU process;
operating the new version QEMU program file to create a new QEMU process, wherein the new QEMU process inherits the program operating parameters of the old QEMU process;
copying all virtual memory area data structures in the old QEMU process and the page table to the new QEMU process;
initializing the new QEMU process by using the address information of the memory block of the old QEMU process;
and after the state information of the virtual equipment in the old QEMU process is restored to the new QEMU process, the virtual machine is enabled to restore to a normal running state.
2. The method of claim 1,
the old QEMU process manages the memory area data structure through an address space descriptor;
and recording start-stop address information of the memory block in the virtual memory area data structure.
3. The method as claimed in claim 1, wherein when all virtual memory region data structures in the old QEMU process are copied into the new QEMU process together with the page table, only the marked memory region data structures and their associated page tables are copied.
4. The method of claim 1,
the address information of the old QEMU process memory block is stored in an environment variable;
and when the new QEMU process is initialized, reading the address information of the memory block of the old QEMU process from the environment variable.
5. The method of claim 1,
the state information of the virtual equipment in the old QEMU process is stored in a specified state file;
and when the state information of the virtual equipment in the old QEMU process is restored to the new QEMU process, reading the state information of the virtual equipment in the old QEMU process from the specified state file.
6. The method according to claim 1 or 2,
the virtual address of the memory block recorded in the virtual memory area data structure in the old QEMU process is a four-level page table address;
the page table copy refers to a copy of a four-level page table address associated with a virtual address recorded in the virtual memory region data structure.
7. A device for hot upgrading of a QEMU program of a virtual machine is applied to a host of the virtual machine, and comprises:
the system comprises a block address storage module, a memory module and a data processing module, wherein the block address storage module is used for storing address information of memory blocks in an old QEMU process, and the old QEMU process is created by running an old version QEMU program file;
the file upgrading module is used for replacing the old version QEMU program file with the new version QEMU program file;
the state saving module is used for suspending the running of the virtual machine and saving the state information of the virtual equipment in the old QEMU process;
the new process creation module is used for operating the new version QEMU program file to create a new QEMU process, and the new QEMU process inherits the program operation parameters of the old QEMU process;
a memory copy module, configured to copy all virtual memory region data structures in the old QEMU process and the page table to the new QEMU process; initializing the new QEMU process by using the address information of the memory block of the old QEMU process;
and the state recovery module is used for recovering the state information of the virtual equipment in the old QEMU process to the new QEMU process and then enabling the virtual machine to recover the normal running state.
8. The apparatus of claim 7,
the block address storage module stores the address information of the old QEMU process memory block in an environment variable;
when initializing the new QEMU process, the state recovery module reads the address information of the memory block of the old QEMU process from the environment variable;
the state saving module saves the state information of the virtual equipment in the old QEMU process in an appointed state file;
and the state recovery module reads the state information of the virtual equipment in the old QEMU process from the specified state file.
9. The apparatus of claim 7,
the virtual address of the memory block recorded in the virtual memory area data structure in the old QEMU process is a four-level page table address;
the page table copy by the memory copy module is a copy of a four-level page table address associated with a virtual address.
10. An electronic device is characterized by comprising a processor, a communication interface, a storage medium and a communication bus, wherein the processor, the communication interface and the storage medium are communicated with each other through the communication bus;
a storage medium for storing a computer program;
a processor for performing the method steps of any one of claims 1-6 when executing a computer program stored on a storage medium.
CN202211046854.4A 2022-08-30 2022-08-30 Virtual machine QEMU program hot upgrading method, device and equipment Pending CN115390876A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211046854.4A CN115390876A (en) 2022-08-30 2022-08-30 Virtual machine QEMU program hot upgrading method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211046854.4A CN115390876A (en) 2022-08-30 2022-08-30 Virtual machine QEMU program hot upgrading method, device and equipment

Publications (1)

Publication Number Publication Date
CN115390876A true CN115390876A (en) 2022-11-25

Family

ID=84124644

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211046854.4A Pending CN115390876A (en) 2022-08-30 2022-08-30 Virtual machine QEMU program hot upgrading method, device and equipment

Country Status (1)

Country Link
CN (1) CN115390876A (en)

Similar Documents

Publication Publication Date Title
US9811369B2 (en) Method and system for physical computer system virtualization
US8789069B2 (en) On-the-fly replacement of physical hardware with emulation
US9063821B1 (en) Method for updating operating system without memory reset
US8176294B2 (en) Reducing storage expansion of a virtual machine operating system
CN102541619B (en) Virtual machine management device and method
CN107209683B (en) Backup image restore
US20190391843A1 (en) System and method for backing up virtual machine memory with shared storage for live migration
US11487523B2 (en) Updating machine emulator
US20110066786A1 (en) Method of Suspending and Resuming Virtual Machines
US10289564B2 (en) Computer and memory region management method
US20160266923A1 (en) Information processing system and method for controlling information processing system
CN104603750A (en) Layout and execution of software applications using BPRAM
CN107368353B (en) Method and device for realizing hot addition of virtual machine memory
US20170177225A1 (en) Mid-level controllers for performing flash management on solid state drives
CN104583948A (en) Layout and execution of operating systems using BPRAM
CN111679889B (en) Conversion migration method and system of virtual machine
US10664299B2 (en) Power optimizer for VDI system
CN107832097B (en) Data loading method and device
US9952984B2 (en) Erasing a storage block before writing partial data
CN115390876A (en) Virtual machine QEMU program hot upgrading method, device and equipment
CN108334401B (en) System and method for realizing logic roll dynamic distribution and supporting virtual machine dynamic migration
US11126563B1 (en) System and method for tracking changes in system memory
WO2024041351A1 (en) Disabling processor facility on new processor generation without breaking binary compatibility
US11762573B2 (en) Preserving large pages of memory across live migrations of workloads
US11734182B2 (en) Latency reduction for kernel same page merging

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination