Virtual Machine Upgrade Method, Apparatus, Device, and Storage Medium

By detecting the status of virtual machine program, modifying code and migrating data, the problem of hang in the virtual machine upgrade process is solved, unsensed hot migration and upgrade is achieved, and the processing capability and business continuity of the virtual machine are improved.

CN111352647BActive Publication Date: 2025-07-18PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010119885.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-26
Publication Date
2025-07-18
Estimated Expiration
2040-02-26

AI Technical Summary

Technical Problem

During the virtual machine upgrade process, especially during the hot migration process, due to the large disk and high fragmentation, the main process of the virtual machine is suspended, affecting the business processing capabilities. The existing solution needs to restart or shut down the virtual machine, resulting in data loss and business delay.

Method used

By detecting the status information of the virtual machine program, determining whether it is suspended, modifying the program code, adding jump functions or deleting code segments, generating a new system program, and migrating memory and disk data to the transit host without shutting down the virtual machine, realizing hot migration to the destination host and completing the upgrade.

Benefits of technology

This avoids the problem of hang in the virtual machine upgrade process, realizes unaware version upgrade, improves the virtual machine processing capability and business continuity, and avoids data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111352647B_ABST
    Figure CN111352647B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of cloud technology, and discloses a method for upgrading a virtual machine. By modifying the program code of the virtual system of the source host itself, a new system program is obtained, and the source host is upgraded based on the modified system program. During the upgrade process, the data in the memory and disk of the source host is separated and migrated through a transfer host; the present invention also provides a virtual machine upgrade device, device and computer-readable storage medium. Such an implementation method can directly upgrade the virtual system without shutting down the virtual machine, and at the same time, hot migrate the virtual machine to other hosts, avoiding possible suspension problems during the upgrade process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud technologies, and in particular, to a method, device, equipment and computer-readable storage medium for virtual machine upgrade. Background Art

[0002] In a cloud computing environment, the architecture of the virtual simulator qemu, the virtualization module kvm, and the qcow2 format disk is one of the more widely used implementation methods for implementing virtual systems. During the process of implementing virtualization using this architecture, live migration is a powerful function provided by qemu. However, during the current live migration process of implementing data migration, a bitmap is constructed to indicate whether data needs to be migrated. When constructing the bitmap, qemu first calls the format driver (qcow2 driver) to obtain the actual data allocation situation in the data area to be detected this time; when it is found that there is data allocation, the corresponding file driver (raw driver) will be called again to detect whether there is actually data in the corresponding actual area of the file. To skip the areas in the file where there is actually no writing, so as to reduce data transmission during migration. When the file driver detects whether there are holes, the lseek system call is used to determine whether there are data holes in the file.

[0003] When looking for holes, it will start from the passed-in starting position and search until a hole is found or the end of the file is reached. The length of time to enter lseek is proportional to the size of the file (that is, the disk) and the number of file fragments. That is, the larger the file and the more fragments there are, the longer the time in lseek. This results in the current live migration process staying in the lseek system call for a long time when a single virtual machine disk is very large and there are many disk fragments, causing the qemu main process to be unable to respond to other transactions. For the virtual machine, it means that the main process of the virtual machine is hung up, which can be understood as the main process of virtualization implementation entering a deep loop. This causes the system to be unable to schedule resources to implement other services, which greatly reduces the processing ability of the virtual system for services; in the current solutions, it can only be achieved by restarting the virtual machine or shutting down the virtual machine for qemu upgrade. Whether it is restarting or shutting down the virtual machine for upgrade, it will cause data loss, delay the subsequent system business processing, and affect user use. Summary of the Invention

[0004] The main purpose of the present invention is to provide a method, device, equipment and computer-readable storage medium for virtual machine upgrade, aiming to solve the technical problem that the existing virtual machines will be hung up during the upgrade process.

[0005] To achieve the above object, the present invention provides a virtual machine upgrade method, which is applied to a server. The virtual machine upgrade method includes the following steps:

[0006] Detect the status information of the virtual machine program on the source host, and determine whether to upgrade the virtual machine program according to the status information;

[0007] If so, receive the upgrade request initiated by the virtual machine, and determine the program code of the virtual machine program running on the source host. Among them, the upgrade request includes the upgrade means for the program code;

[0008] According to the upgrade means of the program code, modify the code corresponding to the suspended process in the program code, and recompile the modified program code to obtain a new system program;

[0009] Read the running memory data and disk data in the source host, migrate the running memory data to the transfer host, and share the disk data to the transfer host through network file sharing;

[0010] Migrate the running memory data to the destination host through the transfer host, and the transfer host reads the disk data on the source host through remote access and sends it to the destination host to realize the migration and preservation of all data on the source host;

[0011] Shut down the source host, and upgrade the virtual system on the source host according to the system program.

[0012] Optionally, the status information is the process status of the virtual machine program currently running;

[0013] The step of determining whether to upgrade the virtual machine program according to the status information includes:

[0014] Judge whether the process in the virtual machine program appears in a suspended state, where the suspended state is that the process stays on the same program node for no less than N times the preset execution time of the program node, and N is an integer greater than 3;

[0015] If it is judged to be in a suspended state, it is determined that the virtual machine program needs to be upgraded.

[0016] Optionally, the step of modifying the code corresponding to the suspended process in the program code according to the upgrade means of the program code, and recompiling the modified program code to obtain a new system program includes:

[0017] Detect the position of the program node corresponding to the hanging-up state in the program code, and obtain the process code segment where the program node is located according to the position;

[0018] Determine whether the process code segment belongs to the main process program of the program code;

[0019] Select a corresponding code modification strategy according to the judgment result and the upgrade means of the program code;

[0020] Upgrade the process code segment according to the code modification strategy to generate a new system program.

[0021] Optionally, the determining the corresponding code modification strategy according to the judgment result and the upgrade means of the program code includes:

[0022] If it is determined that the process code segment belongs to the main process program, the selected code modification strategy is to add a jump function;

[0023] If it is determined that the process code segment does not belong to the main process program, the selected code modification strategy is to delete the code segment.

[0024] Optionally, the upgrading the process code segment according to the code modification strategy to generate a new system program includes:

[0025] If the code modification strategy is to delete the code segment, delete the process code segment from the program code and recompile to generate the system program;

[0026] If the code modification strategy is to add a jump function, add a time judgment function after the program node where the hanging state appears in the process code segment, judge the staying time of the hanging state of the process code through the time judgment function, and recompile to generate the system program.

[0027] Optionally, when the code modification strategy is to add a jump function, the step of upgrading the process code segment according to the code modification strategy to generate a new system program further includes:

[0028] Set a program jump pointer on a program node before the process code segment where the hanging state appears, and recompile to generate the system program, where the program jump pointer is used to jump the virtual machine from the current system program to other task programs when the time judgment function determines that the staying time exceeds the preset execution duration.

[0029] Optionally, after the step of modifying the code corresponding to the suspended process in the program code according to the upgrade means of the program code and recompiling the modified program code to obtain a new system program, the method further includes:

[0030] Upgrading the virtual machine programs in the transit host and the destination host respectively according to the system program;

[0031] When the upgrades of the transit host and the destination host are completed, perform the step of migrating all the data on the source host to the destination host through the transit host.

[0032] In addition, to achieve the above object, the present invention further provides a virtual machine upgrade device, where the virtual machine upgrade device includes:

[0033] A judgment module, configured to detect the status information of the virtual machine program of the source host and judge whether to upgrade the virtual machine program according to the status information;

[0034] A reading module, configured to receive the upgrade request initiated by the virtual machine and determine the program code of the virtual machine program running on the source host when it is determined that the virtual machine program needs to be upgraded, where the upgrade request includes the upgrade means for the program code;

[0035] A compilation module, configured to modify the code corresponding to the suspended process in the program code according to the upgrade means of the program code and recompiling the modified program code to obtain a new system program;

[0036] A data sharing module, configured to read the running memory data and disk data in the source host, migrate the running memory data to the transit host, and share the disk data to the transit host through network file sharing;

[0037] A data transfer module, configured to migrate the running memory data to the destination host through the transit host, and the transit host reads the disk data on the source host through remote access and sends it to the destination host to realize the migration and preservation of all the data on the source host;

[0038] An upgrade module, configured to shut down the source host and upgrade the virtual system on the source host according to the system program.

[0039] Optionally, the status information is the process status of the currently running virtual machine program;

[0040] The determination module is used to determine whether the processes in the virtual machine program are in a suspended state, where the suspended state means that the time for the process to stay on the same program node is not less than N times the preset execution time of the program node, and N is an integer greater than 3; if it is determined to be in a suspended state, it is determined that the virtual machine program needs to be upgraded.

[0041] Optionally, the compilation module includes a code detection unit, a modification unit, and a compilation unit, where:

[0042] The code detection unit is used to detect the position of the program node corresponding to the hanging state in the program code, and obtain the process code segment where the program node is located according to the position; determine whether the process code segment belongs to the main process program of the program code;

[0043] The modification unit is used to select a corresponding code modification strategy according to the judgment result and the upgrade means of the program code;

[0044] The compilation unit is used to upgrade the process code segment according to the code modification strategy to generate a new system program.

[0045] Optionally, when the modification unit determines that the process code segment belongs to the main process program, the selected code modification strategy is to add a jump function; or when it determines that the process code segment does not belong to the main process program, the selected code modification strategy is to delete the code segment.

[0046] Optionally, when the code modification strategy is to delete the code segment, the compilation unit is used to delete the process code segment from the program code and recompile to generate the system program; or when the code modification strategy is to add a jump function, a time judgment function is added after the program node in the process code segment where the suspended state appears, and the time judgment function is used to judge the staying time of the hanging state of the process, and then recompile to generate the system program.

[0047] Optionally, when the code modification strategy is to add a jump function, the modification unit is further used to set a program jump pointer on a program node before the process code segment where the hanging state appears, and recompile to generate the system program, where the program jump pointer is used to jump the virtual machine from the current system program to other task programs for execution when the time judgment function determines that the staying time exceeds the preset execution duration.

[0048] Optionally, the upgrade module is further used to upgrade the virtual machine programs in the transit host and the destination host respectively according to the system program;

[0049] The data migration module is further configured to, after the upgrade of the relay host and the destination host is completed, perform the step of migrating all the data on the source host to the destination host through the relay host.

[0050] In addition, to achieve the above object, the present invention further provides a virtual machine upgrade device, which includes: a memory, a processor, and a virtual machine upgrade program stored on the memory and executable on the processor. When the virtual machine upgrade program is executed by the processor, the steps of the virtual machine upgrade method described in any one of the above are implemented.

[0051] In addition, to achieve the above object, the present invention further provides a computer-readable storage medium, on which a virtual machine upgrade program is stored. When the virtual machine upgrade program is executed by the processor, the steps of the virtual machine upgrade method described in any one of the above are implemented.

[0052] Through the method of the present invention, by modifying the program code of the virtual system of the source host itself, a new system program is obtained, and the source host is upgraded based on the modified system program. During the upgrade process, the data in the memory and disk parts of the source host is separately migrated through the relay host. Such an implementation method can upgrade the virtual system without shutting down the virtual machine and simultaneously hot-migrate the virtual machine to other hosts, avoiding possible hang problems during the upgrade process. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 It is a schematic structural diagram of the operating environment of the server related to the solution of the embodiment of the present invention;

[0054] Figure 2 It is a schematic flowchart of the first embodiment of the virtual machine upgrade method provided by the present invention;

[0055] Figure 3 It is a schematic flowchart of the second embodiment of the virtual machine upgrade method provided by the present invention;

[0056] Figure 4 It is a schematic flowchart of the third embodiment of the virtual machine upgrade method provided by the present invention;

[0057] Figure 5 It is a schematic diagram of data transfer during the upgrade of the source host provided by the present invention;

[0058] Figure 6 It is a schematic diagram of process code modification provided by the present invention;

[0059] Figure 7 It is a schematic diagram of process code modification provided by the present invention;

[0060] Figure 8 This is a schematic diagram of the functional modules of the virtual machine upgrade device of the present invention.

[0061] The implementation, functional features and advantages of the object of the present invention will be further described in conjunction with the embodiments and with reference to the accompanying drawings. Detailed implementation manners

[0062] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0063] The present invention provides a data synchronization device.

[0064] Referring to Figure 1 , Figure 1 This is a schematic diagram of the operating environment structure of the server involved in the embodiment solution of the present invention.

[0065] As Figure 1 shown, the server includes: a processor 101, such as a CPU, a communication bus 102, a user interface 103, a network interface 104, and a memory 105. Among them, the communication bus 102 is used to realize the connection and communication between these components. The user interface 103 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). The network interface 104 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 105 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 105 may optionally also be a storage device independent of the aforementioned processor 101.

[0066] Those skilled in the art can understand that Figure 1 the hardware structure of the server shown in

[0067] As Figure 1 shown, in the memory 105 as a computer-readable storage medium, there may be included an operating system, a network communication program module, a user interface program module, and a program for implementing the virtual machine upgrade. Among them, the operating system is a program for managing and controlling the communication between the modules in the virtual machine (source host, transit host, and destination host) and the acquisition and processing of data, and for controlling the software resource call in the memory, supporting the operation of the virtual machine upgrade program and other software and / or programs.

[0068] In Figure 1In the hardware structure of the server shown, the network interface 104 is mainly used to access the network; the user interface 103 is mainly used to check whether the system program process in the virtual machine hangs up, and the processor 101 can be used to call the virtual machine upgrade program stored in the memory 105 and execute the operations of the embodiments of the following virtual machine upgrade method.

[0069] Based on the hardware structure of the above business system, various embodiments of the configuration method of the rule call architecture system of the present invention are proposed.

[0070] Refer to Figure 2 , Figure 2 is a flowchart of the virtual machine upgrade method provided by the embodiments of the present invention. In this embodiment, the method is to determine whether the virtual machine will have a data migration hang-up. If so, the system program of the virtual machine is upgraded by modifying the program process of the data migration, so as to solve the hang-up problem. The virtual machine upgrade method specifically includes the following steps:

[0071] Step S210, detect the status information of the virtual machine program of the source and destination hosts, and determine whether to upgrade the virtual machine program according to the status information;

[0072] In this step, the status information here specifically refers to various statuses that occur when the virtual machine of the source and destination hosts is executing a process and dealing with a large amount of data. For example, the process execution is too slow, resulting in the virtual machine being hung and unable to jump out to execute other processes, or staying in the same process for a long time.

[0073] And the status information of the source and destination hosts here is to detect whether such a situation occurs in the currently executing process of the virtual machine. If it exists, execute step S220; otherwise, continue to monitor the process status.

[0074] In this embodiment, the status information further includes version information. When determining whether an upgrade is required, the total running time of the virtual machine program is specifically determined through the version information, and whether a new upgrade is required is judged according to the total running time; specifically, the total running time of the current virtual machine program is calculated through the version number in the version information and the naming rule of the version number. For example, the naming rule of the version number contains time and version number of times. In actual applications, a specified update time is set for the virtual machine program, such as an update or upgrade is required every month. Then, the total running time of the virtual machine program is calculated by combining the time in the version number with the current time, and the total running time is compared with the specified update or upgrade time. If it is greater than or equal to, it is determined that an upgrade is required; otherwise, continue to monitor.

[0075] In this embodiment, the status information is the process status of the currently running virtual machine program. At this time, this step can be implemented by judging the corresponding process status. Specifically: judge whether the process in the virtual machine program has entered a suspended state, where the suspended state means that the process stays on the same program node for no less than N times the preset execution time of the program node, and N is an integer greater than 3; if it is judged to be in a suspended state, it is determined that the virtual machine program needs to be upgraded; otherwise, there is no need to upgrade, and return to step S210 to continue monitoring the status of other processes, or end the processing flow.

[0076] In practical applications, the execution time of program code is generally set fixedly. After each piece of code finishes processing data, a rough time length is calculated based on the amount of data. Based on this time length, the actual execution time of the program node is judged, so as to determine whether an upgrade process is required, so as to achieve the effect of optimizing the virtual machine system.

[0077] Step S220, if so, receive the upgrade request initiated by the virtual machine, and determine the program code of the virtual machine program currently running on the source host, where the upgrade request includes the upgrade means for the program code;

[0078] In this embodiment, when it is detected that a process has been hung, an upgrade request is generated according to the specific process. Here, the upgrade request is mainly used to control the server to generate an upgrade package for the virtual system, specifically by modifying the program code of the virtual system according to the upgrade means required in the upgrade request.

[0079] When it is judged that the program code needs to be upgraded, an upgrade request also needs to be generated according to the specific status information. Among them, when the status information is that the main process in the program code has entered a suspended state, the process code segment is selected to be deleted and a jump function is added at the position of the suspended process node to jump the process out of the suspended state and execute other processes.

[0080] Step S230, according to the upgrade means of the program code, modify the code corresponding to the suspended process in the program code, and recompile the modified program code to obtain a new system program;

[0081] In this embodiment, modifying the program code specifically involves modifying the code corresponding to the suspended process in the program code. For example, deleting or masking the corresponding code segment from the program code. In practical applications, it can be achieved by setting a masking function for conditional judgment. For example, when it is detected that the residence time in the suspended state has exceeded 5 times the execution time of the process, then the masking function is started to mask the execution of all the code of this process, directly skipping the execution of this process, and preferably jumping to execute other processes.

[0082] Further, after the modification is completed, the program code is recompiled to obtain a new system program, which is the complete program code modified according to the above-mentioned upgrade means.

[0083] Step S240: Read the running memory data and disk data in the source host, migrate the running memory data to the intermediate host, and share the disk data to the intermediate host through network file sharing;

[0084] In this embodiment, the source host can execute a data decomposition program to distinguish the data of the memory and disk parts, separately extract the memory data and disk data, and first mount the disk data to the intermediate host through NFS, which can be understood as setting a data sharing method to achieve, and then directly migrate the memory part to the intermediate host, specifically to the virtual machine of the intermediate host.

[0085] In this step, after the memory data is migrated, the virtual machine on the source host will stop running, but the source host itself will not shut down and can still be remotely accessed through the TCP / IP protocol. Specifically, this remote access is only for accessing and reading the disk data.

[0086] Step S250: Migrate the running memory data to the destination host through the intermediate host, and the intermediate host reads the disk data on the source host through remote access and sends it to the destination host to achieve the migration and preservation of all the data on the source host;

[0087] In this embodiment, after receiving the migrated memory data, the intermediate host, according to the received migration request, re-migrates the memory data to the destination host and runs the memory data on the destination host. While the memory data is running, it requests to migrate or back up the disk data on the source host to the virtual machine on the destination host. For the migration of the disk data, specifically, the intermediate host accesses the disk of the source host through TCP / IP, reads the data file in the disk and transfers it to the disk on the destination host, thereby achieving the migration of the disk data.

[0088] Step S260, shut down the source host and upgrade the virtual system on the source host according to the system program.

[0089] In this embodiment, during the modification of the program code, it is also necessary to consider whether the suspended program code belongs to the main process part, and select the corresponding code modification method according to the importance of the process in the virtual machine program to generate a system program that meets the conditions. Specifically: for step S130, it can be implemented in the following way:

[0090] Detect the position of the program node corresponding to the hanging state in the program code, and obtain the process code segment where the program node is located according to the position.

[0091] Judge whether the process code segment belongs to the main process program of the program code.

[0092] Select the corresponding code modification strategy according to the judgment result and the upgrade means of the program code.

[0093] Upgrade the process code segment according to the code modification strategy to generate a new system program.

[0094] In this embodiment, the virtual machine upgrade method is mainly for the upgrade of the processing process of data migration in the virtual machine. In practical applications, the data migration process can be divided into two major processes. One is the annotation of the migrated data, and the other is the detection of the overall data to determine the migrated data and perform the migration process. And the second process often appears in a suspended state. For this, in this embodiment, it is possible to determine whether the main process is in a suspended state by detecting the executed detection program.

[0095] Specifically, first, after detecting that the virtual machine is in a suspended state, by detecting whether the driver program currently called by the virtual machine is a file format driver program. If so, it means that the current execution is the code flow of the main process, and determine the position of the suspended node in the main process, and select the corresponding modification method according to the code function of the node, and modify the main process based on the modification method.

[0096] In this embodiment, the determining the corresponding code modification strategy according to the judgment result and the upgrade means of the program code includes:

[0097] If it is judged that the process code segment belongs to the main process program, the selected code modification strategy is to add a jump function.

[0098] If it is judged that the process code segment does not belong to the main process program, the selected code modification strategy is to delete the code segment.

[0099] In practical applications, the modification strategy for the main process can also be to directly delete it.

[0100] In this embodiment, upgrading the process code segment according to the code modification strategy to generate a new system program includes:

[0101] If the code modification strategy is to delete the code segment, delete the process code segment from the program code and recompile to generate the system program;

[0102] If the code modification strategy is to add a jump function, add a time judgment function after the program node in the suspended state in the process code segment, judge the residence time of the suspended state of the process code through the time judgment function, and recompile to generate the system program.

[0103] In practical applications, for modifying the program code by adding a jump function, in addition to using a time judgment function, other functions can also be used, as long as they can optimize the processing flow of the process and avoid the process from being in a suspended state. For example, using a jump arrow is also possible, or even using hardware control is also possible. Of course, on the premise of using hardware, there is a hardware basis of a timer in the host. By setting the timer in the relevant process code, the timer is used to judge the execution operation of the node in the suspended state, thus solving the problem of the node staying for too long.

[0104] In this embodiment, when the code modification strategy is to add a jump function, the steps of upgrading the process code segment according to the code modification strategy to generate a new system program further include:

[0105] Set a program jump pointer on a program node before the process code segment in the suspended state and recompile to generate the system program, where the program jump pointer is used to jump the virtual machine from the current system program to other task programs when the time judgment function determines that the residence time exceeds the preset execution duration.

[0106] Furthermore, in order to optimize the problem of suspension that may also occur during data migration, in this embodiment, it also includes upgrading the virtual machine systems of the transfer host and the destination host, and the upgraded system program is exactly the one modified by the above method. Specifically: after the step of modifying the code corresponding to the suspended process in the program code according to the upgrade means of the program code and recompiling the modified program code to obtain a new system program, it further includes:

[0107] Upgrade the virtual machine programs in the transfer host and the destination host respectively according to the system program;

[0108] After the upgrade of the relay host and the destination host is completed, perform the step of migrating all the data on the source host to the destination host through the relay host.

[0109] The above solution will be described below with a specific application scenario. Taking three servers as an example, server A, server B, and server C. The three servers correspond to the source host, the relay host, and the destination host respectively, as Figure 5 shown.

[0110] In this embodiment, there are two specific ways to upgrade the system program of the virtual machine:

[0111] First, a new system program is obtained by directly deleting the process.

[0112] In practical applications, the deletion here is not the traditional deletion, but by setting a direct transfer jump instruction to mask the execution of the corresponding process, as Figure 3 shown. Its specific execution process includes:

[0113] Step S310: When qemu migrates the local disk (qcow2) for the first time, it will build a bitmap to indicate whether data needs to be migrated.

[0114] Step S320: During the process of building the bitmap, qemu first calls the corresponding format driver (qcow2 driver) to obtain the actual data allocation situation of the data area to be detected this time.

[0115] Step S330: When it is found that there is data allocation, it will call the corresponding filedriver (raw driver) again to detect whether there is actually data in the actual area corresponding to the file. To skip the areas in the file that are not actually written, so as to reduce data transmission during migration.

[0116] Step S340: When the filedriver detects whether there are holes, it calls the lseek system call to determine whether there are data holes in the file.

[0117] Step S350: Judge the length of the execution time when calling the lseek system call to determine whether there are data holes in the file.

[0118] Step S360: If it is greater than the preset value, the corresponding code segment will be obtained and directly deleted from qemu.

[0119] In this step, in the direct deletion method, the processing of the filedriver is directly skipped in the original process, as Figure 6As shown, directly skip the process within the dashed box. The process directly follows the arrow marked as 1. After determining the qcow2 driver, directly set the bitmap.

[0120] Of course, the deletion here can also be a recoverable deletion. For example, use a code shielding function to shield the code segment in the main process and add a jump arrow to skip the execution of the main process code.

[0121] Step S370: Start data migration, migrate the data on the source host to the destination host, and upgrade the qemu on the source host according to the program code after deletion.

[0122] In the virtual machine upgrade method proposed in this embodiment, it is specifically aimed at steps S320 and S330 in the above process. That is, the method provided by the present invention is used to detect the process of data migration allocation detection during the data migration of the virtual machine in server A. When the execution status of steps S320 and S330 is in a suspended state, that is, the process stays for too long, affecting the subsequent process or staying for too long and failing to jump out of steps S320 and S330 in time to execute other processes, resulting in the stagnation of the virtual machine migration.

[0123] The second method is to add a jump function. That is, when originally calling rawdriver for migration in the process, add a time judgment. When the time exceeds a certain time, switch out to execute other tasks, and then switch back to continue running after finishing other tasks. As Figure 7 shown in the process listed in the dashed box. For the execution process of qemu after adding the jump function, as Figure 3 shown, its specific process includes:

[0124] First, execute steps S410 - S450, which are the same as steps S310 - S340;

[0125] Step S450: Start the time judgment function and calculate the execution time length of the lseek system.

[0126] Step S460: If the execution time length reaches the preset value, mark the position of the process and start the virtual machine upgrade operation.

[0127] Step S470: Start data migration, migrate the data on the source host to the destination host, and upgrade the qemu on the source host according to the program code after adding the time judgment function.

[0128] In this embodiment, for the method of modifying the qemu upgrade, the specific implementation steps are as follows:

[0129] 1. First, upgrade qemu without filedriver detection on the target host server C and the transfer server B.

[0130] 2. Mount the virtual machine disk on the source host server A to the transfer server B via NFS. Use NFS migration to migrate the virtual machine from the source host server A to the transfer server B. In this process, only the memory is migrated, not the disk.

[0131] 3. Directly migrate the virtual machine from the transfer server B to the target host server C, and finally complete the migration of the virtual machine from the source host server A to the target host server C.

[0132] 4. After migrating the virtual machine on the server A, qemu on the server A can be upgraded.

[0133] Of course, the system code obtained by modifying through the above first modification method is used when upgrading qemu here.

[0134] In this embodiment, through the above two modification methods for qemu, it is possible to resolve the hang during local disk hot migration, and at the same time, it is possible to upgrade qemu without shutting down and perform hot migration of the virtual machine after modifying qemu.

[0135] To improve the optimization of the upgrade, in this embodiment, the above two methods can be used simultaneously for the upgrade. First, when it is detected that an upgrade is required, the code is modified using the first modification method based on the process code of the server A itself to obtain the upgrade code. Then, the transfer host and the destination host are upgraded according to the upgrade code. Finally, the second modification method is used to implement the data migration, migrating the data on the server A to the server C, and then upgrading the server A according to the upgrade code.

[0136] In actual application, after the upgrade is completed, the data in the server C can also be migrated back to the server A for operation by repeating the second modification method.

[0137] By modifying the processing flow of disk files during the hot migration process, reducing the raw driver judgment or adding time judgment, the hang problem during the use of the virtual machine can be effectively solved. At the same time, providing the ability to upgrade the qemu version without shutting down can effectively solve the current qemu problems.

[0138] After modifying the migration process in this way, there are the following benefits:

[0139] By modifying the processing flow of qemu, the possible hang problem during the local disk hot migration process can be solved.

[0140] After adding the step of upgrading qemu without shutting down the machine, qemu can be upgraded without shutting down the virtual machine, and at the same time, the virtual machine can be live migrated to other host machines.

[0141] The embodiments of the present invention can solve problems without the user's awareness, and at the same time achieve version upgrade, greatly improving the product competitiveness.

[0142] To solve the above problems, the embodiments of the present invention also provide a virtual machine upgrade device, as Figure 8 shown. The virtual machine upgrade device includes: a judgment module 81, a reading module 82, a compilation module 83, a data sharing module 84, a data transfer module 85, and an upgrade module 86, where

[0143] The judgment module 81 is used to detect the status information of the virtual machine program on the source host machine, and judge whether to upgrade the virtual machine program according to the status information;

[0144] The reading module 82 is used to receive the upgrade request initiated by the virtual machine when it is determined that the virtual machine program needs to be upgraded, and determine the program code of the virtual machine program running on the source host machine. Among them, the upgrade request includes the upgrade means for the program code;

[0145] The compilation module 83 is used to modify the code corresponding to the suspended process in the program code according to the upgrade means of the program code, and recompile the modified program code to obtain a new system program;

[0146] The data sharing module 84 is used to read the running memory data and disk data in the source host machine, migrate the running memory data to the transit host machine, and share the disk data to the transit host machine through network file sharing;

[0147] The data transfer module 85 is used to migrate the running memory data to the destination host machine through the transit host machine, and the transit host machine reads the disk data on the source host machine through remote access and sends it to the destination host machine to realize the migration and preservation of all data on the source host machine;

[0148] The upgrade module 86 is used to shut down the source host machine and upgrade the virtual system on the source host machine according to the system program.

[0149] In this embodiment, the status information is the process status of the current running virtual machine program;

[0150] The determination module is used to determine whether the processes in the virtual machine program are in a suspended state, where the suspended state means that the time for the process to stay on the same program node is not less than N times the preset execution time of the program node, and N is an integer greater than 3; if it is determined to be in a suspended state, it is determined that the virtual machine program needs to be upgraded.

[0151] In this embodiment, the compilation module includes a code detection unit, a modification unit, and a compilation unit, where:

[0152] The code detection unit is used to detect the position of the program node corresponding to the hanging state in the program code, and obtain the process code segment where the program node is located according to the position; determine whether the process code segment belongs to the main process program of the program code;

[0153] The modification unit is used to select a corresponding code modification strategy according to the judgment result and the upgrade means of the program code;

[0154] The compilation unit is used to upgrade the process code segment according to the code modification strategy to generate a new system program.

[0155] In this embodiment, when the modification unit determines that the process code segment belongs to the main process program, the selected code modification strategy is to add a jump function; or when it determines that the process code segment does not belong to the main process program, the selected code modification strategy is to delete the code segment.

[0156] In this embodiment, when the code modification strategy is to delete the code segment, the compilation unit is used to delete the process code segment from the program code and recompile to generate the system program; or when the code modification strategy is to add a jump function, a time judgment function is added after the program node in the process code segment where the suspended state appears, and the time judgment function is used to judge the staying time of the hanging state of the process, and then recompile to generate the system program.

[0157] In this embodiment, when the code modification strategy is to add a jump function, the modification unit is further used to set a program jump pointer on a program node before the process code segment where the hanging state appears, and recompile to generate the system program, where the program jump pointer is used to jump the virtual machine from the current system program to other task programs for execution when the time judgment function determines that the staying time exceeds the preset execution duration.

[0158] In this embodiment, the upgrade module is further used to upgrade the virtual machine programs in the transit host and the destination host respectively according to the system program;

[0159] The data migration module is further configured to, after the upgrade of the transit host and the destination host is completed, execute the step of migrating all the data on the source host to the destination host through the transit host.

[0160] Since the execution functions of this device and the corresponding execution processes of the functions are the same as the description of the virtual machine upgrade method embodiments in the above embodiments of the present invention, the embodiments of the virtual machine upgrade device in this embodiment will not be elaborated too much.

[0161] In addition, an embodiment of the present invention further provides a virtual machine upgrade device, where the virtual machine upgrade device includes: a memory, a processor, and a virtual machine upgrade program stored on the memory and executable on the processor. The method implemented when the virtual machine upgrade program is executed by the processor can refer to the various embodiments of the virtual machine upgrade method of the present invention, and thus will not be elaborated too much.

[0162] The present invention also provides a computer-readable storage medium.

[0163] In this embodiment, a virtual machine upgrade program is stored on the computer-readable storage medium. The method implemented when the virtual machine upgrade program is executed by the processor can refer to the various embodiments of the virtual machine upgrade method of the present invention, and thus will not be elaborated too much.

[0164] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM) and includes several instructions for causing a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0165] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit and scope protected by the claims of the present invention. All those equivalent structural or equivalent process transformations made by using the content of the specification and drawings of the present invention, or directly or indirectly applied to other related technical fields, fall within the protection scope of the present invention.

Claims

1. A virtual machine upgrade method, applied to a server, characterized in that The virtual machine upgrade method includes the following steps: Detect the status information of the virtual machine program on the source host, and determine whether to upgrade the virtual machine program according to the status information; If so, receive the upgrade request initiated by the virtual machine, and determine the program code of the virtual machine program that is running on the source host, where the upgrade request includes an upgrade method for the program code; According to the upgrade method of the program code, modify the code corresponding to the suspended process in the program code, and recompile the modified program code to obtain a new system program; Read the running memory data and disk data in the source host, migrate the running memory data to the transfer host, and share the disk data to the transfer host through network file sharing; Migrate the running memory data to the destination host through the transfer host, and the transfer host reads the disk data on the source host through remote access and sends it to the destination host to realize the migration and preservation of all data on the source host; Shut down the source host, and upgrade the virtual system on the source host according to the system program; The step of modifying the code corresponding to the suspended process in the program code according to the upgrade method of the program code, and recompiling the modified program code to obtain a new system program includes: Detect the position of the program node corresponding to the suspended state in the program code, and obtain the process code segment where the program node is located according to the position; Judge whether the process code segment belongs to the main process program of the program code; Select a corresponding code modification strategy according to the judgment result and the upgrade method of the program code; Upgrade the process code segment according to the code modification strategy to generate a new system program; The judgment of whether the process code segment belongs to the main process program of the program code includes: By detecting whether the driver program currently called by the virtual machine is a file format driver program, if so, it means that the code flow of the main process is currently being executed; The determination of the corresponding code modification strategy according to the judgment result and the upgrade method of the program code includes: If it is judged that the process code segment belongs to the main process program, the selected code modification strategy is to add a jump function; If it is judged that the process code segment does not belong to the main process program, the selected code modification strategy is to delete the code segment.

2. The virtual machine upgrade method according to claim 1, wherein The status information is the process status of the virtual machine program currently running. The step of determining whether to upgrade the virtual machine program according to the status information includes: Judge whether the process in the virtual machine program has a suspended state, where the suspended state means that the process stays at the same program node for no less than N times the preset execution time of the program node, and N is an integer greater than 3; If it is judged to be in a suspended state, it is determined that the virtual machine program needs to be upgraded.

3. The virtual machine upgrade method according to claim 1, characterized in that The upgrade of the process code segment according to the code modification strategy to generate a new system program includes: If the code modification policy is to delete a code segment, delete the process code segment from the program code and recompile to generate the system program; If the code modification policy is to add a jump function, add a time judgment function after the program node in the suspended state in the process code segment, judge the residence time of the suspended state of the process code segment through the time judgment function, and recompile to generate the system program.

4. The virtual machine upgrade method according to claim 3, wherein When the code modification policy is to add a jump function, the step of upgrading the process code segment according to the code modification policy to generate a new system program further includes: Set a program jump pointer on a program node before the process code segment in the suspended state, and recompile to generate the system program, where the program jump pointer is used to jump the virtual machine from the current system program to other task programs when the time judgment function determines that the residence time exceeds the preset execution duration.

5. The virtual machine upgrade method according to any one of claims 1-4, characterized in that, After the step of modifying the code corresponding to the suspended process in the program code according to the upgrade means of the program code and recompiling the modified program code to obtain a new system program, it further includes: Upgrade the virtual machine programs in the transit host and the destination host respectively according to the system program; When the upgrade of the transit host and the destination host is completed, execute the step of migrating all the data on the source host to the destination host through the transit host.

6. A virtual machine upgrade device, characterized in that The virtual machine upgrade device includes: A judgment module, configured to detect the status information of the virtual machine program of the source host and judge whether to upgrade the virtual machine program according to the status information; A reading module, configured to receive the upgrade request initiated by the virtual machine and determine the program code of the virtual machine program running on the source host when it is determined that the virtual machine program needs to be upgraded, where the upgrade request includes the upgrade means for the program code; A compilation module, configured to modify the code corresponding to the suspended process in the program code according to the upgrade means of the program code and recompile the modified program code to obtain a new system program; A data sharing module, configured to read the running memory data and disk data in the source host, migrate the running memory data to the transit host, and share the disk data to the transit host through network file sharing; A data transfer module, configured to migrate the running memory data to the destination host through the transit host, and the transit host reads the disk data on the source host through remote access and sends it to the destination host to implement the migration and preservation of all the data on the source host; An upgrade module, configured to shut down the source host and upgrade the virtual system on the source host according to the system program; A compilation module, configured to detect the position of a program node corresponding to a suspended state in the program code, and obtain the process code segment where the program node is located according to the position; determine whether the process code segment belongs to the main process program of the program code; select a corresponding code modification strategy according to the judgment result and the upgrade means of the program code; upgrade the process code segment according to the code modification strategy to generate a new system program. A compilation module, configured to detect whether the currently invoked driver by the virtual machine is a file format driver. If so, it indicates that the current code flow being executed is that of the main process. A compilation module, configured to, if it is determined that the process code segment belongs to the main process program, select the code modification strategy as adding a jump function; if it is determined that the process code segment does not belong to the main process program, select the code modification strategy as deleting the code segment.

7. A virtual machine upgrade device, characterized in that, The virtual machine upgrade device includes: a memory, a processor, and a virtual machine upgrade program stored on the memory and executable on the processor. When the virtual machine upgrade program is executed by the processor, it implements the steps of the virtual machine upgrade method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, A virtual machine upgrade program is stored on the computer-readable storage medium. When the virtual machine upgrade program is executed by the processor, it implements the steps of the virtual machine upgrade method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Java server hotfix method and system

    CN107908402A

  • Software update method, device, storage medium and equipment

    CN108121558A