Virtual machine fault information storage method and device, storage medium and electronic equipment
By obtaining and converting the fault information of a virtual machine when it fails, and saving it to the host, it solves the problem of difficulty in obtaining fault information inside the virtual machine, achieves fast and efficient fault location, and reduces the storage space occupied by the virtual machine.
Patent Information
- Application Number
- CN202310202906.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-30
AI Technical Summary
When an internal fault occurs in a virtual machine, kernel or user mode fault information cannot be obtained, making fault location difficult and posing security risks and economic losses.
When a virtual machine fails, obtain its internal fault information, convert the physical address to the virtual address of the host, and save it to the host to realize the storage of fault information and avoid the failure of the virtual machine even if the virtual machine does not support the kdump service. Perform fault location.
Faults can be located without entering the virtual machine, saving fault location time and cost, and not occupying virtual machine storage space, improving fault location efficiency.
Smart Images

Figure CN118567779A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, storage medium and electronic device for storing virtual machine fault information. Background Art
[0002] The use of virtualization technology can effectively reduce management costs, improve resource utilization and system compatibility, and has strong usability and portability. With the rapid development of virtualization technology, virtual machines have been widely used in the commercial field.
[0003] However, when a fault occurs inside a virtual machine, it is impossible to obtain kernel or user-mode fault information due to insufficient storage space or the absence of a kdump service (kdump refers to a tool and service used to dump memory operating parameters when the system crashes, deadlocks, or freezes). This makes it difficult to locate the virtual machine fault, which can cause great safety risks and economic losses.
[0004] With respect to the above-mentioned problems existing in the related technologies, no effective solutions have been found so far. Summary of the invention
[0005] Embodiments of the present application provide a method, device, storage medium, and electronic device for storing virtual machine fault information.
[0006] According to one aspect of an embodiment of the present application, a method for saving virtual machine fault information is provided, comprising: when a virtual machine fails, obtaining internal fault information of the virtual machine, wherein the virtual machine runs on a host machine; converting the physical address of the virtual machine in the internal fault information into a virtual address of the host machine; obtaining the internal fault information of the virtual machine based on the virtual address, and saving the internal fault information in the host machine.
[0007] Optionally, before obtaining the internal fault information of the virtual machine, the method also includes: receiving a fault save signal sent by a fault notification device calling an exception notification function, wherein the fault notification device is a driver module inside the virtual machine operating system, and the exception notification function is registered on the notification chain of the virtual machine operating system crash process, and is used to instruct fault saving when the virtual machine fails; responding to the fault save signal, confirming the acquisition of the internal fault information of the virtual machine.
[0008] Optionally, obtaining the internal fault information of the virtual machine includes: obtaining, from the physical memory of the virtual machine, internal fault information sent by the virtual machine using a first physical address, wherein the physical memory is used to store the runtime fault information of the virtual machine, and the internal fault information includes kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter.
[0009] Optionally, before obtaining internal fault information sent by the virtual machine using the first physical address from the physical memory of the virtual machine, the method includes: creating a physical memory of circular storage in the virtual machine, and configuring the first address of the physical memory as the first physical address; configuring a second physical address and a first configuration parameter about kernel fault information in the physical memory through the read-write interface of the virtual machine, and configuring a third physical address and a second configuration parameter about user state fault information.
[0010] Optionally, converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine includes: obtaining a first physical address in the internal fault information, and converting the first physical address into a first virtual address of the host machine; based on the first virtual address, obtaining kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter from the internal fault information; converting the second physical address into a second virtual address of the host machine; and converting the third physical address into a third virtual address of the host machine.
[0011] Optionally, obtaining internal fault information of the virtual machine according to the virtual address and saving the internal fault information to the host machine includes: obtaining kernel log information and user state information of the virtual machine according to the virtual address; and saving the kernel log information and the user state information to the host machine.
[0012] Optionally, saving the kernel log information and the user state information to the host machine includes: determining the time when the failure of the virtual machine occurs; and saving the kernel log information and the user state information to the host machine according to the time when the failure occurs.
[0013] According to another aspect of an embodiment of the present application, a device for saving virtual machine fault information is provided, including: an acquisition module, used to obtain internal fault information of the virtual machine when a fault occurs in the virtual machine, wherein the virtual machine runs on a host machine; a conversion module, used to convert the physical address of the virtual machine in the internal fault information into a virtual address of the host machine; and a storage module, used to obtain the internal fault information of the virtual machine according to the virtual address, and save the internal fault information to the host machine.
[0014] Optionally, the device also includes: a receiving module, used to receive a fault save signal sent by a fault notification device calling an exception notification function, wherein the fault notification device is a driver module inside the virtual machine operating system, and the exception notification function is registered on the notification chain of the virtual machine operating system crash process, and is used to instruct fault saving when the virtual machine fails; a confirmation module, used to respond to the fault save signal and confirm the acquisition of internal fault information of the virtual machine.
[0015] Optionally, the acquisition module also includes: a first acquisition unit, used to obtain internal fault information sent by the virtual machine using a first physical address from the physical memory of the virtual machine, wherein the physical memory is used to store the runtime fault information of the virtual machine, and the internal fault information includes kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter.
[0016] Optionally, the acquisition module also includes: a creation unit, used to create a physical memory of circular storage in the virtual machine, and configure the first address of the physical memory as a first physical address; a configuration unit, used to configure a second physical address and a first configuration parameter about kernel fault information in the physical memory through the read-write interface of the virtual machine, and configure a third physical address and a second configuration parameter about user state fault information.
[0017] Optionally, the conversion module includes: a first conversion unit, used to obtain a first physical address in the internal fault information, and convert the first physical address into a first virtual address of the host machine; a second acquisition unit, used to obtain kernel fault information stored using a second physical address and first configuration parameters, and user-state fault information stored using a third physical address and second configuration parameters from the internal fault information based on the first virtual address; a second conversion unit, used to convert the second physical address into a second virtual address of the host machine; and a third conversion unit, used to convert the third physical address into a third virtual address of the host machine.
[0018] Optionally, the storage module includes: a third acquisition unit, used to obtain kernel log information and user state information of the virtual machine according to the virtual address; and a storage unit, saving the kernel log information and the user state information to the host machine.
[0019] Optionally, the storage unit includes: a storage subunit, used to determine the time when the failure of the virtual machine occurs; and save the kernel log information and the user state information to the host machine according to the time when the failure occurs.
[0020] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0021] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0022] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0023] Through the present application, when a virtual machine fails, internal fault information of the virtual machine is obtained, wherein the virtual machine runs on a host machine; the physical address of the virtual machine in the internal fault information is converted into a virtual address of the host machine; the internal fault information of the virtual machine is obtained according to the virtual address, and the internal fault information is saved in the host machine, thereby realizing the storage of the virtual machine fault information, obtaining the fault information and storing it on the host machine, and even in the case where the virtual machine does not support the kdump service, the fault can be located according to the fault information stored on the host machine, thereby eliminating the need to enter the virtual machine, effectively saving the time cost of fault location, and the stored fault information does not occupy the virtual machine memory, thus saving the virtual machine storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 is a hardware structure block diagram of a computer according to an embodiment of the present application;
[0026] Figure 2is a flow chart of a method for storing virtual machine fault information according to an embodiment of the present application;
[0027] Figure 3 It is a system structure diagram in an implementation scenario according to the first embodiment of the present application;
[0028] Figure 4 It is a flow chart of a method for storing virtual machine fault information in an implementation scenario according to the first embodiment of the present application;
[0029] Figure 5 It is a structural block diagram of a device for storing virtual machine fault information according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] Example 1
[0033] The method embodiment provided in the first embodiment of the present application can be executed in a server, a computer, a mobile phone, or a similar computing device. Taking running on a computer as an example, Figure 1 is a hardware structure block diagram of a computer in an embodiment of the present application. Figure 1 As shown, the computer may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the computer may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer. For example, the computer may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0034] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a method for preserving virtual machine fault information in an embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0035] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] In this embodiment, a method for storing virtual machine fault information is provided. Figure 2 is a flow chart of a method for storing virtual machine fault information according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:
[0037] S1, when a virtual machine fails, obtaining internal fault information of the virtual machine, wherein the virtual machine runs on a host machine;
[0038] The application scenario of the embodiment of the present application is a host machine that supports virtualization scenarios, which can be a physical server or computer. At the same time, a virtual machine needs to be installed on a physical device, and can be applied to a virtualized environment with one or more virtual machines. Among them, a virtual machine refers to a complete computer system with complete hardware system functions that is simulated by software in a host machine and runs in a completely isolated environment. The host machine includes but is not limited to a physical server or computer that can support virtualization scenarios, including a central processing unit, a disk, a network card and other hardware devices.
[0039] The execution subject of the embodiments of the present application can be a host machine, or it can be other computers, servers or similar computing devices with computing processing capabilities, such as a virtual machine monitor, a software layer installed on the physical hardware of the host machine, used to create and run virtual machine software, firmware or hardware, and provide a virtual operating platform to run and manage virtual machine operating systems.
[0040] A fault saving device is provided on the virtual machine monitor, wherein the fault saving device is a virtual device of the virtual machine monitor, and is used to save the last words or key logs of the kernel or user state before the virtual machine is abnormal.
[0041] When a virtual machine fails, such as downtime or crashes, a fault saving device on the virtual machine monitor obtains internal fault information of the virtual machine and saves the fault information in the host machine.
[0042] S2, converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine;
[0043] For the virtual machine monitor, it is in charge of the actual physical memory, and needs to allocate and manage the physical memory of each virtual machine. When virtualization is turned on, the physical address of the virtual machine cannot be directly sent to the system bus. It needs to be converted into an actual physical address by the virtual machine monitor before being handed over to the physical processor for execution. Therefore, in this example, after obtaining the fault information of the virtual machine, it is necessary to convert the physical address of the virtual machine in the fault information into the virtual address of the host machine. The conversion method can be achieved by establishing a mapping table between the physical address of the virtual machine and the virtual address of the host machine, and converting the physical address of the virtual machine into the virtual address of the host machine according to the mapping relationship in the mapping table.
[0044] S3, obtaining internal fault information of the virtual machine according to the virtual address, and saving the internal fault information to the host machine.
[0045] Afterwards, the fault saving device obtains information about the virtual machine fault from the information after the address conversion, and saves the fault information in the host machine.
[0046] The embodiment of the present application obtains the internal fault information of the virtual machine, converts the physical address of the virtual machine in the internal fault information into the virtual address of the host machine, and saves the internal fault information in the host machine, thereby realizing the storage of the virtual machine fault information. By storing the fault information on the host machine, even if the virtual machine does not support the kdump service, the fault can be located based on the fault information stored on the host machine without entering the virtual machine, thus effectively saving the time cost of fault location. In addition, the stored fault information does not occupy the virtual machine memory, thus saving the storage space of the virtual machine.
[0047] In an implementation manner of this embodiment, S1, before obtaining internal fault information of the virtual machine, the method further includes:
[0048] S01, receiving a fault saving signal sent by a fault notification device calling an abnormal notification function, wherein the fault notification device is a driver module inside the virtual machine operating system, and the abnormal notification function is registered in the notification chain of the virtual machine operating system crash process, and is used to instruct to perform fault saving when the virtual machine fails;
[0049] In this example, the virtual machine is provided with a fault notification device, which is a driver module inside the virtual machine operating system. The fault notification device can be abstracted as a character device to notify the fault saving device in the virtual machine monitor to perform fault saving when the virtual machine operating system crashes.
[0050] When a fault occurs inside the virtual machine, the fault notification device inside the virtual machine will be triggered to call the abnormal notification function registered in the abnormal process of the virtual machine to send a fault saving signal, notifying the fault saving device in the virtual machine monitor to save the fault information.
[0051] S02, responding to the fault saving signal, confirming to obtain the internal fault information of the virtual machine.
[0052] After receiving the fault saving signal sent by the fault notification device, the fault saving device responds to the signal, obtains the internal fault information of the virtual machine, and saves the fault information in the host machine.
[0053] The embodiment of the present application saves the fault by receiving a fault saving signal sent by a fault notification device in a virtual machine using an abnormal notification function, so that the fault saving is more timely.
[0054] In another example, when an application process crashes, the application program may write fault information to the read / write interface of the fault notification device, actively triggering the abnormal notification function of the notification device to send a signal to notify the fault saving device in the virtual machine monitor.
[0055] In one example, S1, obtaining internal fault information of the virtual machine includes:
[0056] S11, obtaining internal fault information sent by the virtual machine using the first physical address from the physical memory of the virtual machine, wherein the physical memory is used to store the runtime fault information of the virtual machine, and the internal fault information includes kernel fault information stored using the second physical address and the first configuration parameter, and user state fault information stored using the third physical address and the second configuration parameter.
[0057] The first physical address is the physical first address of the memory in the virtual machine fault notification device for storing the virtual machine runtime fault information, and can be set when the virtual machine is initialized.
[0058] User state and kernel state are aimed at setting different scopes of permissions for resource protection. When executing in user state, the memory space and objects that a process can access are limited, and the processor it occupies can be preempted. When executing in kernel state, it can access all memory spaces and objects, and the processor it occupies cannot be preempted.
[0059] In this example, the second physical address and the first configuration parameters are used to store kernel fault information when the virtual machine fails, and the third physical address and the second configuration parameters are used to store user state fault information when the virtual machine fails. The second physical address is the physical first address for storing the virtual machine kernel fault information, the third physical address is the physical first address for storing the user state fault information, and the configuration parameters are the data format, content, length, etc. of the fault information storage. The physical address and configuration parameters can be configured through the read and write interface of the virtual machine.
[0060] In one example, before obtaining internal fault information sent by the virtual machine using the first physical address from the physical memory of the virtual machine, the method includes:
[0061] Creating a physical memory of a ring storage in the virtual machine, and configuring a first address of the physical memory as a first physical address;
[0062] Ring storage refers to a continuous data storage area that is customized or dynamically allocated. Data is read and written in this continuous storage area through the head and tail indexes, thus forming a closed loop for this continuous data storage area. In this example, the host machine starts normally, the virtualization environment is successfully configured, the virtual machine operating system is started, and the fault notification device in the virtual machine applies for a memory segment for storing virtual machine runtime fault information, which is managed in a ring storage manner, and the physical first address of the memory segment is configured as the first physical address GPA1, where GPA, the full name of which is Guest Physical Address, represents the physical address of the virtual machine.
[0063] A second physical address and a first configuration parameter regarding kernel fault information are configured in the physical memory through the read / write interface of the virtual machine, and a third physical address and a second configuration parameter regarding user state fault information are configured.
[0064] The fault notification device on the virtual machine provides a kernel state and user state read and write interface, through which the kernel fault information physical first address GPA2 and related parameters args are transmitted. a (i.e. the first configuration parameter) and the virtual machine user state fault information physical first address GPA3 and related parameters args b (i.e., the second configuration parameter) is saved to the physical memory of the ring storage. Among them, the first configuration parameter args of the kernel fault information a ={arg a0 ,arg a1 ,arg a2 ,...}, respectively, the kernel state log content, log line number, log level, log current readable index number, log readable location, log current writable index number, log writable location, etc., the second configuration parameter args of user state fault information b ={arg b0 ,arg b1 ,arg b2 ,...}, which are respectively the user-mode log content, log line number, log level, current readable log index number, log readable location, current writable log index number, log writable location, etc.
[0065] The embodiment of the present application realizes the creation of physical memory, physical address and configuration parameters.
[0066] In one example, S2, converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine, includes:
[0067] S21, obtaining a first physical address in the internal fault information, and converting the first physical address into a first virtual address of a host machine;
[0068] The first physical address is the first physical memory address of the virtual machine. GPA1 is transmitted to the fault saving device through the input and output ports. The fault saving device converts GPA1 into a virtual address HVA1 in the host machine, wherein HVA stands for HostVirtual Address, which represents the host machine virtual address.
[0069] S22, acquiring, based on the first virtual address, from the internal fault information, kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter;
[0070] After converting GPA1 to HVA1, the host uses HVA1 to retrieve the physical address GPA2 of the kernel state fault information, the physical address GPA3 of the user state fault information, and the related parameters args a and args b .
[0071] S23, converting the second physical address into a second virtual address of the host machine;
[0072] S24, converting the third physical address into a third virtual address of the host machine.
[0073] According to the mapping relationship in the mapping table, GPA2 and GPA3 are converted into virtual addresses HVA2 and HVA3 in the host machine respectively.
[0074] This embodiment realizes the conversion between the physical address of the virtual machine and the virtual address of the host machine.
[0075] In one example, S3, obtaining internal fault information of the virtual machine according to the virtual address, and saving the internal fault information to the host machine, includes:
[0076] S31, obtaining kernel log information and user state information of the virtual machine according to the virtual address;
[0077] S32, saving the kernel log information and the user state information to the host machine.
[0078] After converting the virtual machine's physical addresses GPA2 and GPA3 to the virtual addresses HVA2 and HVA3 in the host machine, this example is based on HVA2, HVA3, args a and args b Obtain the contents of the virtual machine kernel log information and user state information, such as the kernel state and user state log contents, log line number, log level, current readable log index number, log readable location, current writable log index number, log writable location, etc. when the above failure occurs, and save them to the host machine.
[0079] In one implementation, S32, saving the kernel log information and the user state information to the host machine, includes:
[0080] S321, determining the time when the failure of the virtual machine occurs;
[0081] In this example, the fault information of the virtual machine is managed according to time. You can determine the time when the fault occurred by querying the log information.
[0082] S322: Save the kernel log information and the user state information to the host machine according to the fault occurrence time.
[0083] The fault information is saved according to the time when the fault occurred. For example, a suffix representing the fault time is added to the file name of the fault information, and the kernel log information and user state information are stored in chronological order.
[0084] In this example, the fault information is managed according to the fault occurrence time, so that the storage of the fault information is more standardized and clear.
[0085] The following is a complete explanation of the embodiments of the present application through an implementation scenario.
[0086] Reference Figure 3 , Figure 3 This is a system structure diagram according to the implementation scenario of the first embodiment of the present application, such as Figure 3 As shown, the system includes: a host machine 101, a virtual machine monitor 102, a virtual machine 103, a virtual machine operating system 104, a fault notification device 105 and a fault storage device 106, wherein:
[0087] Host machine 101, which includes but is not limited to a physical server or computer with hardware devices such as a central processing unit, a disk and a network card, and can support virtualization scenarios;
[0088] A virtual machine monitor 102, which is used to create and run software, firmware or hardware of a virtual machine, and provides a virtual operation platform to run and manage the virtual machine operating system;
[0089] The virtual machine 103 is a complete computer system with complete hardware system functions and running in a completely isolated environment, which is simulated by software in the host machine 101;
[0090] A virtual machine operating system 104, used to manage and control the hardware and software resources of the host machine 101;
[0091] The fault notification device 105 is a driver module inside the virtual machine operating system 104, and is used to notify the fault saving device in the virtual machine monitor 102 when 104 crashes;
[0092] The fault saving device 106 is a virtual device of the virtual machine monitor 102, and is used to save the last words or key logs of the kernel or user state before the virtual machine is abnormal.
[0093] Reference Figure 4 , Figure 4This is a flowchart of a method for storing virtual machine fault information in an implementation scenario according to the first embodiment of the present application, which is applied in Figure 3 On systems such as Figure 4 As shown, the process includes:
[0094] S401, the virtual machine operating system is started;
[0095] The host machine starts normally, the virtualization environment is configured successfully, and the fault saving device is initialized in the virtual machine monitor.
[0096] For example, the Hygon physical server as the host machine is started normally, the virtualization environment is configured, a qemu virtual machine is created on the Hygon server, qemu-kvm is used as a virtual machine monitor, and the virtualization of the fault saving device is completed in qemu.
[0097] S402, initialization of the fault notification device;
[0098] The virtual machine operating system starts and completes the initialization of the fault notification device, including:
[0099] In the virtual machine, a memory is applied for the fault notification device to store the fault information during the virtual machine runtime, and the memory is managed in a ring storage manner. The physical first address of the memory is GPA1.
[0100] Abstract the fault notification device as a character device and register it to provide kernel mode and user mode read and write interfaces. Use the read and write interfaces to convert the kernel fault information physical first address GPA2 and related parameters args a And the virtual machine user state fault information physical first address GPA3 and related parameters args b Save to the requested physical memory, where
[0101] args a ={arg a0 ,arg a1 ,arg a2 ,...};
[0102] args b ={arg b0 ,arg b1 ,arg b2 ,...};
[0103] Specifically,
[0104] args a ={arg a0 =Content,
[0105] arg a1 = number of lines, arg a2= Current readable index number of user state information, arg a3 =
[0106] Log readable location, arg a4 =The current writable index number of the log,
[0107] arg a5 =Location where the log can be written};
[0108] args b ={arg b0 =Log content,
[0109] arg b1 =Number of log lines, arg b2 =log level,arg b3 =
[0110] The log's currently readable index number, arg b4 =Location where the log is readable,
[0111] arg b5 =The current writable index number of the log, arg b6 =Location where the log can be written};
[0112] The abnormal notification function used for notifying the fault saving device in the fault notification device is registered on the notification chain of the virtual machine operating system crash process.
[0113] S403, determining whether the virtual machine is down, if the virtual machine is down, executing S404;
[0114] S404, the fault notification device sends a signal to the fault storage device;
[0115] When a fault occurs inside the virtual machine, the fault notification device uses the above-mentioned abnormal notification function to send a signal to notify the fault saving device in the virtual machine monitor.
[0116] S405, the fault saving device saves the virtual machine kernel information to the host machine.
[0117] After receiving the save notification, the fault save device of the virtual machine monitor converts GPA1 into the virtual address HVA1 in the host machine, and uses HVA1 to fetch GPA2, GPA3, and args a and args b ;
[0118] Convert GPA2 and GPA3 to virtual addresses HVA2 and HVA3 in the host machine respectively, and based on HVA2, HVA3, args a and args bObtain the contents of the virtual machine kernel log information and user state information, and save them to the host machine;
[0119] The logs in the host machine are managed by date using a fault saving device according to the time when the fault occurred.
[0120] In the embodiment of the present application, when a fault occurs inside the virtual machine, a fault notification device inside the virtual machine is triggered to notify a fault saving device in the virtual machine monitor. The fault saving device saves the last words or key logs of the kernel or user state before the virtual machine abnormality by retaining the internal memory of the virtual machine. The key information when the virtual machine crashes is saved in the host machine in a lightweight manner, and the fault can be quickly located without entering the virtual machine, thereby effectively saving the time cost of fault location.
[0121] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0122] Example 2
[0123] In this embodiment, a device for storing virtual machine fault information is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0124] Figure 5 is a structural block diagram of a device for storing virtual machine fault information according to an embodiment of the present application, such as Figure 5 As shown, the device includes: an acquisition module 100, a conversion module 200, and a storage module 300, wherein:
[0125] The acquisition module 100 is used to acquire internal fault information of the virtual machine when a fault occurs in the virtual machine, wherein the virtual machine runs on the host machine;
[0126] The conversion module 200 is used to convert the physical address of the virtual machine in the internal fault information into the virtual address of the host machine;
[0127] The storage module 300 is used to obtain the internal fault information of the virtual machine according to the virtual address, and save the internal fault information to the host machine.
[0128] Optionally, the device also includes: a receiving module, used to receive a fault save signal sent by a fault notification device calling an exception notification function, wherein the fault notification device is a driver module inside the virtual machine operating system, and the exception notification function is registered on the notification chain of the virtual machine operating system crash process, and is used to instruct fault saving when the virtual machine fails; a confirmation module, used to respond to the fault save signal and confirm the acquisition of internal fault information of the virtual machine.
[0129] Optionally, the acquisition module also includes: a first acquisition unit, used to obtain internal fault information sent by the virtual machine using a first physical address from the physical memory of the virtual machine, wherein the physical memory is used to store the runtime fault information of the virtual machine, and the internal fault information includes kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter.
[0130] Optionally, the acquisition module also includes: a creation unit, used to create a physical memory of circular storage in the virtual machine, and configure the first address of the physical memory as a first physical address; a configuration unit, used to configure a second physical address and a first configuration parameter about kernel fault information in the physical memory through the read-write interface of the virtual machine, and configure a third physical address and a second configuration parameter about user state fault information.
[0131] Optionally, the conversion module includes: a first conversion unit, used to obtain a first physical address in the internal fault information, and convert the first physical address into a first virtual address of the host machine; a second acquisition unit, used to obtain kernel fault information stored using a second physical address and first configuration parameters, and user-state fault information stored using a third physical address and second configuration parameters from the internal fault information based on the first virtual address; a second conversion unit, used to convert the second physical address into a second virtual address of the host machine; and a third conversion unit, used to convert the third physical address into a third virtual address of the host machine.
[0132] Optionally, the storage module includes: a third acquisition unit, used to obtain kernel log information and user state information of the virtual machine according to the virtual address; and a storage unit, saving the kernel log information and the user state information to the host machine.
[0133] Optionally, the storage unit includes: a storage subunit, used to determine the time when the failure of the virtual machine occurs; and save the kernel log information and the user state information to the host machine according to the time when the failure occurs.
[0134] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0135] Example 3
[0136] An embodiment of the present application further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0137] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0138] S1, when a virtual machine fails, obtaining internal fault information of the virtual machine, wherein the virtual machine runs on a host machine;
[0139] S2, converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine;
[0140] S3, obtaining internal fault information of the virtual machine according to the virtual address, and saving the internal fault information to the host machine.
[0141] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0142] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0143] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0144] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0145] S1, when a virtual machine fails, obtaining internal fault information of the virtual machine, wherein the virtual machine runs on a host machine;
[0146] S2, converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine;
[0147] S3, obtaining internal fault information of the virtual machine according to the virtual address, and saving the internal fault information to the host machine.
[0148] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0149] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0150] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0151] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0155] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for storing virtual machine fault information, characterized in that: The method comprises: When a virtual machine fails, internal fault information of the virtual machine is obtained, wherein the virtual machine runs on a host machine; Converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine; The internal fault information of the virtual machine is obtained according to the virtual address, and the internal fault information is saved in the host machine.
2. The method according to claim 1, characterized in that Before obtaining the internal fault information of the virtual machine, the method further includes: Receive a fault saving signal sent by a fault notification device calling an abnormal notification function, wherein the fault notification device is a driver module inside the virtual machine operating system, and the abnormal notification function is registered in the notification chain of the virtual machine operating system crash process, and is used to instruct fault saving when the virtual machine fails; In response to the fault saving signal, confirm obtaining the internal fault information of the virtual machine.
3. The method according to claim 1, characterized in that The obtaining of internal fault information of the virtual machine includes: Obtain internal fault information sent by the virtual machine using a first physical address from the physical memory of the virtual machine, wherein the physical memory is used to store the runtime fault information of the virtual machine, and the internal fault information includes kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter.
4. The method according to claim 3, characterized in that Before obtaining the internal fault information sent by the virtual machine using the first physical address from the physical memory of the virtual machine, the method includes: Creating a physical memory of a ring storage in the virtual machine, and configuring a first address of the physical memory as a first physical address; A second physical address and a first configuration parameter regarding kernel fault information are configured in the physical memory through the read / write interface of the virtual machine, and a third physical address and a second configuration parameter regarding user state fault information are configured.
5. The method according to claim 4, characterized in that The converting the physical address of the virtual machine in the internal fault information into the virtual address of the host machine includes: Acquire a first physical address in the internal fault information, and convert the first physical address into a first virtual address of a host machine; Based on the first virtual address, obtaining kernel fault information stored using a second physical address and a first configuration parameter, and user state fault information stored using a third physical address and a second configuration parameter from the internal fault information; Converting the second physical address into a second virtual address of the host machine; The third physical address is converted into a third virtual address of the host machine.
6. The method according to claim 1, characterized in that The acquiring the internal fault information of the virtual machine according to the virtual address and saving the internal fault information to the host machine includes: Acquire kernel log information and user state information of the virtual machine according to the virtual address; The kernel log information and the user state information are saved in the host machine.
7. The method according to claim 6, characterized in that The step of saving the kernel log information and the user state information to the host machine includes: Determining the time when the failure of the virtual machine occurred; The kernel log information and the user state information are saved in the host machine according to the fault occurrence time.
8. A device for storing virtual machine fault information, characterized in that: The device comprises: An acquisition module, used for acquiring internal fault information of a virtual machine when a fault occurs in the virtual machine, wherein the virtual machine runs on a host machine; A conversion module, used to convert the physical address of the virtual machine in the internal fault information into the virtual address of the host machine; The storage module is used to obtain the internal fault information of the virtual machine according to the virtual address, and save the internal fault information to the host machine.
9. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the steps of any one of the methods of claims 1 to 7 when executed.
10. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein: The processor, the communication interface, and the memory communicate with each other via a communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the steps of the method according to any one of claims 1 to 7 by running a program stored in a memory.
Citation Information
Cited By
Fault processing method and device, electronic equipment and computer readable storage medium
CN120045274A
