Method and device for making and applying hot patch for virtual machine simulation software

By setting the checksum of the replacement function in the QEMU hot patch file, the limitation of QEMU hot patch technology in multiple version environments is solved, and the effective application in different QEMU version environments is achieved, which improves the application scope and efficiency.

CN114924742BActive Publication Date: 2025-09-16JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210542372.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-18
Publication Date
2025-09-16
Estimated Expiration
2042-05-18

AI Technical Summary

Technical Problem

The existing QEMU hot patching technology needs to ensure that the compilation environment of the running program is completely consistent with the compilation environment of the hot patch, resulting in it being unable to be effectively applied in the running environments of multiple QEMU versions.

Method used

By setting the check code of the replacement function in the hot patch file to verify the correctness of the hot patch file, the compilation environment for running QEMU and the compilation environment for making the hot patch are decoupled, and the check code of the replacement function is used to determine the correctness of the hot patch file.

Benefits of technology

On the basis of maintaining the correctness of hot patch application, the application of QEMU hot patch files in the running environments of multiple QEMU versions is realized, which improves the application scope and efficiency of QEMU hot patch.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114924742B_ABST
    Figure CN114924742B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for producing and applying a hot patch for virtual machine simulation software, and relates to the field of computer technology. A specific implementation of the hot patch production method includes: producing a hot patch intermediate file for the target version virtual machine simulation software; running the hot patch intermediate file in a production environment to determine the check code of the replacement function; obtaining the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software; using the first compilation identifier to replace the second compilation identifier in the hot patch intermediate file, and using the check code of each replacement function to update the check information in the hot patch intermediate file, to obtain the hot patch file for the target version virtual machine simulation software. This implementation method can achieve the decoupling of the compilation environment for running QEMU and the compilation environment for producing the hot patch on the basis of maintaining the correctness of the hot patch application, significantly improving the application scope and efficiency of the QEMU hot patch.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for producing and applying a hot patch for virtual machine simulation software. Background Art

[0002] QEMU is a virtual machine emulation software written by Fabrice Bellard, whose source code is distributed under the GPL license. It can be used with KVM to emulate virtual machines and is currently widely used in cloud computing scenarios. QEMU uses user-mode program patching technology for rapid online repairs. This user-mode hot patching technology verifies the correctness of the hot patch by comparing the compilation identifier (build ID) of the running program with the build in the hot patch.

[0003] Because a program's build ID is highly variable and can change with changes to the compilation environment or code, existing hotfixing techniques require that the compilation environment used to run the program be identical to the one used to create the hotfix. Hotfixing cannot be performed on QEMU programs that are already running but have inconsistent compilation environments. Summary of the Invention

[0004] In view of this, an embodiment of the present invention provides a method and device for producing and applying a hot patch for virtual machine simulation software. By setting a check code of a replacement function in the hot patch file to verify the correctness of the hot patch file, it is possible to decouple the compilation environment for running QEMU from the compilation environment for producing the hot patch on the basis of maintaining the correctness of the hot patch application, so that the QEMU hot patch file can be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch.

[0005] To achieve the above-mentioned object, according to one aspect of an embodiment of the present invention, a hot patch production method for virtual machine simulation software is provided, comprising:

[0006] Producing a hot patch intermediate file of the target version virtual machine simulation software; the hot patch intermediate file includes: a second compilation identifier of the target version virtual machine simulation software in the production environment, a replacement function of the function to be modified, and verification information of the replacement function;

[0007] Running the hot patch intermediate file in the production environment to determine a check code of the replacement function;

[0008] Obtaining a first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software;

[0009] The second compilation identifier in the hot patch intermediate file is replaced by the first compilation identifier, and the verification information in the hot patch intermediate file is updated by the verification code of each replacement function to obtain the hot patch file of the target version virtual machine simulation software.

[0010] Optionally, determining the check code of the replacement function includes: determining a sum check code of several bytes at a preset position of the replacement function, and using the sum check code as the check code of the replacement function.

[0011] Optionally, before obtaining the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software, the method further includes: creating a mapping relationship between the first compilation identifier of each version of the virtual machine simulation software in the running environment, the second compilation identifier in the production environment, and the submitted version identifier;

[0012] Obtaining the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software includes: obtaining the first compilation identifier corresponding to the submitted version identifier of the target version virtual machine simulation software from the mapping relationship.

[0013] Optionally, after obtaining the hot patch file of the target version virtual machine simulation software, the method further includes: naming the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software.

[0014] According to a second aspect of an embodiment of the present invention, a hot patch application method for virtual machine simulation software is provided, comprising:

[0015] Obtaining a hot patch file for the target version of the virtual machine simulation software according to a first compilation identifier of the target version of the virtual machine simulation software in a running environment; the hot patch file is produced using the hot patch production method provided by the first aspect of the embodiment of the present invention, and includes: a second compilation identifier of the target version of the virtual machine simulation software in a production environment, a replacement function for the function to be modified, and verification information of the replacement function;

[0016] Determine the checksum of each replacement function in the hot patch file of the target version virtual machine simulation software;

[0017] Determine whether the check code of the determined replacement function is consistent with the check code of the replacement function in the hot patch file; if so, use the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

[0018] Optionally, before obtaining the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment, the method further includes: receiving a hot patch file package formed by packaging the hot patch files of various versions of the virtual machine simulation software;

[0019] Obtaining a hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software in the running environment includes: obtaining a hot patch file corresponding to the first compilation identifier of the target version virtual machine simulation software in the running environment from the hot patch file package.

[0020] According to a third aspect of an embodiment of the present invention, a hot patch production device for virtual machine simulation software is provided, comprising:

[0021] An intermediate file production module produces a hot patch intermediate file of the target version virtual machine simulation software; the hot patch intermediate file includes: a second compilation identifier of the target version virtual machine simulation software in the production environment, a replacement function of the function to be modified, and verification information of the replacement function;

[0022] a patch information acquisition module that runs the hot patch intermediate file in the production environment to determine the check code of the replacement function; and obtains a first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software;

[0023] The patch file production module uses the first compilation identifier to replace the second compilation identifier in the hot patch intermediate file, and uses the verification code of each replacement function to update the verification information in the hot patch intermediate file to obtain the hot patch file of the target version virtual machine simulation software.

[0024] Optionally, the patch information acquisition module determines the check code of the replacement function, including: determining a sum check code of several bytes at a preset position of the replacement function, and using the sum check code as the check code of the replacement function.

[0025] Optionally, the hot patch production device further includes a mapping relationship maintenance module for creating a mapping relationship between the first compilation identifier of each version of the virtual machine simulation software in the running environment, the second compilation identifier in the production environment, and the submitted version identifier before obtaining the first compilation identifier of the target version of the virtual machine simulation software in the running environment according to the submitted version identifier of the target version of the virtual machine simulation software;

[0026] The patch information acquisition module obtains the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software, including: obtaining the first compilation identifier corresponding to the submitted version identifier of the target version virtual machine simulation software from the mapping relationship.

[0027] Optionally, the patch file making module is further configured to: after obtaining the hot patch file of the target version virtual machine simulation software, name the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software.

[0028] According to a fourth aspect of an embodiment of the present invention, a hot patch application device for virtual machine simulation software is provided, comprising:

[0029] A patch file acquisition module acquires a hot patch file of the target version virtual machine simulation software according to a first compilation identifier of the target version virtual machine simulation software in a running environment; the hot patch file is produced using the hot patch production method provided by the first aspect of the embodiment of the present invention, and includes: a second compilation identifier of the target version virtual machine simulation software in a production environment, a replacement function for the function to be modified, and verification information of the replacement function;

[0030] The patch file application module determines the verification code of each replacement function in the hot patch file of the target version virtual machine simulation software; judges whether the verification code of the determined replacement function is consistent with the verification code of the replacement function in the hot patch file; if so, uses the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

[0031] Optionally, the patch file acquisition module is further configured to: before acquiring the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment, receive a hot patch file package formed by packaging the hot patch files of various versions of the virtual machine simulation software;

[0032] The patch file acquisition module obtains the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software in the running environment, including: obtaining the hot patch file corresponding to the first compilation identifier of the target version virtual machine simulation software in the running environment from the hot patch file package.

[0033] According to a fifth aspect of an embodiment of the present invention, there is provided an electronic device for hot patch management of virtual machine simulation software, comprising:

[0034] one or more processors;

[0035] a storage device for storing one or more programs,

[0036] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first or second aspect of the embodiment of the present invention.

[0037] According to a sixth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method provided by the first or second aspect of the embodiment of the present invention is implemented.

[0038] One embodiment of the above invention has the following advantages or beneficial effects: by setting a check code of the replacement function in the hot patch file to verify the correctness of the hot patch file, it is possible to decouple the compilation environment for running QEMU from the compilation environment for making the hot patch on the basis of maintaining the correctness of the hot patch application, so that the QEMU hot patch file can be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch.

[0039] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.

[0041] Figure 1 is a schematic diagram of a system architecture for applying a hot patch production method and a hot patch application method according to an embodiment of the present invention;

[0042] Figure 2 Schematic diagram of the main process of a method for making a hot patch for virtual machine simulation software according to an embodiment of the present invention;

[0043] Figure 3 Schematic diagram of the QEMU version information table in an optional embodiment of the present invention;

[0044] Figure 4 Schematic diagram of a hot patch intermediate file in an optional embodiment of the present invention;

[0045] Figure 5 1 is a schematic diagram of calculating a check code of a replacement function in an optional embodiment of the present invention;

[0046] Figure 6 is a schematic diagram of a hot patch file in an optional embodiment of the present invention;

[0047] Figure 7 Schematic diagram of the main process of a hot patch application method for virtual machine simulation software according to an embodiment of the present invention;

[0048] Figure 8 is a schematic diagram of a hot patch application in an optional embodiment of the present invention;

[0049] Figure 9 This is a schematic diagram of the main process of applying a hot patch in an optional embodiment of the present invention;

[0050] Figure 10 Schematic diagram of main modules of a hot patch making device for virtual machine simulation software according to an embodiment of the present invention;

[0051] Figure 11 Schematic diagram of main modules of a hot patch making device for virtual machine simulation software according to an embodiment of the present invention;

[0052] Figure 12 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;

[0053] Figure 13 It is a schematic diagram of the structure of a computer system of a terminal device or server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0055] QEMU is a virtual machine emulation software developed by Fabrice Bellard and distributed under the GPL license. It can be used with KVM (a Linux kernel virtual machine, which utilizes the Linux kernel and hardware virtualization technology to implement virtual machines) to emulate virtual machines. In cloud computing scenarios, cloud service providers typically use QEMU as a hypervisor to implement system virtual machines (hereinafter referred to as VMs). QEMU is the underlying software that implements VMs, which host various customer services. To maintain service continuity in cloud computing, VMs cannot be easily restarted or shut down for maintenance. When QEMU encounters software issues or security vulnerabilities that require remediation, the VM must be repaired without shutting down. Live migration technology allows QEMU to be updated within a short period of time while the VM is suspended. However, live migration takes a long time and requires a large number of backup servers. If the server scale is large and remediation is not possible quickly, high-level security vulnerabilities pose a significant risk to the security of the VM. Therefore, rapid remediation of QEMU is essential. QEMU can use user-mode program patching technology to perform rapid online repairs. This technology can repair program functions while the program is running, and plays an important role in fixing problems and updating functions of applications that cannot be restarted during operation.

[0056] After compiling a program using a compiler, a build identifier (buildId) is generated and recorded in the program binary to uniquely identify the compilation. This buildId changes when the program source code or the compilation environment changes. Currently, user-mode hot patching technology completes program repairs in two steps. The first step is the hot patch creation process, which compares the differences between the patched (representing a program repair) file and the assembly file compiled from the source file to generate a patch file. The patch file records the program's buildId during the compilation process. The second step is the hot patch application process, which scans the running program's address space and compares the program's buildId with the buildId in the patch file to determine if the patch file is correct. If the patch file is correct, the function in the running program is replaced with the replacement function in the patch file to complete the functional update. Because the program's buildId is highly volatile and can change with changes to the compilation environment or code, existing hot patching technologies must ensure that the compilation environment used by the running program is identical to that used to create the hot patch. Based on this limitation, when making a hot patch file, it is first necessary to modify the compilation environment for running the QEMU program. Hot patch repairs cannot be performed on QEMU programs that are already running but have inconsistent environments, which limits the application scope of hot patch technology.

[0057] In some scenarios (such as public clouds), large-scale computing nodes run numerous QEMU instances. Some QEMU programs have been running for years without shutting down. As QEMU programs are updated, new versions of QEMU are added. Consequently, multiple different versions of QEMU programs are running in real-world environments, and many of these programs have not undergone compilation environment modifications. Existing user-mode hot patching technologies cannot address these situations.

[0058] In view of this, the present invention provides a complete set of QEMU hot patch production and application methods and devices, which can decouple the production environment of QEMU hot patch files from the compilation environment of the system running QEMU, and can maintain the correctness of hot patch application. Figure 1 Schematic diagram of the system architecture of the hot patch making method and hot patch application method according to the embodiment of the present invention. Figure 1 As shown, the embodiments of the present invention relate to hot patch production and hot patch application for virtual machine simulation software.

[0059] According to one aspect of an embodiment of the present invention, a hot patch production method for virtual machine simulation software is provided. Figure 2 FIG. 1 is a schematic diagram of the main process of a method for making a hot patch for virtual machine simulation software according to an embodiment of the present invention. Figure 2 As shown, the hot patch production method for virtual machine simulation software includes: step S201, step S202, step S203 and step S204.

[0060] Step S201: Create a hot patch intermediate file for the target version of QEMU.

[0061] The compilation environment of the QEMU binary file when creating a QEMU hotpatch file is not necessarily the same as the compilation environment of the QEMU binary file when running QEMU. For ease of distinction, the compilation environment of the QEMU binary file when creating a hotpatch intermediate file is called the production environment, and the compilation identifier obtained by compiling the QEMU binary file in the production environment is called the second compilation identifier. The compilation environment of the QEMU binary file when running QEMU is called the runtime environment, and the compilation identifier obtained by compiling the QEMU binary file in the runtime environment is called the first compilation identifier.

[0062] There may be multiple different versions of QEMU programs running in the operating environment, and a hot patch file can be made for each version of QEMU. In an embodiment of the present invention, in the process of making a hot patch file, a hot patch intermediate file is first made, and then some field information in the hot patch intermediate file is replaced to obtain the final hot patch file. The hot patch intermediate file of each version of QEMU is used to repair the corresponding version of QEMU. The hot patch intermediate file includes the second compilation identifier of the target version of QEMU in the production environment, the replacement function of the function to be modified, and the verification information of the replacement function. The production method of the hot patch intermediate file can be selectively determined according to the actual situation. For example, a patch file is generated by comparing the difference between the patched file and the assembly file compiled from the source file. The patch file records the second compilation identifier of the QEMU binary during the compilation process in the production environment.

[0063] Verification information refers to verification code information, which is used to verify whether the replacement function is determined. Under normal circumstances, a verification information or verification code uniquely represents a replacement function. The generation method of the verification code can be selectively set according to the actual situation, for example, the function name of the replacement function is used as the verification code. In an optional embodiment, the sum verification code (checksum, often used to verify whether two binary systems are consistent) of several bytes of the preset position of the replacement function is first determined, and the checksum is used as the verification code of the replacement function. The preset position mentioned here can be all bytes of the replacement function or part of the bytes of the replacement function, such as the first 5 or 6 bytes of the replacement function. The more bytes used to determine the verification code, the greater the probability that the determined verification code identifies the uniqueness of the function. Exemplarily, in the initial state, the verification code of the replaceable function corresponding to the function to be modified in the target version of QEMU has not yet been determined, so the verification code of the replacement function can be set to checksum_0.

[0064] Two types of QEMU binary files are involved in the QEMU hot patch production process, as follows: qemu_online.bin: the binary file corresponding to the QEMU program running on the system, and the corresponding compilation identifier buildid is recorded as buildid1; qemu_build.bin: the QEMU binary file compiled by the production environment, that is, the binary file with the patch, and the corresponding compilation identifier buildid is recorded as buildid2.

[0065] Figure 4 Schematic diagram of hot patch intermediate file in an optional embodiment of the present invention. Figure 2In the illustrated embodiment, Kpatch_make (a tool under the libcare software, used to make the original hot patch) is improved, and the checksum calculation function of the replacement function is added on the basis of the original Kpatch_make, and then the improved Kpatch_make is used to make the hot patch intermediate file. The binary file qemu_build.bin with the patch contains all the information of the functions to be modified, and Kpatch_make traverses these functions to be modified. A checksum field is added after each function, and the excess part and the normal QEMU binary information irrelevant to the patch are removed to generate the hot patch intermediate file. The composition of the hot patch intermediate file is as follows: Figure 4 As shown, it includes the second compilation identifier buildid2 of the target version QEMU in the production environment, the replacement function funcA_witch_patch of the function to be modified, and the checksum_0 of the replacement function.

[0066] The hot patch file produced by the prior art contains the program buildid, and whether it is the correct hot patch file is determined by comparing the buildid of the program with the buildid in the hot patch file. However, the buildid of the program is very changeable, so this way of judging whether the hot patch file is correct limits the application scope of the hot patch technology. In an embodiment of the present invention, the hot patch file contains a check code for the replacement function. In the initial state, the check code of the replaceable function corresponding to the function to be modified in the target version of QEMU has not yet been determined, so the check code can be set to empty or a default value (for example, 0).

[0067] By judging whether the hot patch file is correct by replacing the checksum of the function, the production environment of the QEMU hot patch file can be decoupled from the compilation environment of the QEMU running environment based on the judgment of whether the hot patch file is correct. This allows the QEMU hot patch file to be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch file.

[0068] Step S202: Run the hot patch intermediate file in a production environment to determine the check code of the replacement function.

[0069] In an optional embodiment, a checksum of the sum of several bytes at a preset position in the replacement function is first determined, and this checksum is used as the checksum for the replacement function. The preset position mentioned here can be all bytes of the replacement function, or it can be a portion of the bytes of the replacement function, such as the first 5 or 6 bytes of the function. The more bytes used to determine the checksum, the greater the probability that the determined checksum uniquely identifies the function. Figure 5Schematic diagram of calculation of check code of replacement function in optional embodiment of the present invention. Figure 5 In the illustrated embodiment, the running QEMU is obtained, and the function address provided by the hotpatch is used to calculate the sum of the first five bytes of the function within the process's address space. This sum is used as the checksum. The algorithm is as follows: checksum = buf[0] + buf[1] + buf[2] + buf[3] + buf[4], where buf is the function's first address in memory. If the hotpatch intermediate file includes multiple replacement functions, the checksum for each replacement function is determined separately according to the above steps.

[0070] Step S203 : obtaining a first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software.

[0071] Currently, QEMU uses GIT (a software version management tool) for version management. GIT is a distributed code hosting system used for the maintenance and hosting of user program code. A commitid is generated for each change submitted to GIT, and the commitid can be used to track program changes. For code running online, each version released must correspond to a modification, and each modification corresponds to this commit version identifier (commitid), so each buildid must correspond to a commitid. The version of QEMU and the commitid are in a one-to-one correspondence. If there is only one version, there will also be a buildid. The initial version is not modified and corresponds to an initial commitid. In this step, the buildid1 corresponding to buildid2 is determined by commitid, which can decouple the production environment of the QEMU hot patch file from the compilation environment of running QEMU, so that the QEMU hot patch file can be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch file.

[0072] In an optional embodiment, before obtaining the first compilation identifier of the target version virtual machine simulation software in the operating environment based on the submitted version identifier of the target version virtual machine simulation software, a mapping relationship is created between the first compilation identifier in the operating environment, the second compilation identifier in the production environment, and the submitted version identifier of each version of the virtual machine simulation software. Obtaining the first compilation identifier of the target version virtual machine simulation software in the operating environment based on the submitted version identifier of the target version virtual machine simulation software includes: obtaining the first compilation identifier corresponding to the submitted version identifier of the target version virtual machine simulation software from the mapping relationship.

[0073] For example, first collect all QEMU versions running online and extract the buildid1 of all QEMU versions. Use the existing environment to compile the corresponding QEMU binary files and extract the buildid2. Create a table of QEMU commitids and QEMU binaries (buildid.table), which records the commitids of all QEMU versions running online and the buildid1 of the corresponding QEMU binaries. Figure 3 Schematic diagram of the QEMU version information table in an optional embodiment of the present invention. Figure 3 In the qemu verison field, it represents the QEMU version, binary buildid represents the buildid1 of the QEMU binary running online, and now buildid represents the buildid2 of the binary file compiled in the existing environment. Figure 3 In the illustrated embodiment, there are five versions of QEMU running in the system, of which the first three versions are older and cannot obtain the compilation environment, so the now buildid compiled by the existing compilation environment is different from the binary buildid, and the now buildid of the last two versions is the same as the binary build.

[0074] Step S204: Replace the second compilation identifier in the hot patch intermediate file with the first compilation identifier, and update the verification information in the hot patch intermediate file with the verification code of each replacement function to obtain the hot patch file of the target version virtual machine simulation software.

[0075] For example, in Figure 4 In the hot patch intermediate file shown, the qemu buildid running online is found through build.table according to the commitid of the target version of QEMU. Specifically, the hot patch file that is finally applied is made through the following command: kpatch_make-b buildid_online-c checksum qemu_build.bin-obuildid1.kpatch. The binary file qemu_build.bin with the patch contains all the information of the function to be replaced. In this process, Kpatch_make traverses these functions and modifies the value of the corresponding field in the hot patch intermediate file by replacing the checksum of the function (there may be multiple -cc1, c2, c3), generating the following Figure 6 The hot patch file shown.

[0076] Optionally, after obtaining the hot patch file of the target version virtual machine simulation software, the method further includes: naming the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software. Exemplarily, a hot patch file starting with buildid1 of each version is generated for all versions of QEMU according to steps S201-S204.

[0077] The hot patch files of all versions of QEMU produced by the embodiment of the present invention can be packaged and applied to all online computing nodes. The hot patch files produced by the embodiment of the present invention contain a check code of the replacement function. The check code is used to verify the correctness of the hot patch file. On the basis of maintaining the correctness of the hot patch application, the compilation environment for running QEMU and the compilation environment for producing the hot patch can be decoupled. This allows the QEMU hot patch file to be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch.

[0078] According to a second aspect of an embodiment of the present invention, there is provided a method for applying a hot patch file produced by the hot patch production method according to the first aspect of the embodiment of the present invention.

[0079] Figure 7 FIG. 1 is a schematic diagram of the main process of a hot patch application method for virtual machine simulation software according to an embodiment of the present invention. Figure 7 As shown, the hot patch application method for virtual machine simulation software includes: step S701, step S702, step S703 and step S704.

[0080] Step S701: Obtain a hot patch file for the target version of the virtual machine simulation software based on the first compilation identifier of the target version of the virtual machine simulation software in the running environment. The hot patch file is produced using the hot patch production method provided by the first aspect of the present invention and includes: a second compilation identifier of the target version of the virtual machine simulation software in the production environment, a replacement function for the function to be modified, and verification information for the replacement function.

[0081] Every time a program is opened in the operating system, a process ID, or PID, is created. The QEMU process address space stores the buildID1 of the QEMU binary file. The hot patch file stores the checksum of the replacement function, the buildID1 of the QEMU binary file, and the function to be modified. In practice, you can first obtain the QEMU process PID, then scan the QEMU process address space to obtain the buildID1 of the QEMU process. Finally, use the buildID1 of the QEMU process to find the corresponding hot patch file.

[0082] In this step, a patch file acquisition request can be generated according to the buildid1 of the currently running QEMU process to query and obtain the corresponding hot patch file. Of course, before obtaining the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment, a hot patch file package formed by packaging the hot patch files of each version of the virtual machine simulation software can be received. Obtaining the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment includes: obtaining the hot patch file corresponding to the first compilation identifier of the target version of the virtual machine simulation software in the running environment from the hot patch file package.

[0083] For example, each QEMU version's hotfix file is named starting with its corresponding buildid1. After all QEMU versions' hotfix files are packaged and applied to all online computing nodes, each computing node first obtains the PID of the QEMU process running on it, then scans the QEMU process address space to obtain the buildid1 of the QEMU process, and finally searches for the hotfix file named with its corresponding buildid1 in the hotfix file package.

[0084] Step S702: Determine the checksum of each replacement function in the hot patch file of the target version virtual machine simulation software. The specific implementation of this step is similar to that of step S203 and will not be repeated here.

[0085] Step S703: Determine whether the checksum of the determined replacement function is consistent with the checksum of the replacement function in the hot patch file. If so, jump to step S704 and use the replacement function in the hot patch file to replace the corresponding replacement function in the target version of the virtual machine simulation software; otherwise, the process ends.

[0086] Figure 8 FIG. 1 is a schematic diagram of a hot patch application in an optional embodiment of the present invention. Figure 8 As shown in the figure, the hot patch application process mainly includes the following parts:

[0087] 1. The QEMU binary buildid1 is saved in the QEMU process address space.

[0088] 2. The hot patch file contains the checksum of the replaced function, the buildid1 of the QEMU binary file, and the function to be modified.

[0089] 3. Find the corresponding hot patch file through buildid1 in the QEMU address space.

[0090] 4. Determine the correctness of the hot patch file by calculating the checksum of the replacement function and comparing it with the checksum in the hot patch file.

[0091] 5. After the checksum verification is passed, the function is replaced: add a jump instruction at the beginning of the original function to be modified. When the program runs to this point, it jumps to the new replacement function to run.

[0092] Figure 9 This is a schematic diagram of the main process of hot patch application in an optional embodiment of the present invention. Figure 9 As shown, the main process includes:

[0093] Traverse the running QEMU process and obtain the PID of the QEMU process. Get the corresponding buildid1 according to the PID of the QEMU process. Determine whether there is a match with buildid1 in the hotpatch (hot patch file) list. If there is a hotpatch matching buildid1 in the hotpatch list, load the matched hot patch file into the process address space, calculate the checksum based on the replacement function address, and compare the calculated checksum with the checksum in the matching hotpatch. If they are the same, it means that the replacement function is consistent, and the function is replaced; if they are different, it means that the versions are different, terminate the hot patch process of the current QEMU process, and traverse the next QEMU process. If there is no hotpatch matching buildid1 in the hotpatch list, it means that the versions are different, terminate the hot patch process of the current QEMU process, and traverse the next QEMU process.

[0094] The buildid in the hot patch file is the same as the buildid when QEMU is running, which only indicates that the running QEMU and the hot patch file are compiled and generated under the same code modification (commitid), and does not mean that the hot patch can be correctly applied. If the compilation environment for running QEMU is different from the compilation environment for generating the hot patch, address offset is likely to occur. If the address offset is not processed, the wrong function will be replaced. This replacement function error will cause the program to crash. In the embodiment of the present invention, the checksum of the replacement function is used to determine whether the hot patch file is correct. On the basis of avoiding the above problems, the compilation environment for running QEMU and the compilation environment for making the hot patch can be decoupled, so that the QEMU hot patch file can be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch.

[0095] According to a third aspect of the embodiments of the present invention, there is provided an apparatus for implementing the thermal patch manufacturing method according to the first aspect of the embodiments of the present invention.

[0096] Figure 10 FIG. 1 is a schematic diagram of the main modules of the hot patch making device for virtual machine simulation software according to an embodiment of the present invention. Figure 10 As shown, a hot patch making device 1000 for virtual machine simulation software includes:

[0097] The intermediate file production module 1001 produces a hot patch intermediate file of the target version virtual machine simulation software; the hot patch intermediate file includes: a second compilation identifier of the target version virtual machine simulation software in the production environment, a replacement function for the function to be modified, and verification information of the replacement function;

[0098] The patch information acquisition module 1002 runs the hot patch intermediate file in the production environment to determine the check code of the replacement function; obtains the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software;

[0099] The patch file production module 1003 uses the first compilation identifier to replace the second compilation identifier in the hot patch intermediate file, and uses the verification code of each replacement function to update the verification information in the hot patch intermediate file to obtain the hot patch file of the target version virtual machine simulation software.

[0100] Optionally, the patch information acquisition module determines the check code of the replacement function, including: determining a sum check code of several bytes at a preset position of the replacement function, and using the sum check code as the check code of the replacement function.

[0101] Optionally, the hot patch production device further includes a mapping relationship maintenance module for creating a mapping relationship between the first compilation identifier of each version of the virtual machine simulation software in the running environment, the second compilation identifier in the production environment, and the submitted version identifier before obtaining the first compilation identifier of the target version of the virtual machine simulation software in the running environment according to the submitted version identifier of the target version of the virtual machine simulation software;

[0102] The patch information acquisition module obtains the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software, including: obtaining the first compilation identifier corresponding to the submitted version identifier of the target version virtual machine simulation software from the mapping relationship.

[0103] Optionally, the patch file making module is further configured to: after obtaining the hot patch file of the target version virtual machine simulation software, name the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software.

[0104] According to a fourth aspect of an embodiment of the present invention, there is provided an apparatus for implementing the hot patch application method according to the second aspect of an embodiment of the present invention.

[0105] Figure 11 FIG. 1 is a schematic diagram of the main modules of the hot patch making device for virtual machine simulation software according to an embodiment of the present invention. Figure 11 As shown, the hot patch application device 1100 for virtual machine simulation software includes:

[0106] The patch file acquisition module 1101 acquires a hot patch file of the target version of the virtual machine simulation software based on the first compilation identifier of the target version of the virtual machine simulation software in the running environment; the hot patch file is produced using the hot patch production method provided by the first aspect of the embodiment of the present invention, and includes: the second compilation identifier of the target version of the virtual machine simulation software in the production environment, a replacement function for the function to be modified, and verification information of the replacement function;

[0107] The patch file application module 1102 determines the verification code of each replacement function in the hot patch file of the target version virtual machine simulation software; determines whether the verification code of the determined replacement function is consistent with the verification code of the replacement function in the hot patch file; if so, uses the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

[0108] Optionally, the patch file acquisition module is further configured to: before acquiring the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment, receive a hot patch file package formed by packaging the hot patch files of various versions of the virtual machine simulation software;

[0109] The patch file acquisition module obtains the hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software in the running environment, including: obtaining the hot patch file corresponding to the first compilation identifier of the target version virtual machine simulation software in the running environment from the hot patch file package.

[0110] According to a fifth aspect of an embodiment of the present invention, there is provided an electronic device for hot patch management of virtual machine simulation software, comprising:

[0111] one or more processors;

[0112] a storage device for storing one or more programs,

[0113] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first or second aspect of the embodiment of the present invention.

[0114] According to a sixth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method provided by the first or second aspect of the embodiment of the present invention is implemented.

[0115] Figure 12 An exemplary system architecture 1200 is shown to which the method or apparatus for making or applying a hot patch for virtual machine simulation software according to an embodiment of the present invention may be applied.

[0116] like Figure 12 As shown, system architecture 1200 may include terminal devices 1201, 1202, and 1203, a network 1204, and a server 1205. Network 1204 is used to provide a medium for communication links between terminal devices 1201, 1202, and 1203 and server 1205. Network 1204 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0117] Users can use terminal devices 1201, 1202, and 1203 to interact with server 1205 via network 1204 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1201, 1202, and 1203, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0118] The terminal devices 1201 , 1202 , and 1203 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0119] Server 1205 may be a server that provides various services, such as a backend management server (for example only) that supports shopping websites browsed by users using terminal devices 1201, 1202, and 1203. The backend management server may analyze and process received data such as product information query requests, and feed back processing results (for example, targeted push information and product information—for example only) to the terminal device.

[0120] It should be noted that the hot patch production method for virtual machine simulation software provided in the embodiment of the present invention is generally executed by server 1205, and accordingly, the hot patch production device for virtual machine simulation software is generally set in server 1205; the hot patch application method for virtual machine simulation software provided in the embodiment of the present invention is generally executed by terminal devices 1201, 1202, and 1203, and accordingly, the hot patch application device for virtual machine simulation software is generally set in terminal devices 1201, 1202, and 1203.

[0121] It should be understood that Figure 12 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0122] Reference below Figure 13 , which shows a schematic structural diagram of a computer system 1300 of a terminal device suitable for implementing an embodiment of the present invention. Figure 13 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0123] like Figure 13 As shown, the computer system 1300 includes a central processing unit (CPU) 1301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1302 or a program loaded from a storage unit 1308 into a random access memory (RAM) 1303. Various programs and data required for the operation of the system 1300 are also stored in the RAM 1303. The CPU 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0124] The following components are connected to the I / O interface 1305: an input section 1306 including a keyboard, a mouse, and the like; an output section 1307 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1308 including a hard disk; and a communication section 1309 including a network interface card such as a LAN card or a modem. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to the I / O interface 1305 as needed. Removable media 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1310 as needed, so that computer programs read therefrom can be installed into the storage section 1308 as needed.

[0125] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1309, and / or installed from a removable medium 1311. When the computer program is executed by the central processing unit (CPU) 1301, the above-mentioned functions defined in the system of the present invention are performed.

[0126] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.

[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0128] The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The modules described may also be provided in a processor. For example, they may be described as: a processor including an intermediate file production module, a patch information acquisition module, and a patch file production module, or a processor including a patch file acquisition module and a patch file application module. The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, the patch file production module may also be described as a "module for producing hot patch intermediate files for the target version of the virtual machine simulation software."

[0129] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiments, or may exist independently without being incorporated into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes:

[0130] Prepare a hot patch intermediate file of the target version virtual machine simulation software; the hot patch intermediate file includes: the second compilation identifier of the target version virtual machine simulation software in the production environment, the replacement function of the function to be modified, and the verification information of the replacement function; run the hot patch intermediate file in the production environment to determine the verification code of the replacement function; obtain the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software; use the first compilation identifier to replace the second compilation identifier in the hot patch intermediate file, and use the verification code of each replacement function to update the verification information in the hot patch intermediate file to obtain the hot patch file of the target version virtual machine simulation software; or,

[0131] A hot patch file of the target version virtual machine simulation software is obtained according to the first compilation identifier of the target version virtual machine simulation software in the running environment; the hot patch file is produced by the hot patch production method of the first aspect of the embodiment of the present invention, including: the second compilation identifier of the target version virtual machine simulation software in the production environment, the replacement function of the function to be modified, and the verification information of the replacement function; determining the verification code of each replacement function in the hot patch file of the target version virtual machine simulation software; judging whether the verification code of the determined replacement function is consistent with the verification code of the replacement function in the hot patch file; if so, using the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

[0132] According to the technical solution of an embodiment of the present invention, by setting a check code of the replacement function in the hot patch file to verify the correctness of the hot patch file, it is possible to decouple the compilation environment for running QEMU from the compilation environment for making the hot patch on the basis of maintaining the correctness of the hot patch application, so that the QEMU hot patch file can be applied to the situation where there are multiple QEMU versions in the running environment, significantly improving the application scope and efficiency of the QEMU hot patch.

[0133] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for making a hot patch for virtual machine simulation software, characterized in that: include: Create hot patch intermediate files for the target version of virtual machine simulation software; The hot patch intermediate file includes: a second compilation identifier of the target version virtual machine simulation software in a production environment, a replacement function of the function to be modified, and verification information of the replacement function; the compilation identifier obtained by compiling the target version virtual machine simulation software binary file in the production environment is called the second compilation identifier; Running the hot patch intermediate file in the production environment to determine a check code of the replacement function; Obtaining a first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software; the compilation identifier obtained by compiling the target version virtual machine simulation software binary file in the running environment is referred to as the first compilation identifier; The second compilation identifier in the hot patch intermediate file is replaced by the first compilation identifier, and the verification information in the hot patch intermediate file is updated by the verification code of each replacement function to obtain the hot patch file of the target version virtual machine simulation software.

2. The method according to claim 1, wherein Determining a check code of the replacement function includes: A sum check code of several bytes at a preset position of the replacement function is determined, and the sum check code is used as a check code of the replacement function.

3. The method according to claim 1, wherein Before obtaining the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software, the method further includes: creating a mapping relationship between the first compilation identifier of each version of the virtual machine simulation software in the running environment, the second compilation identifier in the production environment, and the submitted version identifier; Obtaining the first compilation identifier of the target version virtual machine simulation software in the running environment according to the submitted version identifier of the target version virtual machine simulation software includes: obtaining the first compilation identifier corresponding to the submitted version identifier of the target version virtual machine simulation software from the mapping relationship.

4. The method according to claim 1, wherein After obtaining the hot patch file of the target version of the virtual machine simulation software, the method further includes: The hot patch file of the target version virtual machine simulation software is named according to the first compilation identifier of the target version virtual machine simulation software.

5. A hot patch application method for virtual machine simulation software, characterized in that: include: Obtaining a hot patch file of the target version of the virtual machine simulation software according to a first compilation identifier of the target version of the virtual machine simulation software in the running environment; The hot patch file is produced by the method according to any one of claims 1 to 4, and includes: a first compilation identifier of the target version virtual machine simulation software in the running environment, a replacement function of the function to be modified, and a check code of the replacement function; Determine the checksum of each replacement function in the hot patch file of the target version virtual machine simulation software; Determine whether the check code of the determined replacement function is consistent with the check code of the replacement function in the hot patch file; if so, use the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

6. The method according to claim 5, wherein Before obtaining the hot patch file of the target version of the virtual machine simulation software according to the first compilation identifier of the target version of the virtual machine simulation software in the running environment, the method further includes: receiving a hot patch file package formed by packaging the hot patch files of various versions of the virtual machine simulation software; Obtaining a hot patch file of the target version virtual machine simulation software according to the first compilation identifier of the target version virtual machine simulation software in the running environment includes: obtaining a hot patch file corresponding to the first compilation identifier of the target version virtual machine simulation software in the running environment from the hot patch file package.

7. A hot patch making device for virtual machine simulation software, characterized in that: include: An intermediate file production module is used to produce hot patch intermediate files for the target version of the virtual machine simulation software; The hot patch intermediate file includes: a second compilation identifier of the target version virtual machine simulation software in a production environment, a replacement function of the function to be modified, and verification information of the replacement function; the compilation identifier obtained by compiling the target version virtual machine simulation software binary file in the production environment is called the second compilation identifier; a patch information acquisition module that runs the hot patch intermediate file in the production environment to determine the checksum of the replacement function; obtains a first compilation identifier of the target version virtual machine simulation software in the running environment based on the submitted version identifier of the target version virtual machine simulation software; the compilation identifier obtained by compiling the target version virtual machine simulation software binary file in the running environment is referred to as the first compilation identifier; The patch file production module uses the first compilation identifier to replace the second compilation identifier in the hot patch intermediate file, and uses the verification code of each replacement function to update the verification information in the hot patch intermediate file to obtain the hot patch file of the target version virtual machine simulation software.

8. A hot patch application device for virtual machine simulation software, characterized in that: include: a patch file acquisition module for acquiring a hot patch file of the target version of the virtual machine simulation software according to a first compilation identifier of the target version of the virtual machine simulation software in the running environment; The hot patch file is produced by the method according to any one of claims 1 to 4, and includes: a first compilation identifier of the target version virtual machine simulation software in the running environment, a replacement function of the function to be modified, and a check code of the replacement function; The patch file application module determines the verification code of each replacement function in the hot patch file of the target version virtual machine simulation software; judges whether the verification code of the determined replacement function is consistent with the verification code of the replacement function in the hot patch file; if so, uses the replacement function in the hot patch file to replace the corresponding replacement function in the target version virtual machine simulation software.

9. An electronic device for hot patch management of virtual machine simulation software, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

10. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Compiled file updating method and device, server and storage medium

    CN113157296A

  • Custom code transformations during compilation process

    US10698668B1