A method and device for hot upgrading a virtual machine
By creating child processes, saving device status and establishing network virtual protocol negotiation channels during the hot upgrade of virtual machines, the problem of unrecoverable network virtual devices after hot upgrade of virtual machines is solved, business interruption time is optimized and risks are reduced.
Patent Information
- Application Number
- CN202211718890.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-12-30
AI Technical Summary
The existing technology cannot effectively restore the operation of the network virtual device during hot upgrade of the virtual machine, causing the network card to fail to work normally or even crash.
By creating a sub-process in the current process of the virtual machine, the virtual machine is controlled to pause and run, the device status information is saved, the network virtual protocol negotiation channel is established, the network virtual device is initialized and renegotiated, and the saved device status information is loaded to ensure that the virtual machine is hot. It can be restored normally after the upgrade.
Optimizes the business interruption time caused by network virtual device interruption during the hot upgrade process, implements network virtual device rollback after hot upgrade failure, and reduces risks to customer businesses.
Smart Images

Figure CN115774601B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of software development technology, and in particular, relates to a method and device for hot upgrading a virtual machine. Background Art
[0002] The running virtual machine consists of a user-mode virtualization environment and a kernel-mode virtualization environment. When upgrading the virtualization environment version, the usual practice is to cold restart the virtual machine or hot migrate. Among them, the cold restart virtual machine technology will cause business interruption; hot migration technology can achieve less business interruption time, but it needs to occupy network bandwidth and the operation crosses nodes, the steps are more complicated, and the rollback and problem location after failure are more complicated. The above traditional upgrade methods will affect the user experience and service quality of the cloud host.
[0003] Hot upgrade technology can solve the above-mentioned problem. The rollback hot upgrade can complete the update of the virtual machine environment without the virtual machine user's awareness. If the upgrade fails, it can be rolled back in time and restored to the original virtualization environment. However, in the existing technology, when performing hot upgrades on virtual machines configured with network virtual devices (i.e., vhost devices), the virtualization environment can only save the device status of part of the network virtual device, so it is impossible to restore the operation of the network virtual device after loading the new virtualization environment. This causes the network card to not work properly after the virtual machine is hot upgraded, and even crashes in severe cases. Summary of the invention
[0004] In order to solve the above-mentioned problem that the virtualization environment can only save the device status of part of the network virtual device, and therefore cannot restore the operation of the network virtual device after loading the new virtualization environment, which leads to the technical defects that the network card cannot work normally after the virtual machine is hot-upgraded, and even crashes in severe cases, a method and device for hot-upgrading a virtual machine are proposed, and the technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a method for hot upgrading a virtual machine, comprising:
[0006] When the upgrade action of the virtual machine is detected, a child process is created in the current process of the virtual machine, and the virtual machine is controlled to be in a suspended state;
[0007] Saving the device status information of the virtual machine in the current virtualization environment to a preset path, and saving the device status information of the network virtual device based on the first virtualization software;
[0008] Sending a renegotiation request of a network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software;
[0009] In the child process, a target virtualization environment of the virtual machine is loaded according to the target binary program, and the network virtual device is initialized based on the target virtualization environment of the virtual machine;
[0010] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0011] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, the device status information of the virtual machine in the current virtualization environment saved in the preset path is loaded, and the device status information of the network virtual device is loaded.
[0012] In an optional solution of the first aspect, after loading the target virtualization environment of the virtual machine according to the target binary program in the child process, the method further includes:
[0013] When it is detected that the target virtualization environment of the virtual machine fails to load, the network virtual device is initialized based on the current virtualization environment of the virtual machine;
[0014] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0015] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0016] In another optional solution of the first aspect, sending a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software includes:
[0017] When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software;
[0018] When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring the network virtual protocol negotiation path at a preset time interval to see whether the path state is restored;
[0019] When it is determined that the network virtual protocol negotiation path is restored to the path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
[0020] In another optional solution of the first aspect, after saving the device state information of the network virtual device based on the first virtualization software, and before sending the renegotiation request of the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine, the method further includes:
[0021] The first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path;
[0022] The uninstall data information is processed based on the second virtualization software.
[0023] In another optional solution of the first aspect, the first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path, including:
[0024] When it is detected that the type of the network virtual device is the second type, adding a renegotiation request for the network virtual device in a designated field in the uninstall data information;
[0025] The first virtualization software sends the uninstallation data information with the re-negotiation request of the network virtual device added to the second virtualization software through the network virtual protocol negotiation path.
[0026] In another optional solution of the first aspect, after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved in the preset path, and loading the device status information of the network virtual device, it also includes:
[0027] Based on the target virtualization environment of the virtual machine, control the virtual machine to resume from a suspended running state to a running state.
[0028] In yet another optional solution of the first aspect, after creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended running state, the method further includes:
[0029] Share the memory corresponding to the current process of the virtual machine with the child process.
[0030] In a second aspect, an embodiment of the present application provides a device for hot upgrading a virtual machine, including:
[0031] The first processing module is used to create a subprocess in the current process of the virtual machine and control the virtual machine to be in a suspended state when an upgrade action of the virtual machine is detected;
[0032] An information saving module, used to save the device status information of the virtual machine in the current virtualization environment to a preset path, and save the device status information of the network virtual device based on the first virtualization software;
[0033] A first request module is used to send a renegotiation request of a network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software;
[0034] A second processing module is used to load the target virtualization environment of the virtual machine according to the target binary program in the subprocess, and initialize the network virtual device based on the target virtualization environment of the virtual machine;
[0035] A second request module, configured to send a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software after the network virtual device completes initialization;
[0036] An information loading module is used to load the device status information of the virtual machine in the current virtualization environment saved in a preset path after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, and load the device status information of the network virtual device.
[0037] In an optional solution of the second aspect, the device further includes:
[0038] After loading the target virtualization environment of the virtual machine according to the target binary program in the child process,
[0039] When it is detected that the target virtualization environment of the virtual machine fails to load, the network virtual device is initialized based on the current virtualization environment of the virtual machine;
[0040] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0041] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0042] In yet another optional solution of the second aspect, the second request module includes:
[0043] When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software;
[0044] When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring the network virtual protocol negotiation path at a preset time interval to see whether the path state is restored;
[0045] When it is determined that the network virtual protocol negotiation path is restored to the path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
[0046] In yet another optional solution of the second aspect, the device further comprises:
[0047] After the device state information of the network virtual device is saved based on the first virtualization software, and before a renegotiation request of the network virtual device is sent to the second virtualization software based on the current virtualization environment of the virtual machine,
[0048] The first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path;
[0049] The uninstall data information is processed based on the second virtualization software.
[0050] In yet another optional solution of the second aspect, the device further comprises:
[0051] When it is detected that the type of the network virtual device is the second type, adding a renegotiation request for the network virtual device in a designated field in the uninstall data information;
[0052] The first virtualization software sends the uninstallation data information with the re-negotiation request of the network virtual device added to the second virtualization software through the network virtual protocol negotiation path.
[0053] In yet another optional solution of the second aspect, the device further comprises:
[0054] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved to the preset path, and loading the device status information of the network virtual device,
[0055] Based on the target virtualization environment of the virtual machine, control the virtual machine to resume from a suspended running state to a running state.
[0056] In yet another optional solution of the second aspect, the device further comprises:
[0057] After creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended state,
[0058] Share the memory corresponding to the current process of the virtual machine with the child process.
[0059] In a third aspect, an embodiment of the present application further provides a device for hot upgrading a virtual machine, including a processor and a memory;
[0060] The processor is connected to the memory;
[0061] A memory for storing executable program codes;
[0062] The processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the method for hot upgrading of the virtual machine provided by the first aspect of the embodiment of the present application or any one of the implementation methods of the first aspect.
[0063] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the method for hot upgrading a virtual machine provided by the first aspect of the embodiment of the present application or any one of the implementation methods of the first aspect can be implemented.
[0064] In an embodiment of the present application, when a virtual machine is hot-upgraded, when an upgrade action of the virtual machine is detected, a sub-process is created in the current process of the virtual machine, and the virtual machine is controlled to be in a suspended state; the device status information of the virtual machine in the current virtualization environment is saved to a preset path, and the device status information of the network virtual device is saved based on the first virtualization software; a renegotiation request of the network virtual device is sent to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software; in the sub-process, the target virtualization environment of the virtual machine is loaded according to the target binary program, and the network virtual device is initialized based on the target virtualization environment of the virtual machine; after the network virtual device is initialized, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software; after the network virtual protocol negotiation between the first virtualization software and the second virtualization software is completed in the target virtualization environment of the virtual machine, the device status information of the virtual machine in the current virtualization environment saved in the preset path is loaded, and the device status information of the network virtual device is loaded. By introducing the network virtual protocol renegotiation mechanism, not only the service interruption time caused by the interruption of network virtual devices during the hot upgrade process is optimized, but also the rollback of network virtual devices after the hot upgrade fails is realized based on the renegotiation mechanism. The hot-upgraded network virtual device can be rolled back to the state before the upgrade, greatly reducing the risk of hot upgrade affecting customer business. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 An overall flow chart of a method for hot upgrading a virtual machine provided in an embodiment of the present application;
[0067] Figure 2 A schematic diagram of the system structure of a method for hot upgrading a virtual machine provided in an embodiment of the present application;
[0068] Figure 3 A schematic diagram of the structure of a device for hot upgrading a virtual machine provided in an embodiment of the present application;
[0069] Figure 4 A schematic diagram of the structure of another device for hot upgrading a virtual machine provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0071] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application, and different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments recorded. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, although the embodiment may not be clearly recorded in the following text.
[0072] The following description provides examples and does not limit the scope, applicability or examples set forth in the claims. Changes may be made to the functions and arrangements of the elements described without departing from the scope of the present application. Various processes or components may be appropriately omitted, substituted or added to each example. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted or combined. In addition, features described in some examples may be combined in other examples.
[0073] In the existing technology, for network virtual devices (i.e., vhost devices), they are naturally divided into two parts during design and implementation. One part can be understood as the first virtualization software (i.e., corresponding to the master end), which is responsible for the initialization of the virtio queue and the transmission of the necessary information for unloading the virtio data plane; the other part can be understood as the second virtualization software (i.e., corresponding to the slave end), which is used to receive the necessary information for unloading the virtio data plane transmitted by the first virtualization software and realize the unloading of data on the virtio queue. However, when the virtual machine configured with the network virtual device is hot-upgraded, the virtualization environment of the virtual machine can only save the device status corresponding to the master end of the network virtual device, so it is impossible to restore the operation of the vhost device after loading the new virtualization environment, which causes the network card to fail to work properly after the virtual machine is hot-upgraded, and even crashes in severe cases.
[0074] Next, the present application will be combined with one or more embodiments to solve the above-mentioned technical defects.
[0075] See also Figure 1 , Figure 1 An overall flow chart of a method for hot upgrading a virtual machine provided in an embodiment of the present application is shown.
[0076] like Figure 1 As shown, the method for hot upgrading a virtual machine may at least include the following steps:
[0077] Step 102: When an upgrade action of the virtual machine is detected, a child process is created in the current process of the virtual machine, and the virtual machine is controlled to be in a suspended state.
[0078] Specifically, when a virtual machine configured with a network virtual device is hot-upgraded, when the upgrade action of the virtual machine is detected, it indicates that the virtual machine needs to upgrade the current virtualization environment, and then a sub-process for loading the target virtualization environment can be created in the current process of the virtual machine, and the virtual machine is controlled to be converted from the running state to the suspended running state at this time. Among them, the created sub-process can be, but is not limited to, executing the binary file corresponding to the target virtualization environment, and based on the target virtualization environment created by the sub-process, the running state of the virtual machine composed of the target virtualization environment can be restored.
[0079] As an option of the embodiment of the present application, after creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended running state, the method further includes:
[0080] Share the memory corresponding to the current process of the virtual machine with the child process.
[0081] Specifically, after creating a child process in the current process of the virtual machine, in order to ensure the stable operation of the child process, the memory corresponding to the current process of the virtual machine can also be shared with the child process, so that the child process can execute the binary file corresponding to the target virtualization environment under the shared memory.
[0082] Step 104: Save the device status information of the virtual machine in the current virtualization environment to a preset path, and save the device status information of the network virtual device based on the first virtualization software.
[0083] Specifically, after the control virtual machine is in a suspended state, the device status information of the virtual machine in the current virtualization environment can be saved to a preset path. The preset path can be but is not limited to a specified memory or disk. At the same time, the first virtualization software can also save the device status information of the network virtual device to facilitate the subsequent reloading of the device status information of the virtual machine in the current virtualization environment in the target virtualization environment, as well as the reloading of the device status information of the network virtual device.
[0084] Among them, the first virtualization software can correspond to a network virtual device, that is, the first virtualization software can be but is not limited to being understood as the master end of the network virtual device, and the device status information of the network virtual device saved by the master end is essentially the status information required to simulate the network virtual device.
[0085] Step 106: Send a re-negotiation request for the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine.
[0086] Specifically, after saving the device status information of the virtual machine in the current virtualization environment and the device status information of the network virtual device, a renegotiation request for the network virtual device can be sent to the second virtualization software based on the current virtualization environment of the virtual machine, wherein the second virtualization software can correspond to the network virtual device, that is, the second virtualization software can be but is not limited to being understood as the slave end of the network virtual device, and the slave end of the network virtual device is added with a renegotiation function of the network virtual protocol to facilitate receiving the renegotiation request of the network virtual device.
[0087] Here, before receiving the renegotiation request of the network virtual device, the slave end of the network virtual device can receive the uninstall data information transmitted by the master end of the network virtual device through the network virtual protocol negotiation path, and the uninstall data information corresponds to the necessary information for the virtio data plane uninstall, and the uninstall data information can be processed, for example but not limited to processing the data of the virtio queue data plane. It should be noted that the uninstall data information here can ensure that the virtio data plane uninstall function of the network virtual device can work normally, and in the embodiment of the present application, the uninstall data information is not saved, and only needs to be collected before the first virtualization software and the second virtualization software perform network virtual protocol negotiation.
[0088] It can also be understood that in the embodiment of the present application, the current virtualization environment of the virtual machine can be but is not limited to running in the first virtualization software, that is, the first virtualization software can load the current virtualization environment of the virtual machine according to the device status information of the virtual machine in the current virtualization environment, and the first virtualization software sends a renegotiation request for the network virtual device to the second virtualization software, and is not limited to this.
[0089] As another optional embodiment of the present application, when it is detected that the type of the network virtual device is the second type, the second type can be but is not limited to a non-connected network virtual negotiation path (that is, a non-connected network virtual negotiation path is established between the first virtualization software and the second virtualization software), and a renegotiation request for the network virtual device can be added at the specified field in the above-mentioned uninstall data information, so that after the second virtualization software receives the renegotiation request of the added network virtual device, it can periodically send a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software after the network virtual device completes initialization. For example, taking the second type of network virtual device as a vhost-net or vhost-vdpa device based on a system call as an example, a renegotiation request for the network virtual device can be added to the request field in the uninstall data information, and after the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device can be periodically sent to the first virtualization software.
[0090] Step 108: In the subprocess, the target virtualization environment of the virtual machine is loaded according to the target binary program, and the network virtual device is initialized based on the target virtualization environment of the virtual machine.
[0091] Specifically, before sending a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software, the target binary program can be run in the sub-process to load the target virtualization environment of the corresponding virtual machine, and the network virtual device can be reset and initialized under the target virtualization environment of the virtual machine, so that after the network virtual device completes the initialization, the first virtualization software can respond to the network virtual protocol negotiation request and quickly complete the network virtual protocol negotiation with the second virtualization software.
[0092] Step 110: After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
[0093] Specifically, after the network virtual device completes initialization, the type of the network virtual device can also be determined. When it is detected that the type of the network virtual device is the first type, the first type can be, but is not limited to, a network virtual negotiation path based on a socket connection (that is, a network virtual negotiation path based on a socket connection is established between the first virtualization software and the second virtualization software). The second virtualization software determines whether the network virtual negotiation path is disconnected. It can be understood that when the network virtual negotiation path based on the socket connection is implemented, the first virtualization software will actively disconnect the network virtual negotiation path between the first virtualization software and the second virtualization software. Based on this, when the second virtualization software detects that the network virtual negotiation path is disconnected, the second virtualization software can monitor whether the network virtual protocol negotiation path has restored the path state according to a preset time interval. When the second virtualization software subsequently detects that the network virtual negotiation path has restored the path state, the second virtualization software can then send a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software until the network virtual protocol negotiation between the first virtualization software and the second virtualization software is successful.
[0094] It should be noted that in the embodiment of the present application, the step of determining the type of the network virtual device may also be performed, but is not limited to, before step 102 or step 104 or step 106, so as to improve the overall upgrade efficiency.
[0095] Step 112: After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0096] Specifically, after completing the network virtual protocol negotiation between the first virtualization software and the second virtualization software, the target virtualization environment of the virtual machine can extract and load the device status information of the virtual machine in the current virtualization environment from the preset path, and the first virtualization software can also reload the device status information of the network virtual device to restore the network virtual device to normal. Since the network virtual protocol negotiation between the first virtualization software and the second virtualization software has been completed, the virtio data plane unloading function of the network virtual device can still work normally.
[0097] As another option of the embodiment of the present application, after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved to the preset path, and loading the device status information of the network virtual device, it also includes:
[0098] Based on the target virtualization environment of the virtual machine, control the virtual machine to resume from a suspended running state to a running state.
[0099] Specifically, after reloading the device status information of the virtual machine in the current virtualization environment based on the target virtualization environment of the virtual machine, and loading the device status information of the network virtual device, the virtual machine composed of the target virtualization environment can be controlled to recover to the running state, and then the entire hot upgrade process of the virtual machine is completed.
[0100] As another option of the embodiment of the present application, after the target virtualization environment of the virtual machine is loaded according to the target binary program in the subprocess, the method further includes:
[0101] When it is detected that the target virtualization environment of the virtual machine fails to load, the network virtual device is initialized based on the current virtualization environment of the virtual machine;
[0102] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0103] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0104] Specifically, when it is detected that the target virtualization environment of the virtual machine fails to load, in order to roll back to the current virtualization environment of the virtual machine, the network virtual device can be initialized by the current virtualization environment of the virtual machine. The current virtualization environment of the virtual machine can be, but is not limited to, running in the first virtualization software, and after the network virtual device is initialized, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software until the device status information of the virtual machine in the current virtualization environment saved in the preset path is loaded, and the device status information of the network virtual device is loaded. It can be understood that in the embodiment of the present application, the rollback process of the virtual machine is the same as the logic of the successful hot upgrade process.
[0105] See here Figure 2 The system structure diagram of a method for hot upgrading a virtual machine provided by an embodiment of the present application is shown. Figure 2 As shown, when the method of hot upgrading a virtual machine is applied to the qemu-kvm virtualization solution, the system corresponding to the method of hot upgrading a virtual machine may include a virtual machine for hot upgrading, a first virtualization software corresponding to a network virtual device, and a second virtualization software (i.e., the slave end of the vhost device), wherein the master end of the vhost device is a virtual machine supervisor (i.e., Qemu) for controlling the first virtualization software, and a network virtualization protocol negotiation channel is established between the first virtualization software and the second virtualization software. The specific steps are as follows:
[0106] Step 1: After the device status information is saved, Qemu, as the master of the network virtualization protocol, actively initiates a renegotiation request for the vhost device before entering the next stage, and then continues the next stage of hot upgrade;
[0107] Step 2: After receiving the request, the slave end of the network virtual protocol starts to re-negotiate with Qemu. For the vhost-user network card device, in the specific implementation, the dpdk software module, as the slave end of the network virtual protocol, will detect the reconnection request, and then start to periodically initiate network virtual protocol negotiation with Qemu until it succeeds;
[0108] Step 3: Before the hot upgrade enters the device state loading stage, for the vhost device, Qemu first resets and initializes the vhost device, so that it responds to the request for network virtual protocol negotiation and completes the network virtual protocol negotiation with the slave end;
[0109] Step 4: During the device status loading phase of the hot upgrade, Qemu loads the vhost device. Since Qemu does not save the relevant status of the network virtual protocol negotiation of the vhost device and only loads other device status, the vhost device status will return to normal. Since the network virtual protocol negotiation of the vhost device has been completed before the device is restored, the virtio data plane unloading function can still work normally.
[0110] Step 5: During the hot upgrade rollback phase, when the vhost device needs to be rolled back, the current virtualization environment of the virtual machine also resets the vhost device, completes the network virtualization protocol negotiation with dpdk, and then loads the previously saved vhost device state to complete the rollback.
[0111] In one or more of the above-mentioned embodiments, compared with the traditional virtual machine hot upgrade technology, the following beneficial effects are achieved:
[0112] 1) When processing vhost devices, the traditional virtual machine hot upgrade solution will recreate a vhost device. The new virtualization environment will initialize the device according to the process of creating the vhost device. After the hot upgrade is successful, the virtual machine will use the newly created vhost device. Therefore, during the upgrade process, a vhost device of the virtual machine will have two vhost backends at the same time. For example, vhost-net will have two tap devices at the same time, and vhost-user will have two socket paths and openvswitch port ports at the same time. The upper-layer business software needs to recognize that the virtual machine is in a hot upgrade state and perform special processing on it. Moreover, after the hot upgrade is successful, the identification of the vhost device backend (such as the name of the tap device and the socket path) will be updated. In order to ensure business continuity, the upper-layer business software and quality service software also need to do special processing, which greatly increases the complexity of adaptation. Compared with the traditional solution, the solution proposed in this application reuses the original vhost device, which can realize the atomicity of the hot upgrade task. The upper-layer business software supports hot upgrades without any adaptation work, which greatly reduces the complexity of business software adaptation caused by virtual machine hot upgrades;
[0113] 2) Traditional virtual machine hot upgrade solutions cannot support rollback if the vhost device upgrade fails. The reason is that traditional solutions use newly created vhost devices in the new virtualization environment. Once the rollback fails, the vhost protocol cannot be renegotiated, and the original vhost device cannot be used anymore.
[0114] 3) The traditional virtual machine hot upgrade solution needs to create a new vhost device backend during the upgrade process. For example, the vhost-net network card needs to create a new tap device, and the vhost-user network card needs to create a new openvswitch port. After the virtualization environment upgrade is completed, the business software needs to re-execute the business logic, such as the vhost network card needs to re-issue the flow table. Therefore, the process of creating a new vhost device and configuring the business logic increases the entire hot upgrade time and business interruption time.
[0115] See also Figure 3 , Figure 3 A schematic structural diagram of a virtual machine hot upgrade device provided in an embodiment of the present application is shown.
[0116] like Figure 3 As shown, the virtual machine hot upgrade device may include at least a first processing module 301, an information storage module 302, a first request module 303, a second processing module 304, a second request module 305 and an information loading module 306, wherein:
[0117] The first processing module 301 is used to create a subprocess in the current process of the virtual machine and control the virtual machine to be in a suspended state when an upgrade action of the virtual machine is detected;
[0118] The information saving module 302 is used to save the device status information of the virtual machine in the current virtualization environment to a preset path, and save the device status information of the network virtual device based on the first virtualization software;
[0119] The first request module 303 is used to send a renegotiation request of the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software;
[0120] The second processing module 304 is used to load the target virtualization environment of the virtual machine according to the target binary program in the subprocess, and initialize the network virtual device based on the target virtualization environment of the virtual machine;
[0121] The second request module 305 is used to send a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software after the network virtual device completes initialization;
[0122] The information loading module 306 is used to load the device status information of the virtual machine in the current virtualization environment saved in the preset path after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, and load the device status information of the network virtual device.
[0123] In some possible embodiments, the device further includes:
[0124] After loading the target virtualization environment of the virtual machine according to the target binary program in the child process,
[0125] When it is detected that the target virtualization environment of the virtual machine fails to load, the network virtual device is initialized based on the current virtualization environment of the virtual machine;
[0126] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0127] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0128] In some possible embodiments, the second request module includes:
[0129] When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software;
[0130] When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring the network virtual protocol negotiation path at a preset time interval to see whether the path state is restored;
[0131] When it is determined that the network virtual protocol negotiation path is restored to the path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
[0132] In some possible embodiments, the device further includes:
[0133] After the device state information of the network virtual device is saved based on the first virtualization software, and before a renegotiation request of the network virtual device is sent to the second virtualization software based on the current virtualization environment of the virtual machine,
[0134] The first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path;
[0135] The uninstall data information is processed based on the second virtualization software.
[0136] In some possible embodiments, the device further includes:
[0137] When it is detected that the type of the network virtual device is the second type, adding a renegotiation request for the network virtual device in a designated field in the uninstall data information;
[0138] The first virtualization software sends the uninstallation data information with the re-negotiation request of the network virtual device added to the second virtualization software through the network virtual protocol negotiation path.
[0139] In some possible embodiments, the device further includes:
[0140] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved to the preset path, and loading the device status information of the network virtual device,
[0141] Based on the target virtualization environment of the virtual machine, control the virtual machine to resume from a suspended running state to a running state.
[0142] In some possible embodiments, the device further includes:
[0143] After creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended state,
[0144] Share the memory corresponding to the current process of the virtual machine with the child process.
[0145] Those skilled in the art can clearly understand that the technical solutions of the embodiments of the present application can be implemented with the help of software and / or hardware. The "unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA), an integrated circuit (IC), etc.
[0146] See also Figure 4 , Figure 4 A schematic structural diagram of another virtual machine hot upgrade device provided in an embodiment of the present application is shown.
[0147] like Figure 4 As shown, the virtual machine hot upgrade apparatus 400 may include at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .
[0148] The communication bus 402 may be used to realize the connection and communication among the above-mentioned components.
[0149] The user interface 403 may include buttons, and the optional user interface may also include a standard wired interface or a wireless interface.
[0150] The network interface 404 may include, but is not limited to, a Bluetooth module, an NFC module, a Wi-Fi module, etc.
[0151] Among them, the processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect various parts in the device 400 for hot upgrading of virtual machines, and executes various functions and processes data of the device 400 for hot upgrading of routing virtual machines by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be implemented in at least one hardware form of DSP, FPGA, and PLA. The processor 401 can integrate one or a combination of CPU, GPU, modem, etc. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 401, but may be implemented separately through a chip.
[0152] The memory 405 may include a RAM or a ROM. Optionally, the memory 405 includes a non-transitory computer-readable medium. The memory 405 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may optionally be at least one storage device located away from the aforementioned processor 401. As Figure 4 As shown, the memory 405 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program for hot upgrading of a virtual machine.
[0153] Specifically, the processor 401 may be used to call the virtual machine hot upgrade application stored in the memory 405, and specifically perform the following operations:
[0154] When the upgrade action of the virtual machine is detected, a child process is created in the current process of the virtual machine, and the virtual machine is controlled to be in a suspended state;
[0155] Saving the device status information of the virtual machine in the current virtualization environment to a preset path, and saving the device status information of the network virtual device based on the first virtualization software;
[0156] Sending a renegotiation request of a network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software;
[0157] In the child process, a target virtualization environment of the virtual machine is loaded according to the target binary program, and the network virtual device is initialized based on the target virtualization environment of the virtual machine;
[0158] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0159] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, the device status information of the virtual machine in the current virtualization environment saved in the preset path is loaded, and the device status information of the network virtual device is loaded.
[0160] In some possible embodiments, after loading the target virtualization environment of the virtual machine according to the target binary program in the child process, the method further includes:
[0161] When it is detected that the target virtualization environment of the virtual machine fails to load, the network virtual device is initialized based on the current virtualization environment of the virtual machine;
[0162] After the network virtual device completes initialization, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software;
[0163] After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
[0164] In some possible embodiments, sending a network virtual protocol negotiation request corresponding to a renegotiation request of a network virtual device to the first virtualization software based on the second virtualization software includes:
[0165] When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software;
[0166] When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring the network virtual protocol negotiation path at a preset time interval to see whether the path state is restored;
[0167] When it is determined that the network virtual protocol negotiation path is restored to the path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
[0168] In some possible embodiments, after saving the device state information of the network virtual device based on the first virtualization software, and before sending a renegotiation request of the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine, the method further includes:
[0169] The first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path;
[0170] The uninstall data information is processed based on the second virtualization software.
[0171] In some possible embodiments, the first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path, including:
[0172] When it is detected that the type of the network virtual device is the second type, adding a renegotiation request for the network virtual device in a designated field in the uninstall data information;
[0173] The first virtualization software sends the uninstallation data information with the re-negotiation request of the network virtual device added to the second virtualization software through the network virtual protocol negotiation path.
[0174] In some possible embodiments, after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved in the preset path, and loading the device status information of the network virtual device, the method further includes:
[0175] Based on the target virtualization environment of the virtual machine, control the virtual machine to resume from a suspended running state to a running state.
[0176] In some possible embodiments, after creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended running state, the method further includes:
[0177] Share the memory corresponding to the current process of the virtual machine with the child process.
[0178] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0179] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0180] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0181] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0182] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0183] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0184] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program codes.
[0185] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by entering a program to instruct related hardware, and the program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0186] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A method for hot upgrading a virtual machine, characterized in that: include: When an upgrade action of the virtual machine is detected, a child process is created in the current process of the virtual machine, and the virtual machine is controlled to be in a suspended state; Saving the device status information of the virtual machine in the current virtualization environment to a preset path, and saving the device status information of the network virtual device based on the first virtualization software; Sending a renegotiation request of the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software; In the subprocess, a target virtualization environment of the virtual machine is loaded according to a target binary program, and initialization processing is performed on the network virtual device based on the target virtualization environment of the virtual machine; After the network virtual device completes initialization, sending a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software; After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved to the preset path, and loading the device status information of the network virtual device; The sending, based on the second virtualization software, to the first virtualization software, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device includes: When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software; When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring whether the network virtual protocol negotiation path is restored to a path state at a preset time interval; When it is determined that the network virtual protocol negotiation path is restored to a path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
2. The method according to claim 1, characterized in that: After the target virtualization environment of the virtual machine is loaded according to the target binary program in the subprocess, the method further includes: When it is detected that the target virtualization environment of the virtual machine fails to load, initializing the network virtual device based on the current virtualization environment of the virtual machine; After the network virtual device completes initialization, sending a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software; After completing the network virtual protocol negotiation between the first virtualization software and the second virtualization software in the current virtualization environment of the virtual machine, load the device status information of the virtual machine in the current virtualization environment saved in the preset path, and load the device status information of the network virtual device.
3. The method according to claim 1, characterized in that After the device state information of the network virtual device is saved based on the first virtualization software, and before the current virtualization environment of the virtual machine sends a renegotiation request for the network virtual device to the second virtualization software, the method further includes: The first virtualization software sends the uninstallation data information to the second virtualization software through the network virtualization protocol negotiation path; The uninstall data information is processed based on the second virtualization software.
4. The method according to claim 3, characterized in that The sending of the uninstallation data information by the first virtualization software to the second virtualization software through the network virtualization protocol negotiation path includes: When it is detected that the type of the network virtual device is the second type, adding a renegotiation request of the network virtual device in a designated field in the uninstall data information; The first virtualization software sends the uninstallation data information with the re-negotiation request of the network virtual device added thereto to the second virtualization software through the network virtual protocol negotiation path.
5. The method according to claim 1, characterized in that After completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine, loading the device status information of the virtual machine in the current virtualization environment saved in the preset path, and loading the device status information of the network virtual device, the method further includes: Based on the target virtualization environment of the virtual machine, the virtual machine is controlled to resume from a suspended running state to a running state.
6. The method according to claim 1, characterized in that After creating a child process in the current process of the virtual machine and before controlling the virtual machine to be in a suspended running state, the method further includes: The memory corresponding to the current process of the virtual machine is shared with the child process.
7. A device for hot upgrading a virtual machine, characterized in that: include: A first processing module is used to create a subprocess in the current process of the virtual machine and control the virtual machine to be in a suspended state when an upgrade action of the virtual machine is detected; An information saving module, used to save the device status information of the virtual machine in the current virtualization environment to a preset path, and save the device status information of the network virtual device based on the first virtualization software; A first request module is used to send a renegotiation request of the network virtual device to the second virtualization software based on the current virtualization environment of the virtual machine; wherein the network virtual devices correspond to the first virtualization software and the second virtualization software respectively, and a network virtual protocol negotiation path is established between the first virtualization software and the second virtualization software; A second processing module is used to load the target virtualization environment of the virtual machine according to the target binary program in the sub-process, and initialize the network virtual device based on the target virtualization environment of the virtual machine; A second request module, configured to send a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device to the first virtualization software based on the second virtualization software after the network virtual device completes initialization; an information loading module, configured to load the device status information of the virtual machine in the current virtualization environment saved in the preset path and the device status information of the network virtual device after completing the network virtualization protocol negotiation between the first virtualization software and the second virtualization software in the target virtualization environment of the virtual machine; The sending, based on the second virtualization software, to the first virtualization software, a network virtual protocol negotiation request corresponding to the renegotiation request of the network virtual device includes: When it is detected that the type of the network virtual device is the first type, determining whether the network virtual protocol negotiation path is disconnected based on the second virtualization software; When it is determined that the network virtual protocol negotiation path is in a disconnected state, monitoring whether the network virtual protocol negotiation path is restored to a path state at a preset time interval; When it is determined that the network virtual protocol negotiation path is restored to a path state, a network virtual protocol negotiation request corresponding to the re-negotiation request of the network virtual device is sent to the first virtualization software based on the second virtualization software.
8. A device for hot upgrading a virtual machine, characterized in that: including a processor and a memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the steps of the method according to any one of claims 1 to 6.
