Method and device for acquiring virtual machine disk input / output latency, equipment and medium
Patent Information
- Application Number
- CN202311113967.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2043-08-31
AI Technical Summary
[0005]本发明的目的是提供一种虚拟机磁盘输入输出时延的获取方法、装置、设备及介质,以解决获取虚拟机磁盘IO时延数据的效率、安全性、准确性低的技术问题
[0058]本发明所提供的一种虚拟机磁盘输入输出时延的获取方法,应用于宿主机,该方法包括:通过拦截器函数拦截虚拟机的退出事件和进入事件;其中,退出事件为虚拟机的进程从用户态切换至内核态的事件,进入事件为虚拟机的进程进行从内核态切换至用户态的事件;获取虚拟机的各进程的输入输出对应的退出事件发生的时刻与进入事件发生的时刻;根据各进程的输入输出对应的进入事件发生的时刻与退出事件发生的时刻的差值在预设时长中的占比确定预设时长内虚拟机磁盘输入输出时延。
Smart Images

Figure CN117076054B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of virtual machine technology, and in particular to a method, apparatus, device, and medium for obtaining virtual machine disk input / output latency. Background Technology
[0002] Virtual machines are the core resources of a virtualization platform that directly face users. To evaluate the quality of business operations within a virtual machine's operating system, virtual machine disk input / output (I / O) latency data is typically used as a metric.
[0003] In related technical solutions, virtual machine disk I / O latency data is collected through the native monitoring interface of the virtualization library (libvirt). However, this only supports statistics on a single virtual disk device of the virtual machine, resulting in a decrease in efficiency in obtaining the overall virtual machine disk I / O latency data. Alternatively, an agent program is installed inside the guest operating system to capture the actual load input. However, because the agent program is installed inside the guest operating system, it intrudes into the internal business of the guest operating system, posing unknown risks to the security of the guest operating system. Another option is to collect process monitoring data through performance data query tools provided by the Linux operating system (such as top, iostat, etc.). However, these are general process performance data capture tools that capture all processes on the host machine, not just virtual machine process measurement tools, which makes it impossible to accurately measure virtual machine disk I / O latency data.
[0004] Therefore, providing a fast, safe, and accurate method for obtaining virtual machine disk I / O latency data is a technical problem that urgently needs to be solved by those in the field. Summary of the Invention
[0005] The purpose of this invention is to provide a method, apparatus, device, and medium for obtaining virtual machine disk input / output latency, so as to solve the technical problems of low efficiency, security, and accuracy in obtaining virtual machine disk IO latency data.
[0006] To address the aforementioned technical problems, this invention provides a method for obtaining virtual machine disk input / output latency, applied to a host machine. The method includes:
[0007] The exit and entry events of the virtual machine are intercepted by an interceptor function; wherein the exit event is the event in which the process of the virtual machine switches from user mode to kernel mode, and the entry event is the event in which the process of the virtual machine switches from kernel mode to user mode, and the interceptor function is a function used to intercept the exit and entry events of the virtual machine.
[0008] Obtain the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine;
[0009] The virtual machine disk input / output latency within the preset duration is determined based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset duration.
[0010] Firstly, before determining the virtual machine disk input / output latency based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within a preset duration, the method further includes:
[0011] Create a directory for recording process information and a first file corresponding to the target for recording input and output times;
[0012] After detecting the process that created the virtual machine, add the identification code of the created process, the name of the first file used to record input and output times to the directory, and record the creation time of the created process in the first file;
[0013] Correspondingly, obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine includes:
[0014] Based on the identification code of each process, obtain the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine;
[0015] Correspondingly, after obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine, the method further includes:
[0016] The timestamps of the exit events and the entry events are added sequentially to the first file.
[0017] On the other hand, the preset duration is a preset duration prior to the time of the last entry event, wherein the time of the last entry event is the entry event time in the last pair of exit event times and entry event times among all pairs of exit event times and entry event times in the first file; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the entry event time and the exit event time corresponding to the input / output of each process within the preset duration includes:
[0018] Obtain the difference between the time of the last entry event and the preset duration;
[0019] Based on the difference, locate the time of the exit event and the time of the entry event corresponding to the first target group in the first file;
[0020] Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the first target group to the last group;
[0021] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0022] On the other hand, the preset duration is multiple, and after obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine, it further includes:
[0023] Create a second file to characterize process stress data;
[0024] According to the correspondence between each preset duration and the corresponding virtual machine disk input / output latency, each preset duration and the corresponding virtual machine disk input / output latency are added to the second file.
[0025] On the other hand, the preset duration is determined based on the input and output parameters set by the kernel query interface;
[0026] If the kernel query interface is found to have no input parameter time and no output parameter time, the preset duration is from the creation time of the process to the output parameter time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes:
[0027] Obtain the second target group corresponding to the creation time of the process and the third target group corresponding to the exit time; wherein, the target group is a pair of times when the entry event occurs and times when the exit event occurs;
[0028] Obtain the sum of the differences between the times of the exit events and the times of the entry events for all groups from the second target group to the second target group.
[0029] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration;
[0030] If the kernel query interface is found to have no input parameter time and no output parameter time set, the preset duration is from the process creation time to the current query time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes:
[0031] Obtain the second target group corresponding to the creation time of the process and the fourth target group corresponding to the current query time;
[0032] Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the second target group to the fourth target group;
[0033] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration;
[0034] When the kernel query interface is detected to set the input parameter time and the output parameter time, the preset duration is from the input parameter time to the output parameter time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes:
[0035] Obtain the fifth target group corresponding to the input parameter time and the third target group corresponding to the output parameter time;
[0036] Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the fifth target group to the third target group;
[0037] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration;
[0038] When the kernel query interface is detected to have set the input parameter time but not the output parameter time, the preset duration is from the input parameter time to the current query time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset duration includes:
[0039] Obtain the fifth target group corresponding to the input parameter time and the fourth target group corresponding to the current query time;
[0040] Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the fifth target group to the fourth target group;
[0041] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0042] On the other hand, before obtaining the difference between the time of the last entry event and the preset duration, the method further includes:
[0043] Check if the input parameter setting of the kernel query interface is a duration parameter;
[0044] If so, proceed to the step of obtaining the difference between the time of the last entry event and the preset duration.
[0045] On the other hand, after adding the preset duration and the corresponding virtual machine disk input / output latency to the second file according to the correspondence between the preset duration and the corresponding virtual machine disk input / output latency, the method further includes:
[0046] If a request to obtain virtual machine disk input / output latency is detected, the virtual machine disk input / output latency corresponding to the preset duration is obtained from the second file according to the preset duration in the request.
[0047] On the other hand, after creating the directory for recording process information and the first file corresponding to the target for recording input and output times, the method further includes:
[0048] Set read and write permissions for the first file;
[0049] Correspondingly, if the destruction of the created process is detected, the directory corresponding to the process, the first file used to record input and output time, and the second file used to characterize process pressure data corresponding to the target are deleted.
[0050] To address the aforementioned technical problems, the present invention also provides a device for acquiring virtual machine disk input / output latency, applied to a host machine, the device comprising:
[0051] An interception module is used to intercept virtual machine exit events and entry events through an interceptor function; wherein, the exit event is the event in which the virtual machine's process switches from user mode to kernel mode, the entry event is the event in which the virtual machine's process switches from kernel mode to user mode, and the interceptor function is a function used to intercept virtual machine exit events and entry events;
[0052] The acquisition module is used to acquire the time when the exit event occurs and the time when the entry event occurs, corresponding to the input and output of each process of the virtual machine;
[0053] The determining module is used to determine the virtual machine disk input / output latency within the preset time period based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset time period.
[0054] To address the aforementioned technical problems, the present invention also provides a device for acquiring virtual machine disk input / output latency, comprising:
[0055] Memory, used to store computer programs;
[0056] A processor is configured to implement the steps of the virtual machine disk input / output latency acquisition method described above when executing the computer program.
[0057] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for obtaining virtual machine disk input / output latency.
[0058] The present invention provides a method for obtaining virtual machine disk input / output latency, applied to a host machine. The method includes: intercepting virtual machine exit events and entry events through an interceptor function; wherein, an exit event is an event in which a virtual machine process switches from user mode to kernel mode, and an entry event is an event in which a virtual machine process switches from kernel mode to user mode; obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input / output of each process of the virtual machine; and determining the virtual machine disk input / output latency within a preset time period based on the proportion of the difference between the time of occurrence of the entry event and the time of occurrence of the exit event corresponding to the input / output of each process within a preset time period.
[0059] The beneficial effects of this invention are as follows: First, this invention starts with the timing of the virtual machine process switching between user mode and kernel mode. By capturing the switching time point and statistically analyzing the waiting time for I / O after switching to kernel mode within a preset duration, the virtual machine disk I / O latency is accurately determined. Second, compared to previous methods that statistically analyzed data on a per-virtual-disk-device basis, this invention uses an interceptor function to intercept virtual machine exit and entry events, capturing events for the entire virtual machine process, i.e., statistically analyzing data on a per-virtual-device basis, thus greatly improving the efficiency of obtaining virtual machine disk I / O latency data. Third, compared to previous guest operating... This invention uses an internal system agent to capture real stress input. Because it obtains virtual machine disk I / O latency data from the host machine rather than from the virtual machine process stress data, it achieves non-intrusive out-of-band acquisition of virtual machine process stress data, thus improving virtual machine security. Furthermore, compared to previous methods that used performance data query tools to obtain monitoring data for all processes, this invention employs interceptor functions to intercept virtual machine exit and entry events. This allows for precise capture of events that switch between user mode and kernel mode, enabling accurate measurement of virtual machine disk I / O latency data. Therefore, the method provided by this invention can quickly, safely, and accurately obtain virtual machine disk I / O latency data.
[0060] By creating a directory for recording process information and a first file corresponding to the target for recording input and output times, the delay can be determined based on the time data recorded in the first file.
[0061] Given a preset duration starting from the time before the last entry event, the virtual machine disk input / output latency within the preset duration is determined by summing the differences between the times of exit events and entry events for all groups from the first target group to the last group.
[0062] By recording each preset duration and the corresponding virtual machine disk input / output latency in a second file, the virtual machine disk input / output latency within a preset duration can be directly found through the second file if the preset duration is known.
[0063] The kernel query interface can be used to determine the specific time and the corresponding virtual machine disk input / output latency within a preset duration.
[0064] By setting permissions for the first file, data security can be improved, and if the process is detected to have been destroyed, the directory corresponding to the process and the files in that directory can be deleted, thus reducing the storage space occupied by the files.
[0065] In addition, the present invention also provides a device for obtaining virtual machine disk input / output latency, a device for obtaining virtual machine disk input / output latency, and a computer-readable storage medium, which have the same or corresponding technical features as the virtual machine disk input / output latency method mentioned above, and have the same effect. Attached Figure Description
[0066] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0067] Figure 1 A schematic diagram illustrating a virtual machine disk input / output transfer process provided in an embodiment of the present invention;
[0068] Figure 2 A flowchart illustrating a method for obtaining disk input / output latency of a host machine virtual machine, provided as an embodiment of the present invention;
[0069] Figure 3 This is a schematic diagram illustrating the exit and entry times of a virtual machine process, provided as an embodiment of the present invention.
[0070] Figure 4 A structural diagram of a device for acquiring virtual machine disk input / output latency provided in an embodiment of the present invention;
[0071] Figure 5 A structural diagram of a device for acquiring virtual machine disk input / output latency provided in another embodiment of the present invention. Detailed Implementation
[0072] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.
[0073] The core of this invention is to provide a method, apparatus, device, and medium for obtaining virtual machine disk input / output latency, so as to solve the technical problems of low efficiency, security, and accuracy in obtaining virtual machine disk IO latency data.
[0074] Figure 1 This is a schematic diagram of a virtual machine disk input / output transfer process provided in an embodiment of the present invention, as shown below. Figure 1As shown, the operating system of virtual machine 1 initiates an I / O request to storage device 2. The I / O transfer process involves exiting user mode 3 and entering kernel mode 4, and then returning from kernel mode 4 to user mode 3. The I / O transfer process involves the virtual machine process constantly switching and scheduling between user mode 3 and kernel mode 4. In this embodiment of the invention, the time of this switching is collected to determine the virtual machine disk I / O latency.
[0075] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Figure 2 A flowchart illustrating a method for obtaining disk input / output latency of a host machine virtual machine, provided by an embodiment of the present invention, is shown below. Figure 2 As shown, the method includes:
[0076] S10: Intercept virtual machine exit and entry events through interceptor functions; where an exit event is the virtual machine process switching from user mode to kernel mode, and an entry event is the virtual machine process switching from kernel mode to user mode.
[0077] S11: Obtain the times of exit events and entry events corresponding to the input and output of each process in the virtual machine;
[0078] S12: Determine the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of entry event and the time of exit event corresponding to the input / output of each process within the preset duration.
[0079] To accurately obtain virtual machine disk I / O latency, this embodiment captures the timing of virtual machine process switching between user mode and kernel mode, and determines the virtual machine disk I / O waiting time based on the switching timing. When capturing the switching timing, interceptor functions are used to intercept virtual machine exit and entry events. An exit event is the event where the virtual machine process switches from user mode to kernel mode, and an entry event is the event where the virtual machine process switches from kernel mode to user mode.
[0080] To capture exit events, a VM-ExitInterceptor function is written and injected with init3 machine code at the hook points of VM-Exit and VM-Entry in the Kernel-based Virtual Machine (KVM) module. This triggers the sig_trap signal. When the Central Processing Unit (CPU) reaches this point, it sends this signal, and the VM-ExitInterceptor function is injected into the callback function of the aforementioned signal, thus enabling the execution of the interceptor function. This VM-ExitInterceptor function intercepts VM-Exit events and process information sent by the guest machine (obtaining the process identity document (ID), parsing the event and obtaining the event type; if the event type is IO-Exit, it records the time T1 (in milliseconds) of the received IO-Exit event for the corresponding virtual machine process, i.e., the moment the virtual machine exits from user mode to KVM kernel mode, i.e., the moment the exit event occurs).
[0081] To capture entry events, a VM-EntryInterceptor function is written, which operates in the same way as the VM-ExitInterceptor. This interceptor function intercepts the VM-Entry event and process ID (PID) sent by the guest, parses the event and obtains the event type. If it is an IO-Entry, it records the time T2 of the event received from the corresponding virtual machine process, which is the moment when the virtual machine returns from KVM kernel mode to user mode, i.e., the moment the entry event occurs.
[0082] The I / O wait time is determined based on the difference between the time of the exit event and the time of the entry event corresponding to the input / output of each process. To more accurately determine the virtual machine disk I / O latency, this embodiment of the invention uses the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within a preset time period to determine the virtual machine disk I / O latency within a preset time period. The preset time period is not limited and is determined based on actual conditions. Furthermore, it should be noted that after obtaining the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset time period, normalization processing can be performed to obtain the I / O wait time per unit time, thus obtaining a more accurate virtual machine disk I / O latency.
[0083] The method provided in this embodiment firstly determines the virtual machine disk I / O latency by capturing the switching time points and statistically analyzing the I / O waiting time after switching to kernel mode within a preset duration, starting from the timing of the virtual machine process switching between user mode and kernel mode. Secondly, compared to previous methods that statistically analyzed data on a per-virtual-disk-device basis, this embodiment uses an interceptor function to intercept virtual machine exit and entry events, capturing events for the entire virtual machine process, thus statistically analyzing data on a per-virtual-device basis, significantly improving the efficiency of obtaining virtual machine disk I / O latency data. Thirdly, compared to previous guest operating systems... The method of internally installing an agent to capture real stress input improves virtual machine security because this embodiment obtains virtual machine disk I / O latency data through the host machine, rather than acquiring virtual machine process stress data on the virtual machine itself. This means the invention obtains virtual machine process stress data non-intrusively through out-of-band access. Furthermore, compared to previous methods that used performance data query tools to obtain monitoring data for all processes, this embodiment employs interceptor functions to intercept virtual machine exit and entry events. This allows for precise capture of events that switch between user mode and kernel mode, thus enabling accurate measurement of virtual machine disk I / O latency data. Therefore, the method provided by this embodiment can quickly, safely, and accurately obtain virtual machine disk I / O latency data.
[0084] In implementation, to statistically analyze and record process switching timings, before determining the virtual machine disk input / output latency based on the proportion of the difference between the entry and exit events of each process within a preset duration, the following steps are also included:
[0085] Create a directory for recording process information and a first file corresponding to the target for recording input and output times;
[0086] After detecting the process that creates the virtual machine, add the identification code of the created process, the name of the first file used to record input and output times to the directory, and record the creation time of the created process in the first file;
[0087] Correspondingly, the times of exit events and entry events corresponding to the input and output of each process in the virtual machine are obtained, including:
[0088] Based on the identification code of each process, obtain the time of exit event and the time of entry event corresponding to the input and output of each process in the virtual machine;
[0089] Correspondingly, after obtaining the times of exit events and entry events corresponding to the input and output of each process in the virtual machine, the process also includes:
[0090] Add the timestamps of exit and entry events to the first file in pairs.
[0091] In addition, to improve data security, after creating a directory for recording process information and a first file corresponding to the target for recording input and output times, the following is also included:
[0092] Set read and write permissions for the first file.
[0093] Specifically, in this embodiment, the ` / proc / diskio / ` directory is created. Each time the Quick Emulator (QEMU) component creates a virtual machine process, it notifies the KVM module of the process ID. Then, a directory named after the process ID is created under this directory, such as ` / proc / diskio / 11222 / `, and its permissions are set to: readable and writable in kernel mode, and read-only in user mode. Simultaneously, a first file `io_time` is created, with a full path example like ` / proc / diskio / 11222 / io_time`. When a virtual machine process is created, the first line is written, recording the virtual machine process's creation time `create_vm_time: T0`, as follows:
[0094] create_vm_time:T0ms;
[0095] The VM-ExitInterceptor function described above obtains the time when the exit event occurred (i.e., the time when the virtual machine exits and enters the KVM kernel state). This time is appended to the first file, specifying that it is the time when the exit event occurred, `exit_time`. The specific content is as follows:
[0096] exit_time:T1ms;
[0097] The VM-EntryInterceptor interceptor function obtains the time when the entry event occurred (i.e., the time when the virtual machine returns from KVM kernel mode to user mode), and appends this time to the first file, specifying it as the entry_time when the entry event occurred. The content is as follows:
[0098] entry_time:T2ms.
[0099] Every time the virtual machine performs an I / O read or write operation, the kernel KVM module receives VM-Exit and VM-Entry events. The file / proc / diskio / pidxxx / io_time continuously writes the exit and entry timestamps in pairs, as follows:
[0100] create_vm_time:112222
[0101] exit_time:112445
[0102] entry_time:112900
[0103] exit_time:113411
[0104] entry_time:113600
[0105] exit_time:114000
[0106] entry_time:114100
[0107] exit_time:114411
[0108] entry_time:114510
[0109] exit_time:115100
[0110] entry_time:115288
[0111] exit_time:116881
[0112] entry_time:117988
[0113] exit_time:118912
[0114] entry_time:119034
[0115] In the method provided in this embodiment, a directory and a first file for recording input and output times are created, and the directory and the corresponding file content are updated after the process is created, so that the time when the process I / O exit event occurs and the time when the process I / O enters can be obtained through the first file.
[0116] In implementation, the preset duration is the time period preceding the occurrence of the last entry event. The last entry event occurs when the last pair of exit and entry events in the first file is the entry event. The virtual machine disk input / output latency within the preset duration is determined by the proportion of the difference between the entry and exit event times corresponding to each process's input / output within the preset duration.
[0117] Get the difference between the time of the last entry event and the preset duration;
[0118] Based on the difference, locate the time of the exit event and the time of the entry event corresponding to the first target group in the first file;
[0119] Get the sum of the differences between the times of exit events and entry events for all groups from the first target group to the last group;
[0120] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0121] First, the preset duration in this embodiment is explained. The preset duration is the time period before the last entry event occurs. The last entry event occurs within the last pair of exit and entry event times in the first file, i.e., within the most recent t seconds. The contents of / proc / diskio / pidxxx are read to locate the last pair of exit_time and entry_time; t seconds are searched backward to locate the time from VM-Exit to VM-Entry n seconds ago; the sum of the time periods from exit_time to entry_time in the most recent t seconds is calculated.
[0122] T = SUM(entry_time – exit_time), which means searching backwards t seconds from the entry_time of the last pair of exit_time and entry_time, locating the pair of exit_time and entry_time at that position, and calculating the sum of all time intervals from exit_time to entry_time during those n seconds; calculating the percentage of time intervals from exit_time to entry_time in the most recent t seconds, which is the virtual machine disk I / O latency disk_io.
[0123] disk_io(%)=T / (t*1000).
[0124] Figure 3 A schematic diagram illustrating the exit and entry times of a virtual machine process provided in an embodiment of the present invention, as shown below. Figure 3 As shown, it includes the virtual machine process creation time (create_vm_time) and each pair of exit_time and entry_time (referred to as exit time and entry time). Figure 3 The table lists N pairs of exit_time and entry_time, and the difference between the entry time and exit time for each pair is the time interval for that pair.
[0125] Assuming the preset duration is the first 4 seconds, let's take the time pairs listed in the above embodiment as an example to illustrate the virtual machine disk I / O latency. The last pair is exit_time: 118912, entry_time: 119034. 119034-4000=115034. Based on 115034, we can locate the third to last pair, namely exit_time: 115100, entry_time: 115288. At this point, the third to last pair is the first target group. Obtain the time difference of the third-to-last pair (115288-115100=188), the time difference of the second-to-last pair (117988-116881=1107), and the time difference of the last pair (119034-118912=122). Sum these three pairs of time differences: 188+1107+122=1417. Then, obtain the ratio of the sum of the differences to the preset time: 1417 / 4000=0.35. Thus, determine that the virtual machine disk I / O latency in the first 4 seconds is 0.35.
[0126] As a virtual machine disk I / O latency metric, the larger the percentage value, the more time the kernel spends processing I / O after normalization, indicating that the guest machine is in a waiting state, resulting in slow response and high latency.
[0127] In the above embodiments, the delay of the first t seconds is obtained. In practice, there are multiple preset durations. After obtaining the time of exit event and the time of entry event corresponding to the input and output of each process of the virtual machine, the method further includes:
[0128] Create a second file to characterize process stress data;
[0129] According to the correspondence between each preset duration and the corresponding virtual machine disk input / output latency, add each preset duration and its corresponding virtual machine disk input / output latency to the second file.
[0130] Write the calculation results (disk_io) from the above embodiment to the file / proc / diskio / pidxxx / io_pressure (i.e., the second file), and write the queryable default IO latency metrics (last 5 seconds, last 10 seconds, last 60 seconds, last 5 minutes), in the following format: 5:0.25 10:0.18 60:0.16 300:0.09
[0135] total: 0.05
[0136] After adding the preset duration and its corresponding virtual machine disk input / output latency to the second file according to the correspondence between each preset duration and its corresponding virtual machine disk input / output latency, it also includes:
[0137] If a request to obtain virtual machine disk I / O latency is detected, the virtual machine disk I / O latency corresponding to the preset duration in the request is obtained from the second file. For example, if the latency of the first 5 seconds is to be obtained, the latency corresponding to the first 5 seconds is directly obtained from the second file as 0.25. Similarly, if the latency of the first 300 seconds is to be obtained, the latency corresponding to the first 300 seconds is directly obtained from the second file as 0.09.
[0138] In the method provided in this embodiment, by recording the correspondence between each preset duration and the virtual machine disk input / output latency corresponding to each preset duration in a second file, the virtual machine disk IO latency data corresponding to the previous t seconds can be directly queried, which greatly improves the efficiency of obtaining virtual machine disk IO latency data.
[0139] In practice, the preset duration is determined based on the input and output parameters set by the kernel query interface;
[0140] If the kernel query interface is found to have no input parameter time and no output parameter time, the preset duration is from the process creation time to the output parameter time; the virtual machine disk input / output latency within the preset duration is determined by the proportion of the difference between the time of entry event and the time of exit event corresponding to each process's input / output within the preset duration, including:
[0141] Obtain the second target group corresponding to the creation time of the process and the third target group corresponding to the output time; wherein, the target group is the time when the entry event occurs and the time when the exit event occurs in pairs;
[0142] Obtain the sum of the differences between the times of exit events and entry events for all groups from the second target group to the second target group.
[0143] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0144] If the kernel query interface is found to have no input and output parameter timestamps set, the preset duration is from the process creation time to the current query time; the virtual machine disk input / output latency within the preset duration is determined by the proportion of the difference between the entry and exit event times corresponding to each process's input and output within the preset duration, including:
[0145] Obtain the second target group corresponding to the creation time of the process and the fourth target group corresponding to the current query time;
[0146] Obtain the sum of the differences between the times of exit events and entry events for all groups from the second target group to the fourth target group;
[0147] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0148] When the kernel query interface sets the input and output parameters, the preset duration is from the input parameter time to the output parameter time. The virtual machine disk input / output latency within the preset duration is determined based on the proportion of the difference between the time of entry and the time of exit of each process's input / output corresponding to the preset duration.
[0149] Obtain the fifth target group corresponding to the input parameter time and the third target group corresponding to the output parameter time;
[0150] Obtain the sum of the differences between the times of exit events and entry events for all groups from the fifth target group to the third target group;
[0151] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0152] If the kernel query interface sets the input parameters but not the output parameters, the preset duration is from the input parameter time to the current query time. The virtual machine disk input / output latency within the preset duration is determined by the proportion of the difference between the time of entry and the time of exit events corresponding to the input and output of each process within the preset duration.
[0153] Obtain the fifth target group corresponding to the input parameter time and the fourth target group corresponding to the current query time;
[0154] Obtain the sum of the differences between the times of exit events and entry events for all groups from the fifth target group to the fourth target group;
[0155] The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
[0156] It should be noted that the first target group, the second target group, the third target group, the fourth target group, and the fifth target group in this embodiment are not arranged in chronological order, but only to distinguish the target groups corresponding to different times.
[0157] Specifically, write a kernel query interface to query disk I / O latency data for a specified time period:
[0158] Interface 1: Input parameters: start time (date), end time; Output parameter: disk_io;
[0159] If no start time is specified, disk_io is calculated from create_vm_time to the end time;
[0160] If no end time is specified, the total disk latency data since the virtual machine was created is calculated.
[0161] If a start time is specified, disk_io is calculated from the start time to the end time;
[0162] If no end time is specified, disk_io is calculated from the start time to the last exit_time to entry_time.
[0163] The interface provided in this embodiment is suitable for scenarios where business is relatively busy during the day, and can obtain latency data within a specific time period.
[0164] In implementation, before obtaining the difference between the time of the last entry event and the preset duration, the following steps are also included:
[0165] Check if the input parameter setting of the kernel query interface is a duration parameter;
[0166] If so, proceed to the step of obtaining the difference between the time of the last entry event and the preset duration.
[0167] Interface 2: Input parameter: duration (integer seconds) t, Output parameter: disk_io;
[0168] Calculate and return the disk_io for the most recent t seconds.
[0169] In practice, user-space processes can directly read io_time to calculate it themselves, or directly read io_pressure to obtain disk I / O latency metrics.
[0170] The interface provided in this embodiment is suitable for virtual machine process stress data that only focuses on duration.
[0171] To reduce storage requirements, upon detecting the destruction of a created process, the directory corresponding to the process, as well as the first file used to record input / output times and the second file used to characterize process stress data, corresponding to the target, are deleted.
[0172] Specifically, when the virtual machine process is destroyed, the QEMU component sends a notification event and deletes the directory named after the destroyed virtual machine process and all files in the directory under / proc / diskio / through this code, so that only valid data is stored and the storage space occupied by the data is reduced.
[0173] As can be seen, this embodiment of the invention will be based on the switching principle of virtual machine processes between user mode and kernel mode KVM. By capturing the switching time point and statistically analyzing the waiting time for IO after switching to kernel KVM per unit time, more accurate virtual machine disk IO latency data can be obtained. The disk IO latency data obtained in this way can more accurately measure the service operation quality within the guest operating system (OS). By non-intrusively obtaining virtual machine process pressure data out of band, the internal service operation quality, such as lag, can be indirectly evaluated. This allows for notification of the virtual machine's operating pressure status to the user through alarms, and timely guidance to the customer to improve the performance of the basic hardware by expanding capacity or increasing bandwidth, thereby improving the service quality of virtual machine services and enhancing the stability of user services.
[0174] In the above embodiments, the method for obtaining virtual machine disk input / output latency has been described in detail. This invention also provides embodiments of a device for obtaining virtual machine disk input / output latency and a corresponding equipment for obtaining virtual machine disk input / output latency. It should be noted that this invention describes the embodiments of the device portion from two perspectives: one based on functional modules, and the other based on hardware.
[0175] Figure 4 This is a structural diagram of a device for acquiring virtual machine disk input / output latency according to an embodiment of the present invention. From the perspective of functional modules, this embodiment includes:
[0176] Interception module 10 is used to intercept virtual machine exit events and entry events through interceptor functions; wherein, the exit event is the event in which the virtual machine process switches from user mode to kernel mode, the entry event is the event in which the virtual machine process switches from kernel mode to user mode, and the interceptor function is a function used to intercept virtual machine exit events and entry events.
[0177] The acquisition module 11 is used to acquire the time when the exit event and the time when the entry event occur corresponding to the input and output of each process of the virtual machine.
[0178] The determination module 12 is used to determine the virtual machine disk input / output latency within a preset time based on the proportion of the difference between the time of entry event and the time of exit event corresponding to the input / output of each process within a preset time.
[0179] Since the embodiments of the device part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the device part, and they will not be repeated here. Furthermore, it has the same beneficial effects as the virtual machine disk input / output latency acquisition method mentioned above.
[0180] The device for acquiring virtual machine disk input / output latency also includes:
[0181] The first creation module is used to create a directory for recording process information and a first file corresponding to the target for recording input and output times.
[0182] The add and record module is used to add the identification code of the created process, the name of the first file for recording input and output times to the directory after detecting the process that creates the virtual machine, and record the creation time of the created process in the first file.
[0183] Module 11 includes:
[0184] The first acquisition module is used to acquire the time of exit event and the time of entry event corresponding to the input and output of each process of the virtual machine based on the identification code of each process;
[0185] Correspondingly, it also includes:
[0186] The first addition module is used to add the timestamps of exit events and entry events to the first file in pairs.
[0187] The preset duration is the time period preceding the occurrence of the last entry event, wherein the occurrence of the last entry event is the entry event among the last pair of exit and entry event occurrence times in the first file; the determination module 12 includes:
[0188] The second acquisition module is used to acquire the difference between the time of the last entry event and the preset duration.
[0189] The positioning module is used to locate the time of the exit event and the time of the entry event corresponding to the first target group in the first file based on the difference.
[0190] The third acquisition module is used to acquire the sum of the differences between the time of exit event and the time of entry event for all groups from the first target group to the last group;
[0191] The acquisition and determination module is used to obtain the sum of the differences and their proportion in the preset time to determine the virtual machine disk input / output latency within the preset time.
[0192] The device includes multiple preset durations and also includes:
[0193] The second creation module is used to create a second file to characterize process stress data;
[0194] The second adding module is used to add the preset duration and the corresponding virtual machine disk input / output latency to the second file according to the correspondence between each preset duration and the corresponding virtual machine disk input / output latency.
[0195] The preset duration is determined based on the input and output parameters set by the kernel query interface;
[0196] If the kernel query interface is found to have neither an input parameter time nor an output parameter time set, the preset duration is from the process creation time to the output parameter time; the determination module 12 includes:
[0197] The fourth acquisition module is used to acquire the second target group corresponding to the creation time of the process and the third target group corresponding to the output time; wherein, the target group is the time when the entry event occurs and the time when the exit event occurs in pairs;
[0198] The fifth acquisition module is used to acquire the sum of the differences between the times of exit events and the times of entry events for all groups from the second target group to the second target group.
[0199] The acquisition and determination module acquires the sum of the differences and their proportion within a preset time period to determine the virtual machine disk input / output latency within the preset time period;
[0200] If the kernel query interface is found to have no input and output parameter timestamps set, the preset duration is from the process creation time to the current query time; the determination module 12 includes:
[0201] The sixth acquisition module is used to acquire the second target group corresponding to the creation time of the process and the fourth target group corresponding to the current query time;
[0202] The seventh acquisition module is used to acquire the sum of the differences between the times of exit events and the times of entry events for all groups from the second target group to the fourth target group.
[0203] The acquisition and determination module acquires the sum of the differences and their proportion within the preset time to determine the virtual machine disk input / output latency within the preset time.
[0204] When the kernel query interface sets the input and output parameter times, the preset duration is from the input parameter time to the output parameter time; the determination module 12 includes:
[0205] The eighth acquisition module is used to acquire the fifth target group corresponding to the input parameter time and the third target group corresponding to the output parameter time.
[0206] The ninth acquisition module is used to acquire the sum of the differences between the times of exit events and the times of entry events for all groups from the fifth target group to the third target group.
[0207] The acquisition and determination module acquires the sum of the differences and their proportion within the preset time to determine the virtual machine disk input / output latency within the preset time.
[0208] If the kernel query interface is detected to have set the input parameter time but not the output parameter time, the preset duration is from the input parameter time to the current query time; the determination module 12 includes:
[0209] The tenth acquisition module is used to acquire the fifth target group corresponding to the input parameter time and the fourth target group corresponding to the current query time;
[0210] The eleventh acquisition module is used to acquire the sum of the differences between the times of exit events and entry events for all groups from the fifth target group to the fourth target group.
[0211] The acquisition and determination module acquires the sum of the differences and their proportion within a preset time period to determine the virtual machine disk input / output latency within the preset time period.
[0212] The device also includes:
[0213] The detection module is used to detect whether the input parameter setting of the kernel query interface is a duration parameter; if so, the second acquisition module is triggered.
[0214] The device also includes:
[0215] The twelfth acquisition module is used to acquire the virtual machine disk input / output latency corresponding to the preset duration from the second file if a request to acquire the virtual machine disk input / output latency is detected.
[0216] The device also includes:
[0217] The settings module is used to set read and write permissions for the first file;
[0218] The deletion module is used to delete the directory corresponding to the process, as well as the first file for recording input and output times and the second file for characterizing process stress data, which are associated with the target, when the destruction of the created process is detected.
[0219] Figure 5 This is a structural diagram of a device for acquiring virtual machine disk input / output latency according to another embodiment of the present invention. This embodiment is based on a hardware perspective, such as... Figure 5 As shown, the devices for acquiring virtual machine disk I / O latency include:
[0220] Memory 20 is used to store computer programs;
[0221] The processor 21 is used to implement the steps of the virtual machine disk input / output latency acquisition method mentioned in the above embodiments when executing a computer program.
[0222] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the CPU, is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.
[0223] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the virtual machine disk input / output latency acquisition method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the aforementioned virtual machine disk input / output latency acquisition method.
[0224] In some embodiments, the device for acquiring virtual machine disk input / output latency may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0225] Those skilled in the art will understand that Figure 5 The structure shown does not constitute a limitation on the device for obtaining virtual machine disk input / output latency and may include more or fewer components than shown.
[0226] The virtual machine disk input / output latency acquisition device provided in this embodiment of the invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the following method: virtual machine disk input / output latency acquisition method, with the same effect as above.
[0227] Finally, the present invention also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the steps described in the above method embodiments.
[0228] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0229] The computer-readable storage medium provided by this invention includes the aforementioned method for obtaining virtual machine disk input / output latency, with the same effect.
[0230] The foregoing has provided a detailed description of the method, apparatus, device, and medium for obtaining virtual machine disk input / output latency provided by the present invention. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
[0231] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for obtaining virtual machine disk input / output latency, characterized in that, Applied to a host machine, the method includes: The exit and entry events of the virtual machine are intercepted by an interceptor function; wherein the exit event is the event in which the process of the virtual machine switches from user mode to kernel mode, and the entry event is the event in which the process of the virtual machine switches from kernel mode to user mode, and the interceptor function is a function used to intercept the exit and entry events of the virtual machine. Obtain the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine; The virtual machine disk input / output latency within the preset time period is determined based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset time period; The preset duration is determined based on the input and output parameters set by the kernel query interface; If the kernel query interface is found to have no input parameter time and no output parameter time, the preset duration is from the creation time of the process to the output parameter time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes: Obtain the second target group corresponding to the creation time of the process and the third target group corresponding to the exit time; wherein, the target group is a pair of times when the entry event occurs and times when the exit event occurs; Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the second target group to the third target group; The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration; If the kernel query interface is found to have no input parameter time and no output parameter time set, the preset duration is from the process creation time to the current query time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes: Obtain the second target group corresponding to the creation time of the process and the fourth target group corresponding to the current query time; Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the second target group to the fourth target group; The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration; When the kernel query interface is detected to set the input parameter time and the output parameter time, the preset duration is from the input parameter time to the output parameter time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input and output of each process within the preset duration includes: Obtain the fifth target group corresponding to the input parameter time and the third target group corresponding to the output parameter time; Obtain the sum of the differences between the times of the exit event and the times of the entry event for all groups from the fifth target group to the third target group; The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration; When the kernel query interface is detected to have set the input parameter time but not the output parameter time, the preset duration is from the input parameter time to the current query time; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset duration includes: Obtain the fifth target group corresponding to the input parameter time and the fourth target group corresponding to the current query time; Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the fifth target group to the fourth target group; The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
2. The method for obtaining virtual machine disk input / output latency according to claim 1, characterized in that, Before determining the virtual machine disk input / output latency within the preset time period based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset time period, the method further includes: Create a directory for recording process information and a first file corresponding to the directory for recording input and output times; After detecting the process that created the virtual machine, add the identification code of the created process, the name of the first file used to record input and output times to the directory, and record the creation time of the created process in the first file; Correspondingly, obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine includes: The time of the exit event and the time of the entry event corresponding to the input and output of each process of the virtual machine are obtained according to the identification code of each process. Correspondingly, after obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine, the method further includes: The timestamps of the exit events and the entry events are added sequentially to the first file.
3. The method for obtaining virtual machine disk input / output latency according to claim 2, characterized in that, The preset duration is a preset duration preceding the time of the last entry event, wherein the time of the last entry event is the entry event time in the last pair of exit event times and entry event times among all pairs of exit event times and entry event times in the first file; determining the virtual machine disk input / output latency within the preset duration based on the proportion of the difference between the entry event time and exit event time corresponding to the input / output of each process within the preset duration includes: Obtain the difference between the time of the last entry event and the preset duration; Based on the difference, locate the time of the exit event and the time of the entry event corresponding to the first target group in the first file; Obtain the sum of the differences between the time of occurrence of the exit event and the time of occurrence of the entry event for all groups from the first target group to the last group; The sum of the differences is used as a percentage of the preset duration to determine the virtual machine disk input / output latency within the preset duration.
4. The method for obtaining virtual machine disk input / output latency according to claim 3, characterized in that, The preset duration is multiple, and after obtaining the time of occurrence of the exit event and the time of occurrence of the entry event corresponding to the input and output of each process of the virtual machine, it further includes: Create a second file to characterize process stress data; According to the correspondence between each preset duration and the corresponding virtual machine disk input / output latency, each preset duration and the corresponding virtual machine disk input / output latency are added to the second file.
5. The method for obtaining virtual machine disk input / output latency according to claim 3, characterized in that, Before obtaining the difference between the time of the last entry event and the preset duration, the method further includes: Check if the input parameter setting of the kernel query interface is a duration parameter; If so, proceed to the step of obtaining the difference between the time of the last entry event and the preset duration.
6. The method for obtaining virtual machine disk input / output latency according to claim 4, characterized in that, After adding the preset duration and its corresponding virtual machine disk input / output latency to the second file according to the correspondence between the preset duration and the corresponding virtual machine disk input / output latency, the method further includes: If a request to obtain virtual machine disk input / output latency is detected, the virtual machine disk input / output latency corresponding to the preset duration is obtained from the second file according to the preset duration in the request.
7. The method for obtaining virtual machine disk input / output latency according to any one of claims 2 to 6, characterized in that, After creating the directory for recording process information and the first file corresponding to the directory for recording input and output times, the method further includes: Set read and write permissions for the first file; Correspondingly, if the destruction of the created process is detected, the directory corresponding to the process, the first file used to record input and output time, and the second file used to characterize process pressure data corresponding to the target are deleted.
8. A device for acquiring virtual machine disk input / output latency, characterized in that, Applied to a host machine, the device includes: An interception module is used to intercept virtual machine exit events and entry events through an interceptor function; wherein, the exit event is the event in which the virtual machine's process switches from user mode to kernel mode, the entry event is the event in which the virtual machine's process switches from kernel mode to user mode, and the interceptor function is a function used to intercept virtual machine exit events and entry events; The acquisition module is used to acquire the time when the exit event occurs and the time when the entry event occurs, corresponding to the input and output of each process of the virtual machine; The determining module is used to determine the virtual machine disk input / output latency within the preset time period based on the proportion of the difference between the time of the entry event and the time of the exit event corresponding to the input / output of each process within the preset time period; The preset duration is determined based on the input and output parameters set by the kernel query interface; If the kernel query interface is found to have neither an input parameter time nor an output parameter time set, the preset duration is from the process creation time to the output parameter time; the determining module includes: The fourth acquisition module is used to acquire the second target group corresponding to the creation time of the process and the third target group corresponding to the output time; wherein, the target group is the time when the entry event occurs and the time when the exit event occurs in pairs; The fifth acquisition module is used to acquire the sum of the differences between the times of exit events and entry events for all groups from the second target group to the third target group. The acquisition and determination module acquires the sum of the differences and their proportion within a preset time period to determine the virtual machine disk input / output latency within the preset time period; If the kernel query interface is found to have no input and output parameter timestamps set, the preset duration is from the process creation time to the current query time; the determining module includes: The sixth acquisition module is used to acquire the second target group corresponding to the creation time of the process and the fourth target group corresponding to the current query time; The seventh acquisition module is used to acquire the sum of the differences between the times of exit events and the times of entry events for all groups from the second target group to the fourth target group. The acquisition and determination module acquires the sum of the differences and their proportion within the preset time to determine the virtual machine disk input / output latency within the preset time. When the kernel query interface sets the input and output parameter times, the preset duration is from the input parameter time to the output parameter time; the determining module includes: The eighth acquisition module is used to acquire the fifth target group corresponding to the input parameter time and the third target group corresponding to the output parameter time. The ninth acquisition module is used to acquire the sum of the differences between the times of exit events and the times of entry events for all groups from the fifth target group to the third target group. The acquisition and determination module acquires the sum of the differences and their proportion within a preset time period to determine the virtual machine disk input / output latency within the preset time period; If the kernel query interface sets the input parameter time but not the output parameter time, the preset duration is from the input parameter time to the current query time; the determining module includes: The tenth acquisition module is used to acquire the fifth target group corresponding to the input parameter time and the fourth target group corresponding to the current query time; The eleventh acquisition module is used to acquire the sum of the differences between the times of exit events and entry events for all groups from the fifth target group to the fourth target group. The acquisition and determination module acquires the sum of the differences and their proportion within a preset time period to determine the virtual machine disk input / output latency within the preset time period.
9. A device for acquiring virtual machine disk input / output latency, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the virtual machine disk input / output latency acquisition method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the virtual machine disk input / output latency acquisition method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Network data packet processing method and device
CN113923212A
NVMe disk mounting method and equipment, and storage medium
CN114047888A