IO device sharing method and device
By implementing the use of sockets and virtual IO processing units between physical machines, the problem of poor universality of IO device sharing method in the prior art is solved, and sharing of IO devices across different open source systems is realized.
Patent Information
- Application Number
- CN202411456918.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-10-18
AI Technical Summary
The existing IO device sharing method can only realize IO device sharing between physical machines based on specific open source systems, and is less versatile.
By controlling the front-end driver in the kernel space of the first physical machine, the written first control data is sent via a socket to the virtual IO processing unit in the kernel space of the second physical machine, and then the data is sent to the virtual device driver and finally sent to the real device driver to control the IO device on the second physical machine.
It realizes IO device sharing between physical machines without being limited to a specific open source system, improving the universality of IO device sharing.
Smart Images

Figure CN119003391B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of IO device sharing, and in particular to an IO device sharing method and apparatus. Background Art
[0002] Currently, there are two main ways for physical machines to use external IO devices. The first is to connect external devices through the physical machine's interface, such as connecting external cameras, keyboards, mice and other devices through the physical machine's USB interface, or using the physical machine's Thunderbolt interface to connect to an external graphics card dock; the second is to enhance the virtualization capabilities of distributed devices through specific open source distributed subsystems to abstract the screens, cameras, speakers, keyboards, sensors, storage and other devices of multiple physical machines to form the same device resource pool within the "super virtual terminal", and support on-demand allocation and recombination of device resources to achieve global call of device resources.
[0003] Among them, the first method is only applicable to pluggable devices supported by the current physical machine system, and cannot use the integrated IO devices on another physical machine; although the second method can realize IO device sharing between two physical machines, it requires that both physical machines have installed or transplanted the specific open source distributed subsystem. In summary, the existing IO device sharing method can only realize IO device sharing between physical machines based on a specific open source system, and has poor versatility. Summary of the invention
[0004] The embodiments of the present application provide an IO device sharing method and apparatus to solve the technical problem that the existing IO device sharing method can only realize IO device sharing between physical machines based on a specific open source system and has poor versatility.
[0005] In a first aspect, an embodiment of the present application provides an IO device sharing method, comprising:
[0006] Controlling a front-end driver in a kernel space of a first physical machine, and sending first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket;
[0007] Controlling the virtual IO processing unit to send the first control data to a virtual device driver in the kernel space of the second physical machine;
[0008] The virtual device driver is controlled to send the first control data to a real device driver in the kernel space of the second physical machine, so as to control the IO device on the second physical machine.
[0009] In one embodiment, controlling the virtual device driver to send the first control data to a real device driver in the kernel space of the second physical machine includes:
[0010] Control the virtual device driver to wake up the newly added virtual IO module;
[0011] The virtual IO module is controlled to send the first control data to the real device driver.
[0012] In one embodiment, after controlling the IO device on the second physical machine, the method includes:
[0013] The virtual IO module is controlled to send the second control data written into the second physical machine to the first physical machine through the Thunderbolt interface, so as to control the IO device on the first physical machine.
[0014] In one embodiment, the controlling the front-end driver in the kernel space of the first physical machine, before sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket, includes:
[0015] Controlling the backend driver in the user space of the second physical machine to register a target event file descriptor with the virtual IO module and the virtual device driver via a virtual host agent in the user space of the second physical machine; the target event file descriptor includes an IO event file descriptor and an interrupt event file descriptor;
[0016] Associating the IO event file descriptor with the IO operation address of the first physical machine;
[0017] The interrupt event file descriptor is associated with a global interrupt signal.
[0018] In one embodiment, controlling the virtual device driver to wake up the newly added virtual IO module includes:
[0019] If the first control data is written into the IO operation address, a kick signal is sent to the virtual IO module through the IO event file descriptor in the virtual device driver to wake up the virtual IO module.
[0020] In one embodiment, after controlling the virtual IO module to send the first control data to the real device driver, the method includes:
[0021] A notify signal is sent to the virtual device driver through the interrupt event file descriptor in the virtual IO module to inject an interrupt signal into the first physical machine.
[0022] In one embodiment, sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via a socket includes:
[0023] Sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the target network path;
[0024] The target network path is a network path from the socket on the first physical machine side to the Thunderbolt interface, and then from the Thunderbolt interface to the socket on the second physical machine side.
[0025] In a second aspect, an embodiment of the present application provides an IO device sharing device, comprising:
[0026] The inter-physical machine transmission module is used to: control the front-end driver in the kernel space of the first physical machine, and send the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket;
[0027] The transmission module in the physical machine is used to: control the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine;
[0028] The first IO device control module is used to control the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine.
[0029] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein when the processor executes the program, the steps of the IO device sharing method described in the first aspect are implemented.
[0030] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the IO device sharing method described in the first aspect.
[0031] The IO device sharing method and device provided by the present application controls the front-end driver in the kernel space of the first physical machine, sends the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via a socket, controls the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine, and controls the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine. The present application regards the first physical machine as a virtual machine of the second physical machine, and implements the application of paravirtualization technology based on the front-end driver, virtual IO processing unit, virtual device driver, etc., so that the first physical device can use the first control data to control the IO device on the second physical machine. In summary, the present application can realize IO device sharing between physical machines without being limited to a specific open source system, and improve the versatility of IO device sharing. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 This is one of the flow charts of the IO device sharing method provided in the embodiment of the present application;
[0034] Figure 2 It is a schematic diagram of the existing virtual machine technology process;
[0035] Figure 3 This is the second flow chart of the IO device sharing method provided in the embodiment of the present application;
[0036] Figure 4 This is the third flow chart of the IO device sharing method provided in the embodiment of the present application;
[0037] Figure 5 This is the fourth flow chart of the IO device sharing method provided in the embodiment of the present application;
[0038] Figure 6 is a structural diagram of an IO device sharing device provided in an embodiment of the present application;
[0039] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0041] It should be noted that in the description of the embodiments of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those skilled in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0042] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0043] Figure 1 This is one of the flow charts of the IO device sharing method provided in the embodiment of the present application;
[0044] Figure 2 It is a schematic diagram of the existing virtual machine technology process;
[0045] Figure 3 This is the second flow chart of the IO device sharing method provided in the embodiment of the present application;
[0046] Figure 4 This is the third flow chart of the IO device sharing method provided in the embodiment of the present application.
[0047] Reference Figure 1 , Figure 3 to Figure 4 , the embodiment of the present application provides an IO device sharing method, which may include:
[0048] 101. Control a front-end driver in a kernel space of a first physical machine, and send first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket;
[0049] 102. Control the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine;
[0050] 103. Control the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine.
[0051] Reference Figure 2 ,In the traditional virtual machine solution, the communication between the virtual machine and the host ,machine needs to be carried out through a fast simulator in the user space of the ,host machine, which involves context switching between the kernel space and ,user space, which will bring additional performance overhead.
[0052] In this embodiment, a semi-virtualization technology such as virtual IO is adopted. The virtual host in the second physical machine is a specific virtual IO, and its data layer is placed in the kernel space of the second physical machine. By moving the data layer originally in the user space of the second physical machine to the kernel space of the second physical machine, the first physical machine is allowed to communicate directly with the virtual host in the kernel space of the second physical machine, avoiding communication through a fast simulator in the user space when adopting a traditional virtual machine solution, reducing the context switching between the user space and the kernel space when processing IO requests, and significantly improving the efficiency of IO operations.
[0053] The IO device sharing method provided in this embodiment controls the front-end driver in the kernel space of the first physical machine, sends the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via a socket, controls the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine, and controls the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine. This embodiment regards the first physical machine as a virtual machine of the second physical machine, and implements the application of semi-virtualization technology based on the front-end driver, virtual IO processing unit, virtual device driver, etc., so that the first physical device can use the first control data to control the IO device on the second physical machine. In summary, the present application can realize IO device sharing between physical machines without being limited to a specific open source system, and improve the versatility of IO device sharing.
[0054] Reference Figures 2 to 4 In one embodiment, controlling the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine may include:
[0055] The virtual device driver is controlled to wake up the newly added virtual IO module, and the virtual IO module is controlled to send the first control data to the real device driver.
[0056] Figure 3 and Figure 4 In Figure 2 The fast simulator in the user space of the host machine is replaced by the virtual IO processing unit, virtual device driver and virtual IO module in the kernel space of the second physical machine. The first control data is sent to the virtual IO module by using the virtual IO processing unit and the virtual device driver. The virtual IO module is then used to implement the function of the fast simulator and send the first control data to the real device driver. The second physical machine is regarded as the host machine and the first physical machine is regarded as the virtual machine by using the paravirtualization technology. The communication between the physical machines is converted into the conventional communication between the host machine and the virtual machine, so as to realize the IO device sharing between the physical machines.
[0057] This embodiment applies virtual machine technology to physical machines, and replaces the original fast simulator with a virtual IO module, which can realize IO device sharing between physical machines by maximizing the use of paravirtual technology codes combined with a small amount of modification.
[0058] Reference Figures 2 to 4 In one embodiment, after controlling the IO device on the second physical machine, the method may include:
[0059] The control virtual IO module sends the second control data written in the second physical machine to the first physical machine through the Thunderbolt interface to control the IO device on the first physical machine.
[0060] In addition, sending the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket may include:
[0061] Sending the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the target network path;
[0062] The target network path is a network path from the socket on the first physical machine side to the Thunderbolt interface, and then from the Thunderbolt interface to the socket on the second physical machine side.
[0063] Figure 3 and Figure 4 The Thunderbolt interface is a high-speed data transmission and connection technology that can transmit data and video signals at the same time and is compatible with USB technology. Figure 2 The IO ring in the system realizes data transmission between physical machines.
[0064] In addition, the sockets on the first physical machine side and the second physical machine side are used to translate the control data. On the one hand, the sockets cooperate with the Thunderbolt interface to convert the virtual IO data stream into a network transmission data stream, thereby enabling data communication between physical machines. On the other hand, the sockets cooperate with the virtual IO module to realize the application of paravirtualization technology in non-virtual machine scenarios.
[0065] In this embodiment, the first physical machine sends control data to the second physical machine through the socket and Thunderbolt interface in a network transmission manner, and controls the IO devices on the second physical machine based on the semi-virtualization technology, thereby sharing the IO devices of the second physical machine; in addition, under specific demand scenarios, the same configuration as the second physical machine can also be set on the first physical machine, and the second physical machine can directly send control data to the first physical machine through the same Thunderbolt interface to control the IO devices on the first physical machine, thereby reversely sharing the IO devices of the first physical machine.
[0066] Figure 5 This is a fourth flow chart of the IO device sharing method provided in the embodiment of the present application; Figures 3 to 5 In one embodiment, controlling the front-end driver in the kernel space of the first physical machine and sending the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket may include:
[0067] 501. Control the backend driver in the user space of the second physical machine to register a target event file descriptor with the virtual IO module and the virtual device driver via the virtual host agent in the user space of the second physical machine;
[0068] The target event file descriptor includes an IO event file descriptor and an interrupt event file descriptor;
[0069] 502. Associating the IO event file descriptor with the IO operation address of the first physical machine;
[0070] 503. Associate the interrupt event file descriptor with the global interrupt signal.
[0071] Reference Figure 4 , where the solid line represents data transmission at the data layer, and the dotted line represents data transmission at the control layer:
[0072] In step 502, if the first control data is written to the IO operation address, a kick signal is sent to the virtual IO module through the IO event file descriptor in the virtual device driver, so as to realize the IO operation request notification of the front-end first physical machine to the back-end second physical machine, so as to wake up the virtual IO module, thereby controlling the virtual IO module to send the first control data to the real device driver to control the IO device on the second physical machine.
[0073] In step 503, after controlling the virtual IO module to send the first control data to the real device driver, a notify signal can also be sent to the virtual device driver through the interrupt event file descriptor in the virtual IO module to inject the interrupt signal into the first physical machine, thereby realizing the completion notification of the IO operation of the second physical machine at the back end to the first physical machine at the front end.
[0074] It should be noted that the virtual IO module and the virtual device driver need to maintain their internal target event file descriptors so that the target event file descriptors can play a better role.
[0075] In practical applications, there is no strict timing relationship between step 502 and step 503; that is, they can be executed simultaneously, or any one of the steps can be executed first, depending on actual needs and is not limited here.
[0076] In this embodiment, the IO operation address and the global interrupt signal are respectively associated with the IO event file descriptor and the interrupt event file descriptor, and the kick signal and the notify signal are used to notify the event between the front-end and the back-end, so that the back-end can promptly discover the front-end IO operation request event, and the front-end can promptly discover the back-end IO operation completion event, thereby ensuring that the first physical machine and the second physical machine are aware of each other's working status and ensuring the smooth execution of the IO operation between the first physical machine and the second physical machine.
[0077] The IO device sharing apparatus provided in an embodiment of the present application is described below. The IO device sharing apparatus described below and the IO device sharing method described above can be referenced to each other.
[0078] Figure 6 Schematic diagram of the structure of the IO device sharing device provided in the embodiment of the present application. Figure 6 , an embodiment of the present application provides an IO device sharing device, which may include:
[0079] The inter-physical machine transmission module 601 is used to: control the front-end driver in the kernel space of the first physical machine, and send the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket;
[0080] The physical machine internal transmission module 602 is used to: control the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine;
[0081] The first IO device control module 603 is used to control the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine.
[0082] The IO device sharing device provided in this embodiment controls the front-end driver in the kernel space of the first physical machine, sends the first control data written to the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket, controls the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine, and controls the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine. This embodiment regards the first physical machine as a virtual machine of the second physical machine, and implements the application of semi-virtualization technology based on the front-end driver, the virtual IO processing unit, the virtual device driver, etc., so that the first physical device can use the first control data to control the IO device on the second physical machine. In summary, the present application can realize IO device sharing between physical machines without being limited to a specific open source system, and improve the versatility of IO device sharing.
[0083] In one embodiment, the first IO device control module 603 is specifically configured to:
[0084] Control the virtual device driver to wake up the newly added virtual IO module;
[0085] The virtual IO module is controlled to send the first control data to the real device driver.
[0086] In one embodiment, a second IO device control module (not shown in the figure) is further included, which is used to:
[0087] The virtual IO module is controlled to send the second control data written into the second physical machine to the first physical machine through the Thunderbolt interface, so as to control the IO device on the first physical machine.
[0088] In one embodiment, the descriptor registration association module (not shown in the figure) is used to:
[0089] Controlling the backend driver in the user space of the second physical machine to register a target event file descriptor with the virtual IO module and the virtual device driver via a virtual host agent in the user space of the second physical machine; the target event file descriptor includes an IO event file descriptor and an interrupt event file descriptor;
[0090] Associating the IO event file descriptor with the IO operation address of the first physical machine;
[0091] The interrupt event file descriptor is associated with a global interrupt signal.
[0092] In one embodiment, the first IO device control module 603 is specifically configured to:
[0093] If the first control data is written into the IO operation address, a kick signal is sent to the virtual IO module through the IO event file descriptor in the virtual device driver to wake up the virtual IO module.
[0094] In one embodiment, the interrupt signal injection module (not shown in the figure) is used to:
[0095] A notify signal is sent to the virtual device driver through the interrupt event file descriptor in the virtual IO module to inject an interrupt signal into the first physical machine.
[0096] In one embodiment, the physical machine transmission module 601 is specifically used for:
[0097] Sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the target network path;
[0098] The target network path is a network path from the socket on the first physical machine side to the Thunderbolt interface, and then from the Thunderbolt interface to the socket on the second physical machine side.
[0099] Figure 7 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call a computer program in the memory 730 to execute the steps of the IO device sharing method, for example including:
[0100] Controlling a front-end driver in a kernel space of a first physical machine, and sending first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket;
[0101] Controlling the virtual IO processing unit to send the first control data to a virtual device driver in the kernel space of the second physical machine;
[0102] The virtual device driver is controlled to send the first control data to a real device driver in the kernel space of the second physical machine, so as to control the IO device on the second physical machine.
[0103] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0104] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product including a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the IO device sharing method provided in the above embodiments, for example, including:
[0105] Controlling a front-end driver in a kernel space of a first physical machine, and sending first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket;
[0106] Controlling the virtual IO processing unit to send the first control data to a virtual device driver in the kernel space of the second physical machine;
[0107] The virtual device driver is controlled to send the first control data to a real device driver in the kernel space of the second physical machine, so as to control the IO device on the second physical machine.
[0108] On the other hand, an embodiment of the present application further provides a non-transitory computer-readable storage medium on which a computer program is stored, wherein the computer program is used to enable a processor to execute the steps of the IO device sharing method provided in the above embodiments, for example, including:
[0109] Controlling a front-end driver in a kernel space of a first physical machine, and sending first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket;
[0110] Controlling the virtual IO processing unit to send the first control data to a virtual device driver in the kernel space of the second physical machine;
[0111] The virtual device driver is controlled to send the first control data to a real device driver in the kernel space of the second physical machine, so as to control the IO device on the second physical machine.
[0112] The non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0113] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for sharing IO devices, characterized in that: include: Controlling a front-end driver in a kernel space of a first physical machine, and sending first control data written into the front-end driver to a virtual IO processing unit in a kernel space of a second physical machine via a socket; Controlling the virtual IO processing unit to send the first control data to a virtual device driver in the kernel space of the second physical machine; Controlling the virtual device driver to send the first control data to a real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine; The controlling the virtual device driver to send the first control data to a real device driver in the kernel space of the second physical machine includes: Control the virtual device driver to wake up the newly added virtual IO module; Controlling the virtual IO module to send the first control data to the real device driver; After the controlling of the IO device on the second physical machine, the method further comprises: Control the virtual IO module to send the second control data written in the second physical machine to the first physical machine through the Thunderbolt interface, so as to control the IO device on the first physical machine; The controlling of the front-end driver in the kernel space of the first physical machine, before sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket, comprises: Controlling the backend driver in the user space of the second physical machine to register a target event file descriptor with the virtual IO module and the virtual device driver via a virtual host agent in the user space of the second physical machine; the target event file descriptor includes an IO event file descriptor and an interrupt event file descriptor; Associating the IO event file descriptor with the IO operation address of the first physical machine; Associating the interrupt event file descriptor with a global interrupt signal; The step of sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via a socket includes: Sending the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the target network path; The target network path is a network path from the socket on the first physical machine side to the Thunderbolt interface, and then from the Thunderbolt interface to the socket on the second physical machine side.
2. The IO device sharing method according to claim 1, characterized in that: The controlling the virtual device driver to wake up the newly added virtual IO module includes: If the first control data is written into the IO operation address, a kick signal is sent to the virtual IO module through the IO event file descriptor in the virtual device driver to wake up the virtual IO module.
3. The IO device sharing method according to claim 1, characterized in that: After the controlling the virtual IO module to send the first control data to the real device driver, the method includes: A notify signal is sent to the virtual device driver through the interrupt event file descriptor in the virtual IO module to inject an interrupt signal into the first physical machine.
4. An IO device sharing device, characterized in that: The method for implementing the IO device sharing method according to any one of claims 1 to 3 comprises: The inter-physical machine transmission module is used to: control the front-end driver in the kernel space of the first physical machine, and send the first control data written into the front-end driver to the virtual IO processing unit in the kernel space of the second physical machine via the socket; The transmission module in the physical machine is used to: control the virtual IO processing unit to send the first control data to the virtual device driver in the kernel space of the second physical machine; The first IO device control module is used to control the virtual device driver to send the first control data to the real device driver in the kernel space of the second physical machine to control the IO device on the second physical machine.
5. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the IO device sharing method according to any one of claims 1 to 3 are implemented.
6. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the IO device sharing method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Methods and performance service framework for building virtual machine monitors using a bus architecture
CN102262557A
Method, equipment and system of data operation
CN106844008A