Time synchronization method and device between virtual machines, computing equipment and storage medium

By using the PTP mechanism and virtual PTP technology in service virtual machines, combined with the Hypervisor's security check and time synchronization counter, high-precision time synchronization between virtual machines is achieved, solving the problem that traditional NTP cannot meet the needs of time-sensitive applications and ensuring the accuracy and security of virtual machine time.

CN120750475APending Publication Date: 2025-10-03KYLAND TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510834702.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

Traditional network time protocols (such as NTP) cannot meet the high-precision synchronization requirements of time-sensitive applications in virtualized environments, such as financial trading systems and industrial control systems.

Method used

The service virtual machine uses the PTP mechanism to obtain PTP time, and synchronizes the time between the hypervisor, service virtual machine, and user virtual machine through virtual PTP technology. The hypervisor performs security verification on the received PTP time, uses the time synchronization counter to maintain the growth of the PTP time, and notifies the application virtual machine synchronization through time synchronization virtual interrupts.

Benefits of technology

It achieves high-precision synchronization of the time of all virtual machines within the same physical node, ensuring time accuracy and security, especially for real-time virtual machines that cannot run the PTP protocol.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120750475A_ABST
    Figure CN120750475A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a time synchronization method and device between virtual machines, computing equipment and a storage medium, the virtual machines are type1 virtualized virtual machines and comprise a service virtual machine and an application virtual machine, the application virtual machine comprises a real-time virtual machine, and the method comprises the steps that the service virtual machine obtains PTP time through a PTP mechanism; the service virtual machine is used for sending the PTP (Precision Time Protocol) time to the Hypervisor through the Hypercall; after the Hypervisor is synchronized with the received PTP time, the Hypervisor notifies each application virtual machine to synchronize the PTP time; and each application virtual machine obtains the PTP time from the Hypervisor through the hypercall, and the PTP time is synchronized with the PTP time. According to the technical scheme provided by the embodiment of the invention, the PTP time is obtained through the service virtual machine by utilizing the PTP mechanism, and the time among the Hypervisor, the service virtual machine and the user virtual machine is synchronized by adopting the virtual PTP technology, so that high-precision synchronization of the time of all virtual machines in the same physical node is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of operating system technology, and in particular to a method, apparatus, computing device, and storage medium for synchronizing time between virtual machines. Background Art

[0002] In virtualized environments, precise time synchronization is extremely important, especially for time-sensitive applications such as financial trading systems, telecommunication networks, and industrial control systems.

[0003] However, traditional network time protocols (such as NTP) may not meet the needs of these applications due to their limited accuracy. Therefore, integrating PTP support in virtualized environments can provide more accurate time synchronization services. Summary of the Invention

[0004] In view of this, the embodiments of the present application provide a method, apparatus, computing device and storage medium for time synchronization between virtual machines. The technical solution of the embodiments of the present application obtains PTP time by using the PTP mechanism through the service virtual machine, and adopts virtual PTP technology to synchronize the time between the Hypervisor, service virtual machine and user virtual machine, thereby ensuring high-precision synchronization of the time of all virtual machines in the same physical node.

[0005] In a first aspect, an embodiment of the present application provides a method for time synchronization between virtual machines, wherein the virtual machines are type 1 virtualized virtual machines, including service virtual machines and application virtual machines, and the application virtual machines include real-time virtual machines. The method includes: the service virtual machine obtains PTP time through the PTP mechanism; the service virtual machine sends the PTP time to the Hypervisor through hyper_call; the Hypervisor synchronizes with the received PTP time and notifies each of the application virtual machines to synchronize the PTP time; each of the application virtual machines obtains the PTP time from the Hypervisor through hyper_call and synchronizes with the PTP time.

[0006] As described above, the service VM obtains the PTP time through the PTP mechanism, and synchronizes the time between the Hypervisor, service VM, and user VM through virtual PTP technology, ensuring high-precision synchronization of the time of all VMs in the same physical node.

[0007] In a possible implementation manner of the first aspect, the method further includes: after the service virtual machine sends the PTP time to the hypervisor and before the hypervisor synchronizes with the received PTP time, the hypervisor performs a security check on the received PTP time.

[0008] As shown above, the Hypervisor is a highly secure software environment that performs security verification on the received PTP time to prevent illegal tampering with the PTP time.

[0009] In a possible implementation of the first aspect, the hypervisor performs a security check on the received PTP time, including: when an absolute value of a deviation between a first offset of the received PTP time and a second offset of a time synchronization counter of the hypervisor is less than a set value, the security check passes, wherein the first offset is an offset of the received PTP time between current synchronization and a previous synchronization, and the second offset is an offset of the time synchronization counter between current synchronization and a previous synchronization.

[0010] Based on the above, the offset of the received PTP time between the current synchronization and the previous synchronization is compared with the offset of the hypervisor's time synchronization counter through the timestamp difference comparison method to accurately verify whether the received PTP time is safe.

[0011] In a possible implementation manner of the first aspect, the method further includes: after the security check passes, the Hypervisor maintains an increase in the PTP time in the Hypervisor through the time synchronization counter.

[0012] As described above, the hypervisor maintains its own PTP time growth through the time synchronization counter (TSC), thereby obtaining the adjusted PTP time for high-precision time synchronization of application virtual machines.

[0013] In a possible implementation of the first aspect, the hypervisor notifies each of the application virtual machines to synchronize PTP time, including: the hypervisor injects a time synchronization virtual interrupt to each of the application virtual machines to notify the application virtual machines to synchronize PTP time.

[0014] From the above, the Hypervisor injects a time synchronization virtual interrupt to each application virtual machine to notify it to obtain PTP time, so that each application virtual machine can synchronize PTP time in time by responding to the interrupt

[0015] In a possible implementation of the first aspect, each of the application virtual machines obtains the PTP time from the hypervisor through a hyper_call, including: each of the application virtual machines responds to the interrupt and obtains the PTP time from the hypervisor through a hyper_call.

[0016] From the above, the application virtual machine synchronizes the PTP time in time by responding to the time synchronization virtual interrupt delivered to it

[0017] In a possible implementation manner of the first aspect, the method further includes: when each of the application virtual machines responds to the interrupt, further obtaining the wall clock time corresponding to the PTP time from the hypervisor through hyper_call.

[0018] As described above, the application virtual machine obtains the wall clock time corresponding to the PTP time, so that the application virtual machine and the hypervisor use the same wall clock time, avoiding the impact of the conversion between the PTP time and the corresponding wall clock time on the synchronization time of the application virtual machine.

[0019] In the second aspect, an embodiment of the present application provides a time synchronization device between virtual machines, wherein the virtual machine is a type 1 virtualized virtual machine, including a service virtual machine and an application virtual machine, the application virtual machine includes a real-time virtual machine, and the device includes: a first PTP module, located in the service virtual machine, for the service virtual machine to obtain PTP time through the PTP mechanism; and also for the service virtual machine to send the PTP time to the Hypervisor through hyper_call; a second PTP module, located in the Hypervisor, for the Hypervisor to synchronize with the received PTP time and notify each of the application virtual machines to synchronize the PTP time; a third PTP module, located in each of the application virtual machines, for the application virtual machine to obtain the PTP time from the Hypervisor through hyper_call and synchronize with it.

[0020] As described above, the service VM obtains the PTP time through the PTP mechanism, and synchronizes the time between the Hypervisor, service VM, and user VM through virtual PTP technology, ensuring high-precision synchronization of the time of all VMs in the same physical node.

[0021] In a possible implementation of the second aspect, it further includes: a security verification module, configured to, after the service virtual machine sends the PTP time to the hypervisor and before the hypervisor notifies each of the application virtual machines to obtain the PTP time, perform a security verification on the received PTP time on the hypervisor.

[0022] As shown above, the Hypervisor is a highly secure software environment that performs security verification on the received PTP time to prevent illegal tampering with the PTP time.

[0023] In a possible implementation of the second aspect, the security verification module is specifically used to include: when the absolute value of the deviation between the first offset of the received PTP time and the second offset of the time synchronization counter of the Hypervisor is less than a set value, the security verification passes, wherein the first offset is the offset of the received PTP time between this synchronization and the last synchronization, and the second offset is the offset of the time synchronization counter between this synchronization and the last synchronization.

[0024] Based on the above, the offset of the received PTP time between the current synchronization and the previous synchronization is compared with the offset of the hypervisor's time synchronization counter through the timestamp difference comparison method to accurately verify whether the received PTP time is safe.

[0025] In a possible implementation manner of the second aspect, the second PTP module is further configured to, after the security check passes, enable the Hypervisor to maintain an increase in the PTP time in the Hypervisor through the time synchronization counter.

[0026] As described above, the hypervisor maintains its own PTP time growth through the time synchronization counter (TSC), thereby obtaining the adjusted PTP time for high-precision time synchronization of application virtual machines.

[0027] In a possible implementation manner of the second aspect, the second PTP module is specifically configured for the Hypervisor to inject a time synchronization virtual interrupt into each of the application virtual machines to notify the acquisition of the PTP time.

[0028] From the above, the Hypervisor injects a time synchronization virtual interrupt to each application virtual machine to notify it to obtain PTP time, so that each application virtual machine can obtain and synchronize PTP time in time by responding to the interrupt

[0029] In a possible implementation manner of the second aspect, the third PTP module is specifically configured to cause the application virtual machine where the module is located to respond to the interrupt and obtain the PTP time from the Hypervisor through a hyper_call.

[0030] From the above, the application virtual machine obtains and synchronizes the PTP time in time by responding to the time synchronization virtual interrupt delivered to it

[0031] In a possible implementation manner of the second aspect, the third PTP module is further configured to, when the application virtual machine in which it is located responds to the interrupt, obtain the wall clock time corresponding to the PTP time from the Hypervisor through hyper_call.

[0032] As described above, the application virtual machine obtains the wall clock time corresponding to the PTP time, so that the application virtual machine and the hypervisor use the same wall clock time, avoiding the impact of the conversion between the PTP time and the corresponding wall clock time on the synchronization time of the application virtual machine.

[0033] In a third aspect, an embodiment of the present application provides a computing device, including:

[0034] bus;

[0035] a communication interface connected to the bus;

[0036] at least one processor connected to the bus; and

[0037] At least one memory is connected to the bus and stores program instructions, and when the program instructions are executed by the at least one processor, the at least one processor executes the method described in any embodiment of the first aspect of the present application.

[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a computer, causes the computer to execute the method described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A schematic diagram of the structure of the virtual machine system in each embodiment of the present application;

[0040] Figure 2 This is a flow chart of a first embodiment of a method for synchronizing time between virtual machines according to the present application;

[0041] Figure 3 This is a flowchart of a second embodiment of a method for time synchronization between virtual machines of the present application;

[0042] Figure 4 This is a schematic diagram of the architecture of the first framework of Example 2 of a method for time synchronization between virtual machines of the present application;

[0043] Figure 5 This is a schematic diagram of the architecture of the second framework of Example 2 of a method for time synchronization between virtual machines of the present application;

[0044] Figure 6 This is a structural diagram of a first embodiment of a time synchronization device between virtual machines of the present application;

[0045] Figure 7 This is a structural diagram of a second embodiment of a time synchronization device between virtual machines of the present application;

[0046] Figure 8 A schematic diagram of the structure of the computing device of this application. DETAILED DESCRIPTION

[0047] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0048] In the following description, the terms "first\second\third, etc." or module A, module B, module C, etc. are not only used to distinguish similar objects, or to distinguish different embodiments, but do not represent a specific ordering of the objects. It can be understood that the specific order or sequence can be interchanged where permitted so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0049] In the following description, the numbers representing the steps, such as S110, S120, etc., do not necessarily mean that the steps must be executed in this manner. If permitted, the order of the steps can be interchanged or they can be executed simultaneously.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0051] An embodiment of the present application provides a method, apparatus, computing device, and storage medium for time synchronization between virtual machines. The method includes: the service virtual machine obtains PTP time through a PTP mechanism; the service virtual machine sends the PTP time to a hypervisor through a hyper_call; the hypervisor synchronizes with the received PTP time and notifies each of the application virtual machines to synchronize with the PTP time; each of the application virtual machines obtains the PTP time from the hypervisor through a hyper_call and synchronizes with the PTP time.

[0052] The technical solution of the embodiment of the present application uses the PTP mechanism to obtain PTP time through the service virtual machine, and adopts virtual PTP technology to synchronize the time between the hypervisor, service virtual machine and user virtual machine, ensuring high-precision synchronization of the time of all virtual machines in the same physical node, especially for real-time virtual machines that cannot run the PTP protocol.

[0053] The following describes various embodiments of the present application in conjunction with the accompanying drawings. Figure 1 Introduce the virtual machine system of this application.

[0054] Figure 1The structure of the virtual machine system of the present application is shown. Each virtual machine is deployed on a hypervisor, and the hypervisor is deployed on a hardware system. The hardware system is virtualized based on type 1 to provide a virtual environment for each virtual machine.

[0055] Among them, virtual machines include service virtual machines and application virtual machines. Application virtual machines include real-time virtual machines (RTOSVMs). Service virtual machines deploy the PTP mechanism and run the PTP protocol. Real-time virtual machines and type 1-based hypervisors cannot run the PTP protocol.

[0056] The following combination Figure 2 The present invention introduces a method for synchronizing time between virtual machines according to a first embodiment of the present invention.

[0057] Figure 2 The flowchart of a first embodiment of a method for synchronizing time between virtual machines is shown, including steps S210 to S240.

[0058] S210: The service virtual machine obtains the PTP time through the PTP mechanism.

[0059] The service VM deploys the PTP mechanism and supports the PTP protocol, periodically obtaining the PTP time from an external clock reference source or a PTP clock in the hardware system. The PTP time is a 64-bit count, also known as the PTP timestamp. The PTP protocol includes the 802.1AS protocol.

[0060] When the service VM is a Linux system, you can deploy the Linux-PTP mechanism (Linux's native PTP mechanism) or other PTP mechanisms. When the service VM is a non-Linux system, you can deploy the PTP mechanism by deploying third-party software or modifying the system's native configuration.

[0061] S220: The service virtual machine sends the PTP time to the Hypervisor via hyper_call.

[0062] Hyper_call is a mechanism in a virtualized environment whereby a virtual machine initiates a privileged operation request to a hypervisor, executing sensitive instructions on the hypervisor, which has the advantages of resource isolation and performance close to that of a physical machine. In some embodiments, the hyper_call is implemented via a system call.

[0063] The service virtual machine obtains the PTP time from the external PTP clock source every cycle and sends the PTP time to the hypervisor.

[0064] S230: The Hypervisor synchronizes with the received PTP time and notifies each application virtual machine to synchronize with the PTP time.

[0065] Since the real-time virtual machine cannot run the PTP mechanism, it obtains the PTP time from the hypervisor to synchronize with the PTP time.

[0066] In some embodiments, after the service VM sends the PTP time to the hypervisor and before the hypervisor notifies each application VM to synchronize its PTP time, the hypervisor performs a security check on the received PTP time. As a highly secure software environment, the hypervisor performs a security check on the received PTP time to prevent unauthorized tampering. In some embodiments, if the hypervisor fails the security check on the received PTP time, it notifies the service VM.

[0067] In some embodiments, the security check includes: when the absolute value of the deviation between the first offset of the received PTP time and the second offset of the hypervisor's time synchronization counter (TSC) is less than a set value, the security check passes. The received PTP time offset between the current synchronization and the previous synchronization is compared with the offset of the hypervisor's time synchronization counter to determine whether the received PTP time is secure.

[0068] The first offset is the offset between the received PTP time and the previous synchronization. The second offset is the offset between the hypervisor's time synchronization counter and the previous synchronization. The count of this time synchronization counter, also known as the hypervisor time count, is obtained from the counter on the computer system chip.

[0069] In some embodiments, after the hypervisor passes the security check of the received PTP time, the hypervisor synchronizes with the PTP time and maintains the growth of the PTP time in the hypervisor through its time synchronization counter to obtain accurate PTP time before the next synchronization, including: adding an offset from the count of the time synchronization counter at that time to the current count to the received PTP time as the current PTP time.

[0070] In some embodiments, the hypervisor injects a time synchronization virtual interrupt into each application virtual machine to notify it to obtain the PTP time, so that each application virtual machine can obtain and synchronize the PTP time in a timely manner by responding to the interrupt.

[0071] S240: Each application virtual machine obtains the PTP time through hyper_call and synchronizes with the PTP time.

[0072] Each application virtual machine obtains PTP time through a hyper_call interface, which has the advantages of resource isolation and performance close to that of a physical machine. In some embodiments, the hyper_call is implemented through a system call.

[0073] The PTP time is calibrated by adding a newly added offset of the hypervisor's TSC count based on the PTP time received during this synchronization, and can still be called PTP time.

[0074] In some embodiments, each application virtual machine responds to a time synchronization virtual interrupt delivered to it and obtains the PTP time from the Hypervisor through a hyper_call, thereby obtaining the PTP time in a timely manner.

[0075] In some embodiments, when each application virtual machine responds to a delivered time synchronization virtual interrupt, it also obtains the wall clock time (clock time) corresponding to the PTP time from the hypervisor through a hyper_call. The application virtual machine also obtains the wall clock time corresponding to the PTP time, so that the application virtual machine and the hypervisor use the same wall clock time, avoiding the impact of the conversion between the PTP time and the corresponding wall clock time on the application virtual machine's synchronization time.

[0076] In some embodiments, the service virtual machine also obtains NTP time through its own NTP mechanism and sends it to the hypervisor, which then sends the NTP time to the application virtual machine. In some embodiments, when both the NTP and PTP mechanisms operate simultaneously, the time obtained by the NTP mechanism is used for initial time synchronization after each virtual machine is started, while the time obtained by the PTP mechanism is used for precise synchronization of each virtual machine. If a PTP problem occurs, synchronization is performed again through the NTP mechanism. In some embodiments, when the service virtual machine receives a security check from the hypervisor that fails the received PTP time, the service virtual machine initiates NTP time synchronization and sends the obtained NTP time to the hypervisor.

[0077] In summary, the first embodiment of a method for synchronizing time between virtual machines uses virtual PTP technology to synchronize the time between the hypervisor, service virtual machines, and user virtual machines, ensuring high-precision time synchronization of all virtual machines in the same physical node.

[0078] The following combination Figures 3 to 5 The second embodiment of the time synchronization method between virtual machines of the present application is introduced.

[0079] A method for synchronizing time between virtual machines in Example 2 is a specific implementation of the method for synchronizing time between virtual machines in Example 1, and has all its advantages. Figure 1 The virtual machine system shown is based on the first embodiment of a method for time synchronization between virtual machines. The hypervisor adds security verification of the received PTP time, and the service virtual machine is a Linux system with a built-in Linux-PTP mechanism.

[0080] Figure 3 The flowchart of a second embodiment of a method for synchronizing time between virtual machines is shown, including steps S310 to S360.

[0081] S310: The service virtual machine obtains PTP time through the Linux-PTP mechanism.

[0082] The service virtual machine periodically obtains the PTP time from an external clock reference source or a PTP clock in the hardware system where the service virtual machine is located.

[0083] S320: The service virtual machine sends the PTP time to the Hypervisor through hyper_call.

[0084] The service VM uses hyper_call to send the PTP time to the hypervisor, which has the advantages of resource isolation and performance close to that of a physical machine. This hyper_call is implemented through a system call.

[0085] S330: The Hypervisor performs security verification on the PTP time.

[0086] Among them, because the Hypervisor is a high-security software environment, the received PTP time must be security-verified from the service virtual machine.

[0087] The security verification process includes:

[0088] (1) Obtain the first offset of the PTP time and the second offset of the hypervisor's time synchronization counter (TSC). The first offset is the offset of the PTP time between the current synchronization and the previous synchronization. The second offset is the offset of the hypervisor's time synchronization counter between the current synchronization and the previous synchronization.

[0089] (2) When the absolute value of the deviation between the first offset of the PTP time and the second offset of the hypervisor's time synchronization counter is less than the set value, the security check passes; otherwise, there is a time synchronization error.

[0090] It should be emphasized that when the Hypervisor is started or a time synchronization error occurs, the first time the PTP time is received, no security check is performed, and step S340 is directly executed.

[0091] When the PTP time passes the security check, steps S340 to S350 are executed; otherwise, step S360 is executed.

[0092] S340: The Hypervisor synchronizes with the received PTP time and injects a time synchronization virtual interrupt to each application virtual machine to notify the synchronized PTP time.

[0093] The Hypervisor delivers a time synchronization virtual interrupt to each application virtual machine, notifying each application virtual machine to obtain and synchronize the PTP time in a timely manner.

[0094] Among them, from the current synchronization to the next synchronization period, the hypervisor's TSC maintains the growth of PTP time and translates PTP time into wall clock time, that is, world time.

[0095] S350: Each application virtual machine responds to the time synchronization virtual interrupt delivered to it, obtains the PTP time and the corresponding wall clock time from the hypervisor through the hyper_call interface, and synchronizes with the PTP time.

[0096] Among them, the hyper_call is implemented through a system call, relying on the Hypervisor-specific Hyper_call to transmit the PTP time counter value and the corresponding wall clock time from the Hyperviosr to the application virtual machine. The function of the system call HYPER_CALL_PTP_FUNC_ID is shown in Table 1.

[0097] Table 1

[0098]

[0099] The PTP time is adjusted by adding the newly added count of the hypervisor's TSC to the PTP time received during this synchronization. The adjusted PTP time can still be called the PTP time.

[0100] S360: The Hypervisor performs troubleshooting corresponding to the time synchronization error.

[0101] The Hypervisor notifies the service virtual machine of the time synchronization error while performing fault processing corresponding to the time synchronization error.

[0102] Figure 4This figure illustrates the architecture of the first framework of Example 2 of a method for time synchronization between virtual machines, including a hardware system, a hypervisor, a Linux system, an RTOS, and an nRTOS. The Linux system is a service virtual machine, and the RTOS and nRTOS are application virtual machines. By way of example, the figure includes one RTOS and one nRTOS. In actual scenarios, multiple RTOSes and nRTOSes may be used depending on requirements.

[0103] The Linux kernel supports the Linux PTP mechanism, including the Network Stack, NIC driver, and PTP Clock. The Network Stack implements the network protocol stack, the NIC driver is used to drive the network card that supports PTP in the hardware system, and the PTP Clock is used to drive the PTP clock.

[0104] The Linux system runs Linux PTP, which includes phyc2sys, Network Stack, ptp4l, and PMC. phyc2sys synchronizes the system clock with the PTP hardware clock. ptp4l implements functions such as Boundary Clock, Ordinary Clock, and Transparent Clock. This means it can set the clock as either a master or slave. In this example, the slave clock is set. The Network Stack implements the network protocol stack, and the PMC manages and monitors the PTP clock.

[0105] Linux PTP acquires PTP time, stores it in the system RTC, maintains it, provides it to each app, and sends it to the hypervisor via a hyper_call. After receiving the PTP time, the hypervisor maintains it via the TSC and provides the calibrated PTP time to the application via a hyper_call when synchronizing the application virtual machine.

[0106] The user-state Chronyd of each application virtual machine is used as a background daemon process, responsible for communicating with the time source, calculating clock deviation, and adjusting the kernel system clock of the application virtual machine. The kernel state of each application virtual machine provides a PTP kernel driver module, which provides the user-state PTP device PTP.ko. When the user-state Chronyd performs time synchronization, it obtains time from the PTP device PTP.ko. The PTP driver obtains the PTP time adjusted by the hypervisor through the hyper_cal interface.

[0107] Figure 5This figure illustrates the second framework structure of a second embodiment of a method for inter-virtual machine time synchronization, including a driver system, a hypervisor, a service virtual machine, and an application virtual machine. The driver system includes a board-level driver (BSP), a PTP clock driver (PTP CLock), a timer driver (Tick), a time synchronization counter driver (TSC), and a real-time clock counter driver (RTC). The figure illustrates one application virtual machine, but in actual scenarios, multiple application virtual machines may be included as needed.

[0108] The service VM includes a virtual Linux system for the operation and management terminal and a cloud desktop virtualization platform (VTS). The hypervisor includes a security verification module (NTPSL). The VTS obtains the PTP time from the PTP Clock driver through the service VM's Linux-PTP mechanism and sends it to the hypervisor. The NTPSL performs a security verification on the received PTP time, feeds the verification result back to the VTS, and sends the adjusted PTP time to the application VM.

[0109] The second framework also supports the NTP mechanism. The virtual Linux system uses its own NTP synchronization component to obtain the NTP time through the RTC driver and sends it to the hypervisor, which then transmits the NTP time to the application virtual machines. When both NTP and PTP mechanisms operate simultaneously, the time obtained by the NTP mechanism is used as the initial time after each virtual machine starts, while the time obtained by PTP is used for accurate synchronization of each virtual machine. If PTP issues arise, synchronization is restored through the NTP mechanism.

[0110] In summary, the second embodiment of a method for synchronizing time between virtual machines not only uses virtual PTP technology to synchronize the time between the hypervisor, service virtual machines, and user virtual machines, ensuring high-precision synchronization of the time of all virtual machines in the same physical node, but also the hypervisor provides a time security verification function to perform security verification on the PTP time of the service virtual machine to ensure the correctness of the time synchronized to the virtual machine.

[0111] The following combination Figure 6 The present invention introduces a first embodiment of a time synchronization device between virtual machines.

[0112] A time synchronization device between virtual machines is deployed in Figure 1 The virtual machine system shown runs the first embodiment of a method for time synchronization between virtual machines and has all its advantages.

[0113] Figure 6 The structure of a first embodiment of a time synchronization device between virtual machines is shown, including: a first PTP module 610, a second PTP module 620 and a third PTP module 630.

[0114] The first PTP module 610 is located in the service virtual machine and is used to obtain the PTP time through the PTP mechanism and send the PTP time to the hypervisor through hyper_call. For its working principle and method, please refer to steps S210 and S220 of the first embodiment of a method for time synchronization between virtual machines.

[0115] The second PTP module 620 is located in the hypervisor and is used to notify each application virtual machine to synchronize PTP time after the hypervisor synchronizes with the received PTP time. For its working principle and method, please refer to step S230 of the first embodiment of a method for time synchronization between virtual machines.

[0116] The third PTP module 630 is located in each application virtual machine and is used to obtain PTP time through hyper_call and synchronize with PTP time. For its working principle and method, please refer to step S240 of the first embodiment of a method for time synchronization between virtual machines.

[0117] The following combination Figure 7 The second embodiment of the time synchronization device between virtual machines of the present application is introduced.

[0118] A second embodiment of a time synchronization device between virtual machines is further deployed in Figure 1 The virtual machine system shown runs the second embodiment of a method for time synchronization between virtual machines and has all its advantages.

[0119] Figure 7 The structure of a second embodiment of a time synchronization device between virtual machines is shown, including: a first PTP module 710, a security verification module 720, a second PTP module 730, a fault processing module 740 and a third PTP module 750.

[0120] The first PTP module 710 is located in the service virtual machine and is used for the service virtual machine to obtain the PTP time through the Linux-PTP mechanism and send the PTP time to the hypervisor through hyper_call. For its working principle and method, please refer to steps S310 and S320 of the second embodiment of a method for time synchronization between virtual machines.

[0121] The security verification module 720 is located in the Hypervisor and is used for the Hypervisor to perform security verification on the PTP time. For its working principle and method, please refer to step S330 of the second embodiment of a method for time synchronization between virtual machines.

[0122] The second PTP module 730 is located in the hypervisor and is used to synchronize the hypervisor with the received PTP time and inject a time synchronization virtual interrupt to each application virtual machine to notify each application virtual machine to synchronize with the PTP time. For its working principle and method, please refer to step S340 of the second embodiment of a method for time synchronization between virtual machines.

[0123] The fault handling module 740 is located in the Hypervisor and is used for the Hypervisor to handle faults corresponding to time synchronization errors. For its working principle and method, please refer to step S360 of the second embodiment of a method for time synchronization between virtual machines.

[0124] The third PTP module 750 resides in the application virtual machine. Each application virtual machine responds to a time synchronization virtual interrupt delivered to it, obtains the PTP time and the corresponding wall clock time from the hypervisor via a hyper_call, and synchronizes with the PTP time. For details on its operating principle and method, please refer to step S350 of the second embodiment of a method for time synchronization between virtual machines.

[0125] The present application embodiment also provides a computing device, Figure 8 Detailed introduction.

[0126] The computing device 800 includes a processor 810 , a memory 820 , a communication interface 830 , and a bus 840 .

[0127] It should be understood that the communication interface 830 in the computing device 800 shown in this figure can be used to communicate with other devices.

[0128] The processor 810 may be connected to a memory 820. The memory 820 may be used to store the program code and data. Therefore, the memory 820 may be a storage unit within the processor 810, an external storage unit independent of the processor 810, or a component including both a storage unit within the processor 810 and an external storage unit independent of the processor 810.

[0129] Optionally, computing device 800 may further include a bus 840. Memory 820 and communication interface 830 may be connected to processor 810 via bus 840. Bus 840 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, for example. Bus 840 may be classified as an address bus, a data bus, a control bus, and the like. For ease of illustration, the figure uses only one line, but this does not imply that there is only one bus or only one type of bus.

[0130] It should be understood that in the embodiment of the present application, the processor 810 can adopt a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. Alternatively, the processor 810 adopts one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiment of the present application.

[0131] The memory 820 may include a read-only memory and a random access memory, and provides instructions and data to the processor 810. A portion of the processor 810 may also include a non-volatile random access memory. For example, the processor 810 may also store information about the device type.

[0132] When the computing device 800 is running, the processor 810 executes the computer-executable instructions in the memory 820 to perform the operating steps of each method embodiment.

[0133] It should be understood that the computing device 800 according to the embodiment of the present application can correspond to the corresponding subject in executing the method according to each embodiment of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 800 are respectively for implementing the corresponding processes of each method of the present embodiment. For the sake of brevity, they will not be repeated here.

[0134] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0135] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0136] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0137] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0138] 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.

[0139] If the functions are implemented in the form of 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 application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0140] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it is used to perform the operating steps of each method embodiment.

[0141] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media.Computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium.Computer-readable storage medium can be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof.More specific examples (non-exhaustive list) of computer-readable storage medium include, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.

[0142] A computer-readable signal medium may include a data signal transmitted in baseband or as part of a carrier wave, which carries computer-readable program code. Such a transmitted data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, transfer, or convey a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0143] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0144] The computer program code for performing the operations of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0145] Note that the above are only preferred embodiments of the present application and the technical principles employed. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of protection of the present application, all of which fall within the scope of protection of the present application.

Claims

1. A method for synchronizing time between virtual machines, characterized in that: The virtual machine is a type 1 virtualized virtual machine, including a service virtual machine and an application virtual machine, wherein the application virtual machine includes a real-time virtual machine. The method includes: The service virtual machine obtains the PTP time through the PTP mechanism and sends the PTP time to the Hypervisor through hyper_call; The Hypervisor synchronizes with the received PTP time and notifies each of the application virtual machines to synchronize with the PTP time; Each of the application virtual machines obtains the PTP time from the Hypervisor through hyper_call and synchronizes with it.

2. The method according to claim 1, characterized in that Also includes: After the service virtual machine sends the PTP time to the hypervisor and before the hypervisor synchronizes with the received PTP time, the hypervisor performs a security check on the received PTP time.

3. The method according to claim 2, characterized in that The Hypervisor performs security verification on the received PTP time, including: When the absolute value of the deviation between the first offset of the received PTP time and the second offset of the time synchronization counter of the Hypervisor is less than a set value, the security check passes, wherein the first offset is the offset of the received PTP time between this synchronization and the last synchronization, and the second offset is the offset of the time synchronization counter between this synchronization and the last synchronization.

4. The method according to claim 3, characterized in that Also includes: When the security check passes, the Hypervisor maintains the growth of the PTP time in the Hypervisor through the time synchronization counter.

5. The method according to claim 1, characterized in that: The Hypervisor notifies each of the application virtual machines to synchronize PTP time, including: The Hypervisor injects a time synchronization virtual interrupt to each of the application virtual machines to notify the synchronized PTP time.

6. The method according to claim 5, characterized in that Each application virtual machine obtains the PTP time from the Hypervisor through hyper_call, including: Each of the application virtual machines responds to the interrupt and obtains the PTP time from the Hypervisor through hyper_call.

7. The method according to claim 6, characterized in that Also includes: When each of the application virtual machines responds to the interrupt, it also obtains the wall clock time corresponding to the PTP time from the Hypervisor through hyper_call.

8. A time synchronization device between virtual machines, characterized in that: The virtual machine is a type 1 virtualized virtual machine, including a service virtual machine and an application virtual machine, wherein the application virtual machine includes a real-time virtual machine. The device includes: A first PTP module, located in the service virtual machine, is used for the service virtual machine to obtain PTP time through the PTP mechanism and send the PTP time to the hypervisor through hyper_call; A second PTP module is located in the Hypervisor, and is used to synchronize the Hypervisor with the received PTP time and notify each of the application virtual machines to synchronize the PTP time; The third PTP module is located in each of the application virtual machines and is used for the application virtual machine to obtain the PTP time from the Hypervisor through hyper_call and synchronize with it.

9. A computing device, characterized in that include, bus; a communication interface connected to the bus; at least one processor connected to the bus; as well as At least one memory is connected to the bus and stores program instructions, and when the program instructions are executed by the at least one processor, the at least one processor executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that Program instructions are stored thereon, and when the program instructions are executed by a computer, the computer is caused to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Time synchronization method and device of virtual machine

    CN110502310A

  • Method and system for time synchronization of virtualization platform

    CN113691342A

  • Virtual precision time protocol clock device for virtual nodes

    CN116996151A

  • Network Packet Timing Synchronization For Virtual Machine Host Systems

    US20160112182A1