A virtual machine state determination method, system and electronic device
Patent Information
- Application Number
- CN202211343821.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-10-31
AI Technical Summary
[0040]从上述技术方案可以看出,本申请公开的虚拟机状态确定方法、系统及电子设备,获得待测虚拟机的虚拟网卡或虚拟磁盘的消息队列,确定虚拟网卡或虚拟磁盘的消息队列更新状态,基于虚拟网卡或虚拟磁盘的消息队列更新状态确定虚拟机当前处于内部异常状态或正常状态。本方案通过待测虚拟机的虚拟网卡或虚拟磁盘的消息队列更新状态确定虚拟机是否处于正常运行状态,这一过程无需借助其他软件或网络,不会受到其他针对软件或网络设置的影响,提高了虚拟机状态确定的准确性。
Smart Images

Figure CN115576780B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtual machines, and in particular to a method, system, and electronic device for determining the state of a virtual machine. Background Technology
[0002] There are generally two existing methods for detecting the running status of virtual machines. The first method is to detect the virtual machine from outside the virtual machine by pinging its IP address. If the virtual machine is not connected to the network, it is considered to be inactive. However, if the virtual machine is blocked from network access such as ping for various reasons, the detection of the virtual machine will fail and the virtual machine will be marked as inactive.
[0003] The second method involves installing agent software inside the machine. The probe program outside the virtual machine interacts with this agent software to perform the probe. If the interaction fails, the virtual machine is considered to be inactive. However, if the user disables the agent software inside the virtual machine, the probe for the virtual machine will fail, and the virtual machine will be marked as inactive. Summary of the Invention
[0004] In view of this, this application provides a method, system, and electronic device for determining the state of a virtual machine, the specific solution of which is as follows:
[0005] A method for determining the state of a virtual machine, comprising:
[0006] Obtain the message queue of the virtual network card or virtual disk of the virtual machine under test;
[0007] Determine the message queue update status of the virtual network interface card or virtual disk;
[0008] The virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
[0009] Furthermore, determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk includes:
[0010] If the message queue update status of the virtual network card or virtual disk is continuously updated, then the virtual machine is determined to be in normal operating condition.
[0011] If the message queue update status of the virtual network card or virtual disk is a non-continuous update status, then the virtual machine is determined to be in an internal abnormal state.
[0012] Furthermore, determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network interface card includes:
[0013] Obtain the value of the available space of the message sending queue of the virtual network card at the first moment;
[0014] At a first preset time interval, the available space value of the message sending queue of the virtual network card is obtained at the second time.
[0015] Based on whether the available space value of the message sending queue at the second moment is the same as the available space value of the message sending queue at the first moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0016] Furthermore, if the message queue update status of the virtual network card or virtual disk is a non-continuous update status, then determining that the virtual machine is currently in an internal abnormal state includes:
[0017] If it is determined that the message receiving queue of the virtual network card is in a continuous overflow state, then it is determined that the virtual machine is currently in an internal abnormal state.
[0018] Furthermore, determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network interface card includes:
[0019] Obtain the available space value and the used space value of the message receiving queue of the virtual network card at the third moment;
[0020] At a second preset time interval, the available space value of the message receiving queue of the virtual network card and the used space value of the message receiving queue are obtained at the fourth time.
[0021] Based on the comparison results of whether the available space value of the message receiving queue at the fourth time moment is the same as the available space value of the message receiving queue at the third time moment, and whether the used space value of the message receiving queue at the fourth time moment is the same as the used space value of the message receiving queue at the third time moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0022] Furthermore, determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the comparison results of whether the available space value of the message receiving queue at the fourth time moment is the same as the available space value of the message receiving queue at the third time moment, and whether the used space value of the message receiving queue at the fourth time moment is the same as the used space value of the message receiving queue at the third time moment, includes:
[0023] If it is determined that the available space value of the message receiving queue at the fourth time point is different from the available space value of the message receiving queue at the third time point, it is determined that the virtual machine is currently in normal operating state.
[0024] If it is determined that the available space value of the message receiving queue at the third time point is the same as the used space value, and the available space value of the message receiving queue at the fourth time point is the same as the available space value of the message receiving queue at the third time point, and the message receiving queue of the virtual network card is determined to be in a continuous overflow state, then the virtual machine is determined to be in an internal abnormal state.
[0025] Furthermore, determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual disk includes:
[0026] Obtain the value of the available space in the message request queue of the virtual disk mentioned in the fifth moment;
[0027] At a third preset time interval, the available space value of the message request queue of the virtual disk at the sixth time point is obtained;
[0028] Based on whether the value of the available space of the message request queue at the fifth moment is the same as the value of the available space of the message request queue at the sixth moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0029] Furthermore, the message queue for obtaining the virtual network card or virtual disk of the virtual machine under test includes:
[0030] Obtain the list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test, wherein the list of virtual devices includes at least the virtual network card or virtual disk;
[0031] Obtain the virtual memory address of the virtual network card or virtual disk in the list of virtual devices;
[0032] Read the virtual memory address of the virtual network card or virtual disk to obtain the message queue of the virtual network card or virtual disk.
[0033] A virtual machine state determination system, comprising:
[0034] The acquisition unit is used to acquire the message queue of the virtual network card or virtual disk of the virtual machine under test.
[0035] The first determining unit is used to determine the message queue update status of the virtual network card or virtual disk.
[0036] The second determining unit is used to determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
[0037] An electronic device, comprising:
[0038] The processor is used to obtain the message queue of the virtual network interface card or virtual disk of the virtual machine under test; determine the update status of the message queue of the virtual network interface card or virtual disk; and determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the update status of the message queue of the virtual network interface card or virtual disk.
[0039] The memory is used to store the program used by the processor to execute the above-described processing procedure.
[0040] As can be seen from the above technical solutions, the virtual machine status determination method, system, and electronic device disclosed in this application obtain the message queue of the virtual network card or virtual disk of the virtual machine under test, determine the update status of the message queue of the virtual network card or virtual disk, and determine whether the virtual machine is currently in an internal abnormal or normal state based on the update status of the message queue of the virtual network card or virtual disk. This solution determines whether the virtual machine is in a normal operating state by using the update status of the message queue of the virtual network card or virtual disk of the virtual machine under test. This process does not require the assistance of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine status determination. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart of a virtual machine state determination method disclosed in an embodiment of this application;
[0043] Figure 2 This is a flowchart of a virtual machine state determination method disclosed in an embodiment of this application;
[0044] Figure 3 This is a flowchart of a virtual machine state determination method disclosed in an embodiment of this application;
[0045] Figure 4 This is a flowchart of a virtual machine state determination method disclosed in an embodiment of this application;
[0046] Figure 5This is a schematic diagram of a virtual machine liveness detection architecture disclosed in an embodiment of this application;
[0047] Figure 6 This is a schematic diagram illustrating the relationship between a virtual machine liveness detection program and a host machine, as disclosed in an embodiment of this application.
[0048] Figure 7 This is a schematic diagram of the structure of a virtual machine state determination system disclosed in an embodiment of this application;
[0049] Figure 8 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0050] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0051] This application discloses a method for determining the state of a virtual machine, the flowchart of which is shown below. Figure 1 As shown, it includes:
[0052] Step S11: Obtain the message queue of the virtual network card or virtual disk of the virtual machine under test;
[0053] Step S12: Determine the message queue update status of the virtual network card or virtual disk;
[0054] Step S13: Determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
[0055] Virtual machines are simulated by virtual machine emulators. Each virtual machine has corresponding virtual disks and virtual network cards, etc. Since the virtual disks and virtual network cards of virtual machines are simulated by virtual machine emulators on the host machine, the information of these virtual devices can be detected on the host machine. By judging the changes in the information of these virtual devices, it can be determined whether the virtual machine is alive.
[0056] When it is necessary to detect the status of a virtual machine, the message queue of the virtual network card or virtual disk of the virtual machine under test can be obtained directly, and the update status of the message queue can be determined. Based on the update status of the message queue, it can be determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0057] The message queue of a virtual network interface card includes a message sending queue and a message receiving queue, while the message queue of a virtual disk is a message request queue.
[0058] When the message sending queue in the virtual network interface card is updated, it indicates that the virtual disk is actively sending data outwards, indicating that the virtual machine is currently alive, i.e., in a normal operating state. When the message receiving queue in the virtual disk is updated, it indicates that the virtual disk has received messages sent from the outside and is able to process them, indicating that the virtual machine is currently alive, i.e. in a normal operating state. When the message request queue in the virtual network interface card is updated, regardless of whether the update corresponds to a read request, a write request, or other requests, it indicates that the virtual machine is currently alive, i.e. in a normal operating state.
[0059] When the message sending queue of the virtual network interface card (NIC) has not been updated for a long time, the message receiving queue of the virtual NIC has not been continuously updated, and the message request queue of the virtual disk has also not been updated for a long time, it can be determined that the virtual machine is currently in an internal abnormal state. Only when the message sending queue, message receiving queue of the virtual NIC, and message request queue of the virtual slave disk have all not been updated for a long time can it be determined that the virtual machine is currently in an internal abnormal state.
[0060] In addition, when the virtual network adapter's message receive queue is in a continuous overflow state, it can also be determined that the virtual machine is currently in an internal abnormal state. At this time, it is not necessary to determine whether the virtual network adapter's message send queue has been updated, nor is it necessary to determine whether the virtual disk's message request queue has been updated.
[0061] The message receiving queue continuously overflows, which can be caused by the message receiving queue being able to receive messages sent from the outside but being unable to process the received messages. When the message receiving queue in the virtual network card of the virtual machine is in a state of continuous overflow, it can be determined that the virtual machine is in an internal abnormal state.
[0062] Whether the virtual machine's running status is determined through the message sending or receiving queue of the virtual network card, or through the update status of the message request queue of the virtual disk, it is directly based on the information sending and receiving situation inside the virtual machine. It does not require the help of other software or other networks for judgment. This avoids the situation where the virtual machine status is incorrectly judged when the virtual machine restricts other software or other networks, thus improving the accuracy of virtual machine status determination.
[0063] The virtual machine status determination method disclosed in this embodiment obtains the message queue of the virtual network interface card (NIC) or virtual disk of the virtual machine under test, determines the update status of the message queue of the virtual NIC or virtual disk, and determines whether the virtual machine is currently in an internal abnormal state or a normal state based on the update status of the message queue of the virtual NIC or virtual disk. This solution determines whether the virtual machine is in a normal operating state by using the update status of the message queue of the virtual NIC or virtual disk of the virtual machine under test. This process does not require the use of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine status determination.
[0064] This embodiment discloses a method for determining the state of a virtual machine, the flowchart of which is shown below. Figure 2 As shown, it includes:
[0065] Step S21: Obtain the message queue of the virtual network card or virtual disk of the virtual machine under test;
[0066] Step S22: Determine the message queue update status of the virtual network card or virtual disk;
[0067] Step S23: Obtain the value of the available space of the message sending queue of the virtual network card at the first moment;
[0068] Step S24: After a first preset time interval, obtain the value of the available space of the message sending queue of the virtual network card at the second moment;
[0069] Step S25: Based on whether the available space value of the message sending queue at the second moment is the same as the available space value of the message sending queue at the first moment, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0070] A message queue typically consists of three parts: available space, used space, and address space array desc. The available space and used space represent the positions within the address space array desc. That is, the position of data in the address space array desc can be determined by an index. For example, when sending the data "abc" from the virtual machine, an index is obtained from available space available.idx, which is idx. If the obtained index is 10, then "abc" is placed at the 10th position in the address space array desc.
[0071] To determine the update status of the message sending queue of the virtual network interface card, it is necessary to determine whether the available space value of the message sending queue of the virtual network interface card changes at different times.
[0072] That is, obtain the value of the available space of the message sending queue of the virtual network card at the first moment, and after a first preset time interval, obtain the value of the available space of the message sending queue of the virtual network card at the second moment, and determine whether the two obtained values are the same.
[0073] The system first obtains and saves the available space (avail.idx) of the virtual network interface card's message sending queue, for example, by saving it to last_tx_avail_idx. After a first preset time interval, it obtains the available space (avail.idx) of the virtual network interface card's message sending queue at the second moment. The system then compares the currently obtained value with the value read and saved to last_tx_avail_idx at the first moment.
[0074] If the two values are different, it indicates that the number of messages sent by the virtual network card of the virtual machine is different within the first preset time period from the first moment to the second moment. This means that the virtual machine is sending network data outward during this time period, which can be used to determine that the virtual machine is currently in a normal operating state. Furthermore, the value of avail.idx read at the second moment can be saved to last_tx_avail_idx to replace the value stored at the first moment.
[0075] Specifically, when the virtual machine sends data, it first updates the value of available space avail.idx within the virtual machine. At this time, the virtual machine emulator on the host machine reads the change in the value of available.idx within the virtual machine and processes the corresponding data in the address space array desc based on this change. After the processing is completed, used.idx on the virtual machine emulator on the host machine will change. Based on the change in used.idx, the virtual machine can determine that the data it sent has been processed, thus realizing the complete process of packet sending.
[0076] Furthermore, if the available space value of the virtual network card's message sending queue does not change within the first preset time period from the first moment to the second moment, it indicates that the virtual machine has not sent any messages during this time period. To further determine whether the virtual machine is currently in an internal abnormal state, it is necessary to use the virtual network card's message receiving queue and / or the virtual disk's message request queue for joint determination. It is not possible to directly conclude that the virtual machine is currently in an internal abnormal state based solely on the fact that the available space value of the virtual network card's message sending queue has not changed within the first preset time period, so as to ensure the accuracy of the determination of the virtual machine's current running status.
[0077] The message queues on the virtual machine and the virtual machine emulator on the host machine are shared. When the message queue on the virtual machine emulator on the host machine changes, the message queue on the virtual machine will also change accordingly. For example, when the used.idx in the message sending queue on the virtual machine emulator on the host machine changes, the virtual machine can directly determine that its used.idx has changed.
[0078] The virtual machine state determination method disclosed in this embodiment obtains the message queue of the virtual network interface card (NIC) or virtual disk of the virtual machine under test, determines the update status of the message queue of the NIC or virtual disk, obtains the available space value of the message sending queue of the NIC at a first moment, obtains the available space value of the message sending queue of the NIC at a second moment after a first preset time interval, and determines whether the virtual machine is currently in an internal abnormal state or a normal operating state based on whether the available space value of the message sending queue at the second moment is the same as the available space value of the message sending queue at the first moment. This solution determines whether the virtual machine is in a normal operating state by using the update status of the message queue of the virtual NIC or virtual disk of the virtual machine under test. This process does not require the use of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine state determination.
[0079] Furthermore, the virtual machine state determination method disclosed in this embodiment can also determine whether the virtual machine is currently in an internal abnormal state or a normal operating state by:
[0080] Obtain the available space value of the message request queue of the virtual disk at the fifth moment; after a third preset time interval, obtain the available space value of the message request queue of the virtual disk at the sixth moment; based on whether the available space value of the message request queue at the fifth moment is the same as the available space value of the message request queue at the sixth moment, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0081] The messages in the virtual disk's message request queue include at least information such as reading disk, writing disk, or modifying disk attributes. Regardless of the type of request, it is implemented through only one message request queue. Whenever there is information interaction or modification on the disk, the message request queue will change. Therefore, by directly monitoring the available space value of the message request queue, if two monitored values are different, it indicates that there are request messages on the virtual disk during the two monitoring periods, which means that the virtual machine is currently alive, i.e., in a normal operating state.
[0082] If the values detected in the two monitoring sessions are the same, it indicates that the virtual disk did not request any messages during the two monitoring sessions. In this case, it is necessary to further use the message queue of the virtual network card to determine whether the virtual machine is currently alive, rather than simply determining that the virtual machine is in an internal abnormal state based on the fact that the virtual disk did not request any messages during the two monitoring sessions.
[0083] This embodiment discloses a method for determining the state of a virtual machine, the flowchart of which is shown below. Figure 3 As shown, it includes:
[0084] Step S31: Obtain the message queue of the virtual network card or virtual disk of the virtual machine under test;
[0085] Step S32: Determine the message queue update status of the virtual network card or virtual disk;
[0086] Step S33: Obtain the available space value and the used space value of the message receiving queue of the virtual network card at the third moment;
[0087] Step S34: After a second preset time interval, obtain the available space value and the used space value of the message receiving queue of the virtual network card at the fourth time.
[0088] Step S35: Based on the comparison results of whether the available space value of the message receiving queue at the fourth time moment is the same as the available space value of the message receiving queue at the third time moment, and whether the used space value of the message receiving queue at the fourth time moment is the same as the used space value of the message receiving queue at the third time moment, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0089] When determining whether a virtual machine is in an internal abnormal state by using the message receiving queue of the virtual network card, the available space and used space of the message receiving queue at different times can be used to determine whether data sent to the virtual network card from the outside can be successfully received.
[0090] Determining whether incoming data to the virtual network interface card (NIC) can be successfully received essentially involves checking if the NIC's message receive queue is in a continuous overflow state. If it is, the update status of the NIC's message receive queue is non-continuous, indicating that the virtual machine is currently in an internal abnormal state. If the NIC's message receive queue is not in a continuous overflow state, the update status is continuous, indicating that the NIC's message receive state is currently in normal operation. To further determine whether the virtual machine is currently in normal operation, a comprehensive assessment of the NIC's message send queue and the virtual disk's message request queue is necessary.
[0091] To determine whether the message receive queue of the virtual network card is in a continuous overflow state, it can be determined by comparing the available space value of the message receive queue at the fourth time step with the available space value of the message receive queue at the third time step, and by comparing the used space value of the message receive queue at the fourth time step with the used space value of the message receive queue at the third time step.
[0092] Specifically, if the available space value of the message receiving queue in the fourth moment is different from the available space value of the message receiving queue in the third moment, it is determined that the virtual machine is currently in a normal operating state; if the available space value of the message receiving queue in the third moment is the same as the used space value, and the available space value of the message receiving queue in the fourth moment is the same as the available space value of the message receiving queue in the third moment, it is determined that the message receiving queue of the virtual network card is in a continuous overflow state, and then it can be determined that the virtual machine is currently in an internal abnormal state.
[0093] When a virtual network interface card (NIC) receives messages, it first updates the used.idx file in the message receiving queue on the host machine, and then the virtual machine updates the available.idx file. Since the virtual NIC can receive multiple messages continuously, the used.idx file in the message receiving queue usually grows faster than the available.idx file when the virtual NIC is receiving messages normally. Therefore, the used.idx file in the message receiving queue will be greater than the available.idx file in the message receiving queue.
[0094] When the available.idx in the message receiving queue is equal to the used.idx at a certain moment, it indicates that there is no more space in the virtual network card to receive data. At this time, if the virtual machine is in a normal operating state, the available.idx in the message receiving queue will be updated to ensure that the virtual machine can receive data normally. If the available.idx in the message receiving queue is not updated, a continuous overflow state of the message receiving queue has occurred.
[0095] Therefore, when the available space value `avail.idx` in the message receiving queue at the third time step is the same as the used space value `used.idx`, it is necessary to determine whether the available space value `avail.idx` in the message receiving queue at the fourth time step is the same as the available space value in the message receiving queue at the third time step. If they are the same, it indicates that `avail.idx` in the message receiving queue has not been updated, and it can be determined that the message receiving queue is in a continuous overflow state. If they are different, it indicates that `avail.idx` in the message receiving queue has been updated, and it can be determined that the message receiving queue is in a normal state and has not experienced a continuous overflow state.
[0096] The fourth time is the time interval between the third time and the second preset time. The second preset time, the first preset time, and the third preset time can be the same or different. There is no specific limitation on the preset time.
[0097] The virtual machine state determination method disclosed in this embodiment obtains the message queue of the virtual network interface card (NIC) or virtual disk of the virtual machine under test, determines the update status of the message queue of the NIC or virtual disk, obtains the available space value and the used space value of the message receiving queue of the NIC at a third time, and after an interval of a second preset time, obtains the available space value of the message receiving queue of the NIC at a fourth time and compares it with the available space value of the message receiving queue at the third time, as well as the comparison result of whether the used space value of the message receiving queue at the fourth time is the same as the used space value of the message receiving queue at the third time, to determine whether the virtual machine is currently in an internal abnormal state or a normal operating state. This solution determines whether the virtual machine is in a normal operating state by using the message queue update status of the virtual NIC or virtual disk of the virtual machine under test. This process does not require the use of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine state determination.
[0098] This embodiment discloses a method for determining the state of a virtual machine, the flowchart of which is shown below. Figure 4 As shown, it includes:
[0099] Step S41: Obtain the list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test. The list of virtual devices shall include at least a virtual network card or a virtual disk.
[0100] Step S42: Obtain the virtual memory address of the virtual network card or virtual disk in the virtual device list;
[0101] Step S43: Read the virtual memory address of the virtual network card or virtual disk to obtain the message queue of the virtual network card or virtual disk;
[0102] Step S44: Determine the message queue update status of the virtual network card or virtual disk;
[0103] Step S45: Determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
[0104] A virtual machine emulator is used to simulate the structure on the host machine where virtual machines are created. While emulating a virtual machine, the virtual machine emulator also simulates the virtual devices on the virtual machine. After emulating the virtual devices, it stores a list of virtual devices. This list records information such as the name and address of the virtual devices in the virtual machine simulated by the virtual machine emulator.
[0105] Since virtual devices include at least virtual network adapters and virtual disks, after obtaining the list of virtual devices in the virtual machine, the virtual memory address of the virtual network adapter or the virtual memory address of the virtual disk can be obtained based on the list of virtual devices. Then, the corresponding message queue can be obtained from the virtual memory address. That is, the message sending queue and message receiving queue of the virtual network adapter can be obtained from the virtual memory address of the virtual network adapter, and the message request queue of the virtual disk can be obtained from the virtual memory address of the virtual disk. This is so that after obtaining the message queue of the virtual network adapter or the virtual disk, the update status of the message queue can be used to determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0106] The message queue for determining a virtual network interface card or virtual disk by using a virtual device list and the virtual memory address of the virtual device, and further determining the current running status of the virtual machine, requires adding a virtual device list interface when the virtual machine emulator creates virtual devices in the virtual machine, so that the virtual device list can be called based on this interface; at the same time, a virtual device information interface also needs to be added so that the virtual device information can be called based on this interface, thereby obtaining the virtual memory address of the virtual device.
[0107] The message queue for virtual memory or virtual disk is obtained from the virtual memory address, which is located in the virtual machine emulator on the host machine. This allows the determination of the virtual machine's running status to be made directly based on the data in the virtual machine emulator, without the need to probe the inside of the virtual machine.
[0108] Specifically, the running status of a virtual machine can be detected through a virtual machine liveness detection program. The actual liveness detection architecture can be as follows: Figure 5 As shown, it includes: a host machine 51, a virtual machine 52, a virtual machine emulator 53, a virtual machine liveness detection program 54, and a virtual machine hypervisor 55. The host machine simulates the virtual machine and the virtual devices within it through the virtual machine emulator. The virtual machine liveness detection program stores device information, i.e., information related to the virtual devices simulated by the virtual machine emulator. The virtual machine emulator stores the virtual memory addresses of the virtual devices. When the virtual machine liveness detection program needs to detect the liveness of the virtual machine, it directly obtains the device simulation information from the virtual machine emulator and, based on this information, retrieves the virtual memory addresses of the virtual devices from the virtual machine emulator. Based on this, it determines the running status of the virtual machine and feeds it back to the virtual machine hypervisor so that the virtual machine hypervisor can control and manage the virtual machine based on its running status.
[0109] like Figure 6The diagram illustrates how a virtual machine (VM) liveness detection program retrieves VM-related information from the host machine. Here, Guest represents the VM, VMM represents the host machine, and the memory areas occupied by message queues in the VM and host machine correspond. When the message queue in the VM changes, the message queue in the host machine changes accordingly. Furthermore, the host machine stores a virtual device list (vdev_list) and virtual device information (vdev_info). The VM liveness detection program retrieves these information from the host machine to determine the virtual memory addresses of the virtual devices, thereby determining whether the VM is currently in an internal abnormal state or a normal operating state. Here, nic represents the network interface card (NIC), nic emulation represents the virtual NIC, block represents the disk, and block emulation represents the virtual disk.
[0110] The virtual machine state determination method disclosed in this embodiment obtains a list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test. This list includes at least a virtual network interface card (NIC) or a virtual disk. The method then obtains the virtual memory address of the NIC or disk from the list, reads the virtual memory address, obtains the message queue of the NIC or disk, determines the message queue update status, and determines whether the virtual machine is currently in an internal abnormal or normal state based on the message queue update status. This solution determines whether the virtual machine is in a normal operating state by checking the message queue update status of the NIC or disk under test. This process does not require other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine state determination.
[0111] This embodiment discloses a virtual machine state determination system, the structural diagram of which is shown below. Figure 7 As shown, it includes:
[0112] The acquisition unit 71, the first determination unit 72, and the second determination unit 73 are included.
[0113] Among them, the obtaining unit 71 is used to obtain the message queue of the virtual network card or virtual disk of the virtual machine under test;
[0114] The first determining unit 72 is used to determine the message queue update status of the virtual network card or virtual disk;
[0115] The second determining unit 73 is used to determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
[0116] Furthermore, the second determining unit is used for:
[0117] If the message queue update status of the virtual network interface card or virtual disk is determined to be continuously updated, the virtual machine is determined to be in a normal operating state; if the message queue update status of the virtual network interface card or virtual disk is determined to be non-continuously updated, the virtual machine is determined to be in an internal abnormal state.
[0118] Furthermore, the second determining unit is used for:
[0119] Obtain the available space value of the message sending queue of the virtual network card at the first moment; after a first preset time interval, obtain the available space value of the message sending queue of the virtual network card at the second moment; based on whether the available space value of the message sending queue at the second moment is the same as the available space value of the message sending queue at the first moment, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0120] Furthermore, the second determining unit is used for:
[0121] If the message receive queue of the virtual network card is determined to be in a continuous overflow state, then the virtual machine is currently in an internal abnormal state.
[0122] Furthermore, the second determining unit is used for:
[0123] Obtain the available space value and the used space value of the message receiving queue of the virtual network card at the third time. After a second preset time interval, obtain the available space value and the used space value of the message receiving queue of the virtual network card at the fourth time. Based on the comparison results of whether the available space value of the message receiving queue at the fourth time is the same as the available space value of the message receiving queue at the third time, and whether the used space value of the message receiving queue at the fourth time is the same as the used space value of the message receiving queue at the third time, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0124] Furthermore, the second determining unit is used for:
[0125] If the available space value of the message receiving queue in the fourth moment is different from the available space value of the message receiving queue in the third moment, it is determined that the virtual machine is currently in a normal operating state. If the available space value of the message receiving queue in the third moment is the same as the used space value, and the available space value of the message receiving queue in the fourth moment is the same as the available space value of the message receiving queue in the third moment, it is determined that the message receiving queue of the virtual network card is in a continuous overflow state, and then it is determined that the virtual machine is currently in an internal abnormal state.
[0126] Furthermore, the second determining unit is used for:
[0127] Obtain the available space value of the message request queue of the virtual disk at the fifth moment; after a third preset time interval, obtain the available space value of the message request queue of the virtual disk at the sixth moment; based on whether the available space value of the message request queue at the fifth moment is the same as the available space value of the message request queue at the sixth moment, determine whether the virtual machine is currently in an internal abnormal state or a normal operating state.
[0128] Furthermore, the obtaining unit is used for:
[0129] Obtain the list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test. The list of virtual devices must include at least a virtual network card or a virtual disk. Obtain the virtual memory address of the virtual network card or virtual disk in the list of virtual devices. Read the virtual memory address of the virtual network card or virtual disk and obtain the message queue of the virtual network card or virtual disk.
[0130] The virtual machine state determination system disclosed in this embodiment is implemented based on the virtual machine state determination method disclosed in the above embodiment, and will not be described again here.
[0131] The virtual machine status determination system disclosed in this embodiment obtains the message queue of the virtual network interface card (NIC) or virtual disk of the virtual machine under test, determines the update status of the message queue of the virtual NIC or virtual disk, and determines whether the virtual machine is currently in an internal abnormal state or a normal state based on the update status of the message queue of the virtual NIC or virtual disk. This solution determines whether the virtual machine is in a normal operating state by using the update status of the message queue of the virtual NIC or virtual disk of the virtual machine under test. This process does not require the use of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine status determination.
[0132] This embodiment discloses an electronic device, the structural schematic diagram of which is shown below. Figure 8 As shown, it includes:
[0133] Processor 81 and memory 82.
[0134] The processor 81 is used to obtain the message queue of the virtual network card or virtual disk of the virtual machine under test; determine the update status of the message queue of the virtual network card or virtual disk; and determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the update status of the message queue of the virtual network card or virtual disk.
[0135] The memory 82 is used to store the program for the processor to execute the above processing procedure.
[0136] The electronic device disclosed in this embodiment is implemented based on the virtual machine state determination method disclosed in the above embodiments, and will not be described again here.
[0137] The electronic device disclosed in this embodiment obtains the message queue of the virtual network interface card (NIC) or virtual disk of the virtual machine under test, determines the update status of the message queue of the virtual NIC or virtual disk, and determines whether the virtual machine is currently in an internal abnormal state or a normal state based on the update status of the message queue of the virtual NIC or virtual disk. This solution determines whether the virtual machine is in a normal operating state by using the update status of the message queue of the virtual NIC or virtual disk of the virtual machine under test. This process does not require the use of other software or networks and is not affected by other software or network settings, thus improving the accuracy of virtual machine status determination.
[0138] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0139] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0140] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0141] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for determining the state of a virtual machine, wherein, include: Obtain the list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test. The list of virtual devices includes at least a virtual network card or a virtual disk. Obtain the virtual memory address of the virtual network interface card or virtual disk in the list of virtual devices; read the virtual memory address of the virtual network interface card or virtual disk to obtain the message queue of the virtual network interface card or virtual disk; Determine the message queue update status of the virtual network interface card or virtual disk; The virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
2. The method according to claim 1, wherein, The step of determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk includes: If the message queue update status of the virtual network card or virtual disk is continuously updated, then the virtual machine is determined to be in normal operating condition. If the message queue update status of the virtual network card or virtual disk is a non-continuous update status, then the virtual machine is determined to be in an internal abnormal state.
3. The method according to claim 1, wherein, The step of determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network interface card includes: Obtain the value of the available space of the message sending queue of the virtual network card at the first moment; At a first preset time interval, the available space value of the message sending queue of the virtual network card is obtained at the second time. Based on whether the available space value of the message sending queue at the second moment is the same as the available space value of the message sending queue at the first moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
4. The method according to claim 2, wherein, If the message queue update status of the virtual network interface card or virtual disk is a non-continuous update status, then it is determined that the virtual machine is currently in an internal abnormal state, including: If it is determined that the message receiving queue of the virtual network card is in a continuous overflow state, then it is determined that the virtual machine is currently in an internal abnormal state.
5. The method according to claim 4, wherein, The step of determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network interface card includes: Obtain the available space value and the used space value of the message receiving queue of the virtual network card at the third moment; At a second preset time interval, the available space value of the message receiving queue of the virtual network card and the used space value of the message receiving queue are obtained at the fourth time. Based on the comparison results of whether the available space value of the message receiving queue at the fourth time moment is the same as the available space value of the message receiving queue at the third time moment, and whether the used space value of the message receiving queue at the fourth time moment is the same as the used space value of the message receiving queue at the third time moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
6. The method according to claim 5, wherein, The determination of whether the virtual machine is currently in an internal abnormal state or a normal operating state is based on the comparison results of whether the available space value of the message receiving queue at the fourth time moment is the same as the available space value of the message receiving queue at the third time moment, and whether the used space value of the message receiving queue at the fourth time moment is the same as the used space value of the message receiving queue at the third time moment. If it is determined that the available space value of the message receiving queue at the fourth time point is different from the available space value of the message receiving queue at the third time point, it is determined that the virtual machine is currently in normal operating state. If it is determined that the available space value of the message receiving queue at the third time point is the same as the used space value, and the available space value of the message receiving queue at the fourth time point is the same as the available space value of the message receiving queue at the third time point, and the message receiving queue of the virtual network card is determined to be in a continuous overflow state, then the virtual machine is determined to be in an internal abnormal state.
7. The method according to claim 1, wherein, The step of determining whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual disk includes: Obtain the value of the available space in the message request queue of the virtual disk mentioned in the fifth moment; At a third preset time interval, the available space value of the message request queue of the virtual disk at the sixth time point is obtained; Based on whether the value of the available space of the message request queue at the fifth moment is the same as the value of the available space of the message request queue at the sixth moment, it is determined whether the virtual machine is currently in an internal abnormal state or a normal operating state.
8. A virtual machine state determination system, wherein, include: The obtaining unit is used to obtain a list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test, wherein the list of virtual devices includes at least a virtual network card or a virtual disk; and to obtain the virtual memory address of the virtual network card or virtual disk in the list of virtual devices. Read the virtual memory address of the virtual network card or virtual disk to obtain the message queue of the virtual network card or virtual disk; The first determining unit is used to determine the message queue update status of the virtual network card or virtual disk. The second determining unit is used to determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the message queue update status of the virtual network card or virtual disk.
9. An electronic device, wherein, include: The processor is configured to: obtain a list of virtual devices in the virtual machine emulator corresponding to the virtual machine under test, wherein the list of virtual devices includes at least a virtual network interface card (NIC) or a virtual disk; obtain the virtual memory address of the virtual NIC or virtual disk in the list of virtual devices; read the virtual memory address of the virtual NIC or virtual disk to obtain the message queue of the virtual NIC or virtual disk; determine the update status of the message queue of the virtual NIC or virtual disk; and determine whether the virtual machine is currently in an internal abnormal state or a normal operating state based on the update status of the message queue of the virtual NIC or virtual disk. The memory is used to store the program used by the processor to execute the above-described processing procedure.
Citation Information
Patent Citations
Apparatus and method for preventing queue overflow for hard disk drive protection in computer system
CN101876950A
Heartbeat detection method, heartbeat detection system and heartbeat detection equipment for virtual machine and medium
CN110209470A
Method and device for sending anomaly detection and method and device for receiving anomaly detection
CN117014339A
Service fusing method and apparatus and message middleware
WO2021000693A1