A method for detecting virtual machine vcpu hanging in a cloud computing scenario
By creating MMIO zones in the cloud computing environment and using high-precision timers in conjunction with CPU hot-swapping mechanisms, the problems of inaccurate judgment and service interruption in virtual machine vCPU hang detection are solved, achieving rapid fault location and high availability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM CLOUD TECH CO LTD
- Filing Date
- 2023-12-11
- Publication Date
- 2026-05-15
AI Technical Summary
In a cloud computing environment, when a virtual machine's vCPU hangs, existing technologies cannot accurately determine whether the guest has been actively swapped out or has hangn up. Furthermore, the management program's handling of collaborative processes involving multiple guests can lead to business interruptions and issues such as excessively large core documents and difficulties in transmission.
MMIO region is created in the backend of VMM for memory mapping. Devices are registered through I/O hardware abstraction and device tree. An internal clock is started and a high-precision timer is used to send heartbeat messages. Combined with the CPU hot-plug mechanism, the vCPU is ensured to go offline and enter a deadlock state for detection.
It enables rapid detection and fault location of VCPU hangs, avoiding misjudgments and business interruptions caused by high load on the host, and improving the automated operation and maintenance capabilities and detection accuracy of cloud services.
Smart Images

Figure CN118193121B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of cloud computing, specifically a method for detecting virtual machine (vcpu) hangs in a cloud computing scenario. Background Technology
[0002] A virtual CPU (vCPU) is a virtual processing core in a cloud server instance, virtualized using Hyper-Threading (HT) technology on top of the physical CPU. In cloud computing environments, to meet enterprise customers' Service Level Agreement (SLA) requirements for servers, virtual machine failures, crashes, and hangs need to be detected and addressed promptly. At the host level, the operating system supports various operating system anomaly detection methods, including softlockup, hardlockup, hang, and hardware watchdog timers. These methods coordinate the handling of server hardware failures at the hardware, firmware, kernel, and application levels, improving server reliability.
[0003] At the virtual machine level, since exception triggering relies on the host sending an interrupt signal to the virtual machine, if the guest cannot respond to the interrupt due to a hypervisor exception, the kernel exception handling mechanism cannot be entered when a guest exception occurs, resulting in a suspended guest state where the exception context cannot be preserved. From the host's perspective, the guest's CPU usage will still show changes. Using a watchdog mechanism to trigger a guestpanic exception to obtain the fault information results in inaccurate timing due to time lapses in the guest's time. Furthermore, as an independent CPU task, the guest is unaware of its own scheduling behavior.
[0004] For example, Chinese patent application CN109032822A discloses a method and apparatus for saving system crash information. The method includes: when the system is determined to have experienced an abnormal restart, controlling a first watchdog timer to reset the CPU; after the CPU reset, setting the first and second watchdog timers to hardware-based feeding mode and saving the crash information to flash memory; configuring the second watchdog timer to software-based feeding, and resetting all components on the entire board if the second watchdog timer times out. This invention effectively solves the technical problem in the prior art where crash information cannot be effectively saved in the event of an abnormal system crash and restart, making subsequent fault analysis impossible. It achieves the technical effect of effectively saving crash information even in the event of a severe system crash.
[0005] For example, Chinese patent application CN107515772A discloses a method and apparatus for detecting KVM virtual machine hangs, including: obtaining the PC pointer of the corresponding thread of the virtual machine by querying the virtual machine; determining whether the virtual machine is in a hang state by analyzing the obtained PC pointer of the corresponding thread of the virtual machine; and if it is determined that the virtual machine is in a hang state, reporting a virtual machine hang alarm message. This method can accurately determine the hang state of the virtual machine by querying and analyzing the PC pointer.
[0006] The above-mentioned existing technologies all have the following problems: 1) If there is no scheduling or dog feeding for a long time, the host cannot determine whether the guest is actively swapped out or hangs; 2) The management program has multiple management and collaboration processes for each guest. If they are all transferred together, it will cause guest services to be suspended, the core documents generated to be too large, and transmission difficulties. Summary of the Invention
[0007] To address the shortcomings of existing technologies, this invention proposes a method for detecting virtual machine (VCPU) hangs in a cloud computing scenario. Specifically, it includes: creating an MMIO region in the backend of the Virtual Machine Controller (VMM) for memory mapping; enabling the VMM to recognize this region by adding a configuration file; performing I / O hardware abstraction; registering devices on the memory bus using a device tree approach; providing a memory region to the virtual machine; starting an internal clock; calculating the internal clock's decrement time; adjusting the internal clock based on extracted visitor time; using a misc device; starting a high-precision timer to periodically send heartbeat messages; after sending, the virtual machine enters the VMM and uses the VMM to determine the VCPU status; registering a CPU hot-plug mechanism to ensure that suspended VCPUs are offline and enter a deadlock state. This method allows for rapid analysis of virtual machine hangs and quick fault location.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] A method for detecting virtual machine (vCPU) hangs in a cloud computing scenario includes:
[0010] Step S1: Create an MMIO region in the backend of the VMM for memory mapping, and make the VMM recognize the region by adding a configuration file;
[0011] Step S2: Perform I / O hardware abstraction and register devices on the memory bus using a device tree approach to provide memory regions to the virtual machine;
[0012] Step S3: Start the internal clock, calculate the internal clock decrement time, and adjust the internal clock according to the extracted visitor time;
[0013] Step S4: Using the misc device, start a high-precision timer to periodically send heartbeat messages. After sending, the virtual machine enters the VMM and reads the vcpu status through the VMM.
[0014] Step S5: Register the CPU hot-swap mechanism to ensure that the vCPU in the suspended state is offline and enters a deadlock state.
[0015] Specifically, step S1 includes the following steps:
[0016] Step S101: Create an MMIO emulation device in the VMM backend and integrate the device emulation into the VMM;
[0017] Step S102: Set the MMIO region register parameters.
[0018] Specifically, the steps for creating the MMIO simulation device in step S101 include:
[0019] Step S1011: Define MMIO memory and identify it when the Guest memory exits due to a page fault;
[0020] Step S1012: Create a virtual machine through the KVM driver, allocate virtual memory and read / write and run vcpu registers, and then simulate the virtual machine user space components through QEMU;
[0021] Step S1013: QEMU and KVM drivers obtain and execute the read and write instructions before the Guest exits, and implement MMIO logic simulation in the virtual environment to complete the memory read and write simulation of the Guest, and save it in virtual memory and the corresponding virtual user space;
[0022] Step S1014: After completing the simulation, return to the QEMU user status, trigger the MMIO read / write callback registered in the user status, and complete the MMIO device simulation.
[0023] Specifically, the method for registering devices on the memory bus using a device tree approach in step S2 includes the following steps:
[0024] Step S201: Add nodes to the device tree and flash them, and confirm the existence and compatibility of relevant nodes in the device;
[0025] Step S202: Initialize the platform driver structure and construct the probe function in the structure;
[0026] Step S203: Use the platform driver registration function to complete the platform driver registration, and use the of function of the probe function to obtain the node parameters;
[0027] Step S204: Determine whether the device registration was successful by comparing the device tree nodes and parameter value directory.
[0028] Specifically, step S3 includes the following steps:
[0029] Step S301: Set the KVM clock source and start the internal clock using the virtual thread managed by KVM;
[0030] Step S302: Complete the interaction between the virtual thread and the MMIO region, and update the registers according to the register format;
[0031] Step S303: Achieve clock synchronization through NTPT, use a timestamp counter to calculate the internal clock decrement time, and adjust the internal clock according to the extracted visitor time.
[0032] Specifically, the steps for setting the KVM clock source in step S301 include:
[0033] Step S3011: Guest allocates a memory page, and the memory address is sent to VMM via MSR;
[0034] Step S3012: The VMM writes the Host system time to a memory page;
[0035] Step S3013: Read and update the system time via Guest.
[0036] Specifically, the high-precision timer in step S4 includes the following steps:
[0037] Step S401: Define a high-precision structure and initialize it;
[0038] Step S402: Specify the callback function for the high-precision timer expiration, set the timer expiration time, and start the timer;
[0039] Step S403: When the timer finishes its work or needs to be modified, the high-precision cancellation function is used to modify or cancel it.
[0040] Specifically, step S5 includes the following steps:
[0041] Step S501: The shell thread initiates a CPU shutdown command and wakes up the perCPU thread in the kernel to perform hot-plugging and execute the actual state machine processing flow;
[0042] Step S502: The hot-swappable thread sets the CPU to an invalid state and enables the balancing thrust mechanism, so that the process on that CPU performs the balancing thrust operation in the scheduler flow and migrates itself to other CPUs.
[0043] Step S503: After the process migration is completed, the scheduler wakes up the hot-plug thread, the hot-plug thread wakes up the shell process to complete the state machine callback, and exits execution, setting it to a paused state;
[0044] Step S504: After the shell process is woken up, it runs on another CPU and executes the takedown_CPU process;
[0045] Step S505: The idle process detects that the CPU is offline and begins to execute the CPU suicide process;
[0046] Step S506: Wake up the shell thread and continue the remaining work after the CPU went offline.
[0047] Specifically, step S505 includes the following steps:
[0048] Step S5051: Disable the dynamic interrupt clock of the idle process itself, thereby killing the process itself;
[0049] Step S5052: Wake up the shell thread and continue executing the remaining state machine callbacks;
[0050] Step S5053: Call the CPU power-down interface of psci to complete the power-down process of the CPU.
[0051] A virtual machine (VCPU) hang detection system for cloud computing scenarios includes: a VMM module, an MMIO module, an I / O hardware abstraction module, a KVM module, an NTPT module, and a hot-plug mechanism module.
[0052] The VMM module is used to virtualize the CPU and memory, and is responsible for managing and allocating the physical memory of each virtual machine and maintaining the program environment.
[0053] The MMIO module is used to access I / O devices and map the registers of the I / O devices to the physical memory address space.
[0054] The I / O hardware abstraction module is used to enable data transmission via RTE, which is completely independent of ECU hardware;
[0055] The KVM module is used to control computer peripherals of multiple servers or computer hosts;
[0056] The NTPT module is used to synchronize the clocks between the client and the server;
[0057] The hot-swap mechanism module is used to remove and replace damaged hard drives, power supplies, or circuit boards without shutting down the system or cutting off the power.
[0058] Specifically, an electronic device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of a method for detecting virtual machine (VCPU) hangs in a cloud computing scenario.
[0059] Specifically, a computer-readable storage medium is characterized in that it stores computer instructions, which, when executed, perform the steps of a method for detecting virtual machine (VCPU) hangup in a cloud computing scenario.
[0060] Compared with the prior art, the beneficial effects of the present invention are:
[0061] 1. This invention proposes a detection system for virtual machine (VCPU) hangs in a cloud computing scenario, and optimizes and improves its architecture, operation steps, and processes. The system has the advantages of simple process, low investment and operating costs, and low production and operation costs, which improves high availability and automated operation and maintenance capabilities of cloud services and reduces enterprise costs.
[0062] 2. This invention proposes a method for detecting virtual machine vCPU hangs in a cloud computing scenario, which can effectively identify the inaccurate interpretation problem caused by the slow time issue in the detection of virtual machine run-down anomalies.
[0063] 3. This invention proposes a method for detecting virtual machine (VCPU) hangs in a cloud computing scenario. Compared with watchdog mechanisms, soft locking, and hard locking, this invention can sense its own scheduling behavior, effectively identify the pause and recovery problems of VCPU caused by task scheduling of the host host in the abnormal detection of the virtual machine, accurately calculate the scheduling delay, and avoid the VCPU scheduling delay caused by high load of the host host being mistakenly judged as Guest hang.
[0064] 4. This invention proposes a method for detecting virtual machine (VCPU) hangs in a cloud computing scenario. It employs a hot-swapping mechanism and a per-CPU approach to detect VCPUs in the Guest instance, avoiding service interruptions caused by full monitoring. Attached Figure Description
[0065] Figure 1 This is a flowchart of a method for detecting virtual machine vCPU hangup in a cloud computing scenario according to the present invention.
[0066] Figure 2 The present invention provides a system flowchart for a method to detect virtual machine vCPU hangup in a cloud computing scenario.
[0067] Figure 3 This invention provides a method for detecting virtual machine vCPU hangup in a cloud computing scenario, including a flowchart of vCPU pausing state detection.
[0068] Figure 4 This is an architecture diagram of a virtual machine vCPU hangup detection system in a cloud computing scenario according to the present invention.
[0069] Figure 5 The present invention relates to an electronic device diagram of a method and system for detecting virtual machine (vcpu) hangup in a cloud computing scenario. Detailed Implementation
[0070] To facilitate understanding of the technical means, creative features, and achieved objectives and effects of this invention, it should be noted in the description of this invention that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "number one," "number two," and "number three" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The invention will be further described below in conjunction with specific embodiments.
[0071] Example 1
[0072] Please see Figures 1-3 The present invention provides an embodiment of a method for detecting virtual machine (vCPU) hangup in a cloud computing scenario, comprising the following steps:
[0073] Step S1: Create an MMIO region in the backend of the VMM for memory mapping, and make the VMM recognize the region by adding a configuration file;
[0074] Step S2: Perform I / O hardware abstraction and register devices on the memory bus using a device tree approach to provide memory regions to the virtual machine;
[0075] The ECU abstraction layer includes: onboard device abstraction, memory hardware abstraction, communication hardware abstraction, and I / O hardware abstraction. I / O hardware abstraction is a set of software modules used to abstract the input and output signals of the ECU hardware. The abstracted signals are the physical values of the ECU input / output signals, which can be provided to other SWCs via the RTE. The I / O hardware abstraction module consists of two parts: an I / O signal interface module and an external chip driver module. The I / O signal interface module provides the interface signals between the I / O hardware abstraction module and the application layer SWC, and performs signal abstraction. The external chip driver module is used to drive external chips and can call modules in multiple MCALs, but does not directly interface with the RTE.
[0076] Step S3: Start the internal clock, calculate the internal clock decrement time, and adjust the internal clock according to the extracted visitor time;
[0077] Step S4: Using the misc device, start a high-precision timer to periodically send heartbeat messages. After sending, the virtual machine enters the VMM and reads the vcpu status through the VMM.
[0078] The misc device includes: 1) a misc device is a special character device; 2) device nodes can be automatically generated; 3) the major device number is 10; 4) the allocation of minor device numbers and the creation of device files can be completed simply by calling misc_register().
[0079] Step S5: Register the CPU hot-swap mechanism to ensure that the vCPU in the suspended state is offline and enters a deadlock state.
[0080] Deadlock refers to a situation where two or more processes are blocked during execution due to competition for resources or communication issues, and they cannot proceed without external intervention.
[0081] The conditions necessary for deadlock to occur are:
[0082] 1) Mutual exclusion: This means that a process can use a resource exclusively, meaning that a resource can only be used by one process at a time. If other processes request the resource, they must wait until the process holding the resource finishes using it and releases it.
[0083] 2) Hold and hold condition: This refers to a process that has already held at least one resource, but then makes a new resource request, which has already been held by another process. In this case, the requesting process is blocked, but it still holds onto the other resources it has already acquired.
[0084] 3) No preemption condition: This means that resources already acquired by a process cannot be taken away before it has finished using them; they can only be released by the process itself when it is finished using them.
[0085] 4) Circular wait condition: This means that when a deadlock occurs, there must be a circular chain of processes, i.e., resources.
[0086] The specific steps of step S1 include:
[0087] Step S101: Create an MMIO emulation device in the VMM backend and integrate the device emulation into the VMM;
[0088] The working methods of device simulation are: 1) Integrating device simulation into the VMM; 2) Performing device simulation in an application outside the VMM.
[0089] Step S102: Set the MMIO region register parameters.
[0090] The specific steps for creating the MMIO analog device in step S101 include:
[0091] Step S1011: Define MMIO memory and identify it when the Guest memory exits due to a page fault;
[0092] Step S1012: Create a virtual machine through the KVM driver, allocate virtual memory and read / write and run vcpu registers, and then simulate the virtual machine user space components through QEMU;
[0093] KVM (Kernel-based Virtual Machine) virtualization has two core modules: 1) the KVM kernel module, responsible for CPU and memory virtualization, including VM creation, memory allocation and management, and vCPU execution mode switching; 2) QEMU device emulation, which implements I / O virtualization and device emulation, interacting with the KVM kernel through the IOCTL system call. Existing research on cloud desktop GPU virtualization technology based on the KVM architecture mainly focuses on utilizing the KVM architecture and physical graphics processing unit (GPU) devices to design a cloud desktop model capable of providing services to multiple client machines, based on QEUM emulation, and then applying this model to a selected host. Existing technology also includes optimization of the Loongson KVM virtual machine I / O interrupt subsystem. This analysis examines the performance bottlenecks of the I / O interrupt subsystem in the KVM virtual machine and, based on the implementation of a virtual I / O interrupt controller in KVM, further optimizes it using read-only page tables instead of traps and virtualization-like techniques. By using the KVM module to set the clock source, combined with the VMM module, high-precision timers, and hot-swappable mechanisms, it is possible to observe at the vCPU level, avoiding the complexity introduced by tracking all virtual machines, and improving availability and cloud service monitoring and maintenance capabilities.
[0094] The elements of QEMU / KVM MMIO emulation include: 1) emulating the behavior of Guest reading and writing memory; 2) monitoring the virtual machine's reading and writing of MMIO memory and triggering the execution of the corresponding callback function.
[0095] Step S1013: QEMU and KVM drivers obtain and execute the read and write instructions before the Guest exits, and implement MMIO logic simulation in the virtual environment to complete the memory read and write simulation of the Guest, and save it in virtual memory and the corresponding virtual user space;
[0096] Step S1014: After completing the simulation, return to the QEMU user status, trigger the MMIO read / write callback registered in the user status, and complete the MMIO device simulation.
[0097] The specific steps of the method for registering a device on the memory bus in the device tree mode in step S2 include:
[0098] Step S201: Add a node in the device tree and perform flashing to confirm the existence and compatibility of relevant nodes in the device;
[0099] The work content of the device tree includes: describing the attributes, connection methods, and resource libraries of hardware components, and providing an interface for the operating system to access through device tree nodes.
[0100] Step S202: Initialize the platform driver structure and construct the probe function in the structure;
[0101] Step S203: Use the platform driver registration function to complete the registration of the platform driver, and use the of function of the probe function to obtain the parameters of the node;
[0102] Step S204: Determine whether the device is successfully registered by comparing the device tree node and the parameter value directory.
[0103] The specific steps of step S3 include:
[0104] Step S301: Set the KVM clock source and start the internal clock using the virtual threads managed by KVM;
[0105] Common internal clocks include: RTC, PIT, TSC, HPET, PM, Hyper-V, kvm-clock. The clock frequencies of different clocks are different, and the accuracy is also affected by the clock frequency and is different. There are also differences in the recommended usage levels: 1) In the physical machine environment, the order of clock source accuracy is TSC < HPET < ACPI_PM; 2) In the virtual machine environment, the order of clock source accuracy is kvm-clock = Hyper-V < TSC < ACPI_PM < HPET. The smaller the clock source accuracy, the more accurate the time reading.
[0106] Among them, kvm-clock avoids the Guest virtual machine losing an accurate clock, which may cause abnormalities in network applications and processes, session verification, migration, and other network activities that depend on timestamps.
[0107] Step S302: Complete the interaction between the virtual thread and the MMIO area and update the register according to the register format;
[0108] Step S303: Implement clock synchronization through NTPT, use the timestamp counter to calculate the internal clock decrement time, and adjust the internal clock according to the extracted guest time.
[0109] The mechanism for guest virtual machine time synchronization includes: 1) When the guest system starts, it reads the time from the emulated real time clock (RTC); 2) After NTP is initialized, the guest clock is automatically synchronized; 3) When the guest resumes after pausing or resuming the process, the management software issues an instruction to synchronize the guest clock to a specified value. The guest clock synchronization value is usually the host machine's clock value.
[0110] The specific steps for setting the KVM clock source in step S301 include:
[0111] Step S3011: Guest allocates a memory page, and the memory address is sent to VMM via MSR;
[0112] Step S3012: The VMM writes the Host system time to a memory page;
[0113] Step S3013: Read and update the system time via Guest.
[0114] The specific steps of the high-precision timer in step S4 include:
[0115] Step S401: Define a high-precision structure and initialize it;
[0116] Step S402: Specify the callback function for the high-precision timer expiration, set the timer expiration time, and start the timer;
[0117] Step S403: When the timer finishes its work or needs to be modified, the high-precision cancellation function is used to modify or cancel it.
[0118] The specific steps of step S5 include:
[0119] Step S501: The shell thread initiates a CPU shutdown command and wakes up the perCPU thread in the kernel to perform hot-plugging and execute the actual state machine processing flow;
[0120] Step S502: The hot-swappable thread sets the CPU to an invalid state and enables the balancing thrust mechanism, so that the process on the CPU performs the balancing thrust operation in the scheduler flow and migrates itself to other CPUs.
[0121] Step S503: After the process migration is completed, the scheduler wakes up the hot-plug thread, the hot-plug thread wakes up the shell process to complete the state machine callback, and exits execution, setting it to a paused state;
[0122] Step S504: After the shell process is woken up, it runs on another CPU and executes the takedown_CPU process;
[0123] Step S505: The idle process detects that the CPU is offline and begins to execute the CPU suicide process;
[0124] Step S506: Wake up the shell thread and continue the remaining work after the CPU went offline.
[0125] The specific steps of step S505 include:
[0126] Step S5051: Disable the dynamic interrupt clock of the idle process itself, thereby killing the process itself;
[0127] Step S5052: Wake up the shell thread and continue executing the remaining state machine callbacks;
[0128] Step S5053: Call the CPU power-down interface of psci to complete the power-down process of the CPU.
[0129] Example 2
[0130] Please see Figure 4 Another embodiment of the present invention provides: a detection system for virtual machine (vCPU) hangup in a cloud computing scenario, comprising:
[0131] VMM module, MMIO module, I / O hardware abstraction module, KVM module, NTPT module, hot-swappable mechanism module;
[0132] The VMM module is used to virtualize the CPU and memory, and is responsible for managing and allocating the physical memory of each virtual machine and maintaining the program environment.
[0133] The MMIO module is used to access I / O devices and map the registers of the I / O devices to the physical memory address space.
[0134] The I / O hardware abstraction module is used to enable data transmission via RTE, which is completely independent of ECU hardware;
[0135] The KVM module is used to control computer peripherals of multiple servers or computer hosts;
[0136] The NTPT module is used to synchronize the clocks between the client and the server;
[0137] The hot-swap mechanism module is used to remove and replace damaged hard drives, power supplies, or circuit boards without shutting down the system or cutting off the power.
[0138] Example 3
[0139] Please see Figure 5An electronic device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of a method for detecting virtual machine (VCPU) hangs in a cloud computing scenario.
[0140] A computer-readable storage medium is characterized in that it stores computer instructions thereon, which, when executed, perform the steps of a method for detecting virtual machine (VCPU) hangup in a cloud computing scenario.
[0141] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0142] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0143] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0144] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0145] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method for detecting virtual machine (vCPU) hangup in a cloud computing scenario, characterized in that, include: Step S1: Create an MMIO region in the backend of the VMM for memory mapping, and make the VMM recognize the region by adding a configuration file; Step S2: Perform I / O hardware abstraction and register devices on the memory bus using a device tree approach to provide memory regions to the virtual machine; Step S3: Start the internal clock, calculate the internal clock decrement time, and adjust the internal clock according to the extracted visitor time; Step S4: Using the misc device, start a high-precision timer to periodically send heartbeat messages. After sending, the virtual machine enters the VMM and reads the vcpu status through the VMM. Step S5: Register the CPU hot-swap mechanism to ensure that the vCPU in the suspended state is offline and enters a deadlock state.
2. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 1, characterized in that, The specific steps of step S1 include: Step S101: Create an MMIO emulation device in the VMM backend and integrate the device emulation into the VMM; Step S102: Set the MMIO region register parameters.
3. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 2, characterized in that, The specific steps for creating the MMIO simulation device in step S101 include: Step S1011: Define MMIO memory and identify it when the Guest memory exits due to a page fault; Step S1012: Create a virtual machine through the KVM driver, allocate virtual memory and read / write and run vcpu registers, and then simulate the virtual machine user space components through QEMU; Step S1013: QEMU and KVM drivers obtain and execute the read and write instructions before the Guest exits, and implement MMIO logic simulation in the virtual environment to complete the memory read and write simulation of the Guest, and save it in virtual memory and the corresponding virtual user space; Step S1014: After completing the simulation, return to the QEMU user status, trigger the MMIO read / write callback registered in the user status, and complete the MMIO device simulation.
4. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 3, characterized in that, The specific steps of registering devices on the memory bus using the device tree approach in step S2 include: Step S201: Add nodes to the device tree and flash them, and confirm the existence and compatibility of relevant nodes in the device; Step S202: Initialize the platform driver structure and construct the probe function in the structure; Step S203: Use the platform driver registration function to complete the platform driver registration, and use the of function of the probe function to obtain the node parameters; Step S204: Determine whether the device registration was successful by comparing the device tree nodes and parameter value directory.
5. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 4, characterized in that, The specific steps of step S3 include: Step S301: Set the KVM clock source and start the internal clock using the virtual thread managed by KVM; Step S302: Complete the interaction between the virtual thread and the MMIO region, and update the registers according to the register format; Step S303: Achieve clock synchronization through NTPT, use a timestamp counter to calculate the internal clock decrement time, and adjust the internal clock according to the extracted visitor time.
6. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 5, characterized in that, The specific steps for setting the KVM clock source in step S301 include: Step S3011: Guest allocates a memory page, and the memory address is sent to VMM via MSR; Step S3012: The VMM writes the Host system time to a memory page; Step S3013: Read and update the system time via Guest.
7. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 6, characterized in that, The specific steps of the high-precision timer in step S4 include: Step S401: Define a high-precision structure and initialize it; Step S402: Specify the callback function for the high-precision timer expiration, set the timer expiration time, and start the timer; Step S403: When the timer finishes its work or needs to be modified, the high-precision cancellation function is used to modify or cancel it.
8. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 7, characterized in that, The specific steps of step S5 include: Step S501: The shell thread initiates a CPU shutdown command and wakes up the perCPU thread in the kernel to perform hot-plugging and execute the actual state machine processing flow; Step S502: The hot-swappable thread sets the CPU to an invalid state and enables the balancing thrust mechanism, so that the process on the CPU performs the balancing thrust operation in the scheduler flow and migrates itself to other CPUs. Step S503: After the process migration is completed, the scheduler wakes up the hot-plug thread, the hot-plug thread wakes up the shell process to complete the state machine callback, and exits execution, setting it to a paused state; Step S504: After the shell process is woken up, it runs on another CPU and executes the takedown_CPU process; Step S505: The idle process detects that the CPU is offline and begins to execute the CPU suicide process; Step S506: Wake up the shell thread and continue the remaining work after the CPU went offline.
9. The method for detecting virtual machine (vCPU) hangup in a cloud computing scenario as described in claim 8, characterized in that, The specific steps of step S505 include: Step S5051: Disable the dynamic interrupt clock of the idle process itself, thereby killing the process itself; Step S5052: Wake up the shell thread and continue executing the remaining state machine callbacks; Step S5053: Call the CPU power-down interface of psci to complete the power-down process of the CPU.
10. A detection system for virtual machine (VCPU) hangup in a cloud computing scenario, implemented based on the detection method for virtual machine (VCPU) hangup in a cloud computing scenario according to any one of claims 1-9, characterized in that, include: VMM module, MMIO module, I / O hardware abstraction module, KVM module, NTPT module, hot-plug mechanism module. The VMM module is used to virtualize the CPU and memory, and is responsible for managing and allocating the physical memory of each virtual machine and maintaining the program environment. The MMIO module is used to access I / O devices and map the registers of the I / O devices to the physical memory address space. The I / O hardware abstraction module is used to enable data transmission via RTE, which is completely independent of ECU hardware; The KVM module is used to control computer peripherals of multiple servers or computer hosts; The NTPT module is used to synchronize the clocks between the client and the server; The hot-swap mechanism module is used to remove and replace damaged hard drives, power supplies, or circuit boards without shutting down the system or cutting off the power.
11. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method for detecting virtual machine (vcpu) hangup in a cloud computing scenario as described in any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, It stores computer instructions, which, when executed, perform the steps of the method for detecting virtual machine (vcpu) hangup in a cloud computing scenario as described in any one of claims 1-9.