Pin multiplexing method, device and equipment of multi-virtual machine system and storage medium
By checking and negotiating the usage period of GPIO pins in a multi-virtual machine system, the requirement for GPIO pin multiplexing in a multi-virtual machine system is solved, thereby saving hardware costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ECARX (HUBEI) TECHCO LTD
- Filing Date
- 2024-06-28
- Publication Date
- 2026-06-19
AI Technical Summary
In multi-virtual machine systems, how to efficiently reuse GPIO pins to save hardware costs has become a focus for developers, and existing technologies have failed to effectively solve the pin reuse requirement.
The system checks whether other guest virtual machines are using the shared GPIO pin. It then notifies the guest virtual machine using the application to stop using the pin, releasing the shared pin so that the current guest virtual machine can use it.
It enables the reuse of shared GPIO pins across different guest virtual machines, meeting the requirements for reuse of physical GPIO pins and saving hardware costs.
Smart Images

Figure CN118708295B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtual machine technology, and in particular to a pin multiplexing method, apparatus, device and storage medium for a multi-virtual machine system. Background Technology
[0002] Virtualization technology has revolutionized the automotive electronics ecosystem by enabling resource sharing and secure isolation. Hardware resources such as CPUs, memory, GPUs, and input / output devices can all be shared through virtualization.
[0003] A virtualization architecture typically includes a host virtual machine operating system and several guest virtual machine operating systems. These operating systems run on the same hardware devices, and device virtualization technology enables each virtual operating system to share access to actual hardware resources such as GPUs and input / output devices through virtualized hardware.
[0004] Some input / output device resources, such as general-purpose input / output (GPIO), are typically managed by a single controller, with multiple pins managed by one controller. If efficient sharing among multiple virtual operating systems is required, such as multiple virtual machines using different pins under the same controller, device virtualization is necessary. However, due to the increasing use cases for pins, the need for pin reuse inevitably arises to save hardware costs. Therefore, pin reuse has become a key focus for developers. Summary of the Invention
[0005] This application provides a pin reuse method, apparatus, device, and storage medium for multi-virtual machine systems, which provides a solution for how to reuse pins in response to the increasing demand for pin usage scenarios in the prior art.
[0006] In a first aspect, this application provides a pin multiplexing method for a multi-virtual machine system, wherein the multi-virtual machine system includes a host virtual machine and several guest virtual machines, the several guest virtual machines using the same GPIO pin component, the GPIO pin component including multiple physical GPIO pins; the method includes:
[0007] When a request is received that the current guest virtual machine needs to use a shared pin, the current guest virtual machine checks whether other guest virtual machines occupy the shared pin. The shared pin is at least one of the same physical GPIO pins configured for use by the current guest virtual machine and other guest virtual machines.
[0008] If so, the application notifies the guest virtual machine occupying the shared pin to suspend its use of the shared pin through the current guest virtual machine's on / off switch;
[0009] The shared pin is released by the switch application of the guest virtual machine that occupies the shared pin, allowing the current guest virtual machine to use the shared pin.
[0010] In one possible design, the step of checking whether other guest virtual machines are occupying the shared pin by the current guest virtual machine includes:
[0011] The output level of the shared pin is obtained through the switch application of the current guest virtual machine;
[0012] Check whether any other guest virtual machine is occupying the shared pin based on the output level of the shared pin.
[0013] In one possible design, checking whether another guest virtual machine is occupying the shared pin based on the output level of the shared pin includes:
[0014] Determine whether the output level of the shared pin is consistent with the preset level, where the preset level is the level value when the shared pin is in output mode;
[0015] If so, it is determined that the shared pin is occupied by the other guest virtual machine.
[0016] In one possible design, the notification sent via the current guest virtual machine's on / off application to the guest virtual machine occupying the shared pin to suspend its use of the shared pin includes:
[0017] The application notifies the guest virtual machine occupying the shared pin to close the GPIO device file of the shared pin by the current guest virtual machine's switch.
[0018] In one possible design, releasing the shared pin via the switch application of the guest virtual machine occupying the shared pin includes:
[0019] The switch application of the guest virtual machine that occupies the shared pin notifies the pin application to release the shared pin.
[0020] In one possible design, the current guest virtual machine's switch application and the guest virtual machine's switch application occupying the shared pin are connected via inter-domain communication.
[0021] In one possible design, the plurality of guest virtual machines load the front-end virtual pin driver deployed on the plurality of guest virtual machines through a standard paravirtualization driver, and use the GPIO pin component based on the back-end virtual pin driver deployed on the master virtual machine corresponding to the front-end virtual pin, and each back-end virtual pin has a corresponding relationship with the physical real GPIO pin.
[0022] Secondly, this application provides a pin multiplexing device for a multi-virtual machine system, wherein the multi-virtual machine system includes a host virtual machine and several guest virtual machines, the several guest virtual machines using the same GPIO pin component, the GPIO pin component including multiple physical GPIO pins; the device includes:
[0023] The pin checking module is used to check whether other guest virtual machines occupy the shared pin when the current guest virtual machine needs to use the shared pin. The shared pin is at least one physical GPIO pin that is configured for use by the current guest virtual machine and other guest virtual machines.
[0024] The notification module is used to notify the guest virtual machine occupying the shared pin to suspend its use of the shared pin by means of the on / off application of the current guest virtual machine if it is determined that the other guest virtual machine occupies the shared pin.
[0025] The reuse module is used to release the shared pin by the switch application of the guest virtual machine that occupies the shared pin, so that the current guest virtual machine can use the shared pin.
[0026] In one possible design, the pin inspection module is specifically used for:
[0027] The output level of the shared pin is obtained through the switch application of the current guest virtual machine;
[0028] Check whether any other guest virtual machine is occupying the shared pin based on the output level of the shared pin.
[0029] In one possible design, the pin inspection module is further used for:
[0030] Determine whether the output level of the shared pin is consistent with the preset level, where the preset level is the level value when the shared pin is in output mode;
[0031] If so, it is determined that the shared pin is occupied by the other guest virtual machine.
[0032] In one possible design, the notification module is specifically used for:
[0033] The application notifies the guest virtual machine occupying the shared pin to close the GPIO device file of the shared pin by the current guest virtual machine's switch.
[0034] In one possible design, the reuse module is specifically used for:
[0035] The switch application of the guest virtual machine that occupies the shared pin notifies the pin application to release the shared pin.
[0036] In one possible design, the current guest virtual machine's switch application and the guest virtual machine's switch application occupying the shared pin are connected via inter-domain communication.
[0037] In one possible design, the plurality of guest virtual machines load the front-end virtual pin driver deployed on the plurality of guest virtual machines through a standard paravirtualization driver, and use the GPIO pin component by calling the back-end virtual pin based on the back-end virtual pin driver through the back-end virtual pin deployed on the master virtual machine corresponding to the front-end virtual pin, and each back-end virtual pin has a corresponding relationship with the physical real GPIO pin.
[0038] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0039] The memory stores computer-executed instructions;
[0040] The processor executes computer execution instructions stored in the memory to implement any of the possible pin multiplexing methods for multi-virtual machine systems provided in the first aspect.
[0041] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement any of the possible pin multiplexing methods for a multi-virtual machine system provided in the first aspect.
[0042] Fifthly, this application provides a computer program product including computer execution instructions, which, when executed by a processor, are used to implement any of the possible pin multiplexing methods for multi-virtual machine systems provided in the first aspect.
[0043] This application provides a pin multiplexing method, apparatus, device, and storage medium for a multi-virtual machine system. The multi-virtual machine system includes a host virtual machine and several guest virtual machines. The guest virtual machines use the same GPIO pin component, which includes multiple physical GPIO pins. When a request is received from the current guest virtual machine to use a shared pin, the system checks whether other guest virtual machines are occupying the shared pin. The shared pin is at least one physical GPIO pin that is the same as the one configured for use by the current guest virtual machine and other guest virtual machines. If so, the system notifies the guest virtual machine occupying the shared pin to suspend its use of the shared pin through the current guest virtual machine's on / off application. Then, the system releases the shared pin through the on / off application of the guest virtual machine occupying the shared pin, allowing the current guest virtual machine to use the shared pin. First, it is determined whether the shared pin is occupied by another guest virtual machine. If it is occupied, the application notifies the guest virtual machine occupying the shared pin through the current guest virtual machine's on / off switch, so that the guest virtual machine occupying the shared pin stops using the shared pin to release it. The current guest virtual machine then uses the shared pin, realizing the reuse of the shared pin among different guest virtual machines. This meets the requirements for the reuse of physical real GPIO pins, allowing multiple guest virtual machines to reuse more resources in scenarios where they share pins, thus saving hardware costs. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a schematic diagram of the architecture of a multi-virtual machine system provided in an embodiment of this application;
[0046] Figure 2 A flowchart illustrating a pin multiplexing method for a multi-virtual machine system provided in this application embodiment;
[0047] Figure 3 A flowchart illustrating another pin multiplexing method for a multi-virtual machine system provided for the examples in this application;
[0048] Figure 4 A schematic diagram of a pin multiplexing device for a multi-virtual machine system provided in this application embodiment;
[0049] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0050] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of methods and apparatus consistent with some aspects of this application as detailed in the appended claims.
[0051] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] Some input / output device resources, such as general-purpose input / output (GPIO), are typically managed by a single controller, with multiple pins managed by one controller. If efficient sharing among multiple virtual operating systems is required, such as multiple virtual machines using different pins under the same controller, device virtualization is necessary. However, due to the increasing use cases for pins, the need for pin reuse inevitably arises to save hardware costs. Therefore, pin reuse has become a key focus for developers.
[0053] To address the aforementioned problems in the prior art, this application provides a pin multiplexing method, apparatus, device, and storage medium for a multi-virtual machine system. The inventive concept of the pin multiplexing method for a multi-virtual machine system provided in this application is as follows: several guest virtual machines in a multi-virtual machine system use the same GPIO pin component, which includes multiple physical GPIO pins. First, when the multi-virtual machine system receives a request from a guest virtual machine (the current guest virtual machine) to use a shared pin, the current guest virtual machine checks whether another guest virtual machine is occupying the shared pin. If it is, the current guest virtual machine's switching application notifies the other guest virtual machine occupying the shared pin to suspend its use of the shared pin. The switching application of the guest virtual machine occupying the shared pin then releases the shared pin, and the current guest virtual machine uses the shared pin. Therefore, through the interaction between switching applications in the guest virtual machines, the shared pin can be multiplexed among different guest virtual machines, meeting the requirement for physical pin multiplexing. This allows multiple guest virtual machines to reuse more resources in scenarios where pins are shared, saving hardware costs.
[0054] Figure 1 This is a schematic diagram of the architecture of a multi-virtual machine system provided in an embodiment of this application, such as... Figure 1 As shown, the multi-virtual machine system includes a host virtual machine 101 and several guest virtual machines, which can be, for example... Figure 1 The first virtual machine 102, the second virtual machine 103, etc., are shown in the illustration. However, the number of virtual machines is not limited in this embodiment.
[0055] Furthermore, several guest virtual machines use a unified GPIO pin component 104. This GPIO pin component includes multiple physical GPIO pins, such as... Figure 1 GPIO 0, GPIO 1, and GPIO x, etc.
[0056] Reference Figure 1 As shown, several guest virtual machines, such as the first virtual machine 102 and the second virtual machine 103, each can have its own front-end virtual pin driver loaded via a standard paravirtualization driver (virtio GPIO driver). Each guest virtual machine has its own front-end virtual pins deployed, such as front-end virtual pin 1021 in the first virtual machine 102 and front-end virtual pin 1031 in the second virtual machine 103. Furthermore, the back-end virtual pins deployed on the master virtual machine 101, corresponding to the front-end virtual pins, can call the GPIO pin component 104 based on the back-end pin driver to use the corresponding physical real GPIO pins in the GPIO pin component 104.
[0057] For example Figure 1As shown, the backend virtual pins deployed in the main virtual machine 101 corresponding to the frontend virtual pins can be, for example... Figure 1 The backend virtual pins 1011, 1012, etc., have a corresponding relationship between the frontend virtual pins and the backend virtual pins, such as... Figure 1 In this configuration, front-end virtual pin 1021 corresponds to back-end virtual pin 1011, front-end virtual pin 1031 corresponds to back-end virtual pin 1012, and so on. Furthermore, the back-end virtual pin can call the GPIO pin component 104 based on the back-end pin driver 1010 to use the corresponding physical real GPIO pin in the GPIO pin component 104.
[0058] Each backend virtual pin corresponds to a physical real GPIO pin in the GPIO pin component 104. For example Figure 1 The back-end virtual pins and GPIO pin component 104 have a corresponding relationship. The front-end virtual pins of different guest virtual machines, based on the back-end pin drivers of the host virtual machine, correspond to at least one physical real GPIO pin, which is the shared pin described in this embodiment. For example... Figure 1 As shown, the shared pin corresponding to the first virtual machine 102 and the second virtual machine 103 is GPIO 0. GPIO 0 is the same physical GPIO pin used by the first virtual machine 102 and the second virtual machine 103. It is understood that the correspondence between the backend virtual pins and the physical GPIO pins can be configured according to the actual working conditions, and this embodiment of the application does not limit this.
[0059] In addition, the architecture of the multi-virtual machine system provided in this application embodiment also includes a Hypervisor, which is used to build the virtualization architecture between the multi-virtual machine system and the GPIO pin component 104.
[0060] As described above, provided that each guest virtual machine can use a standard paravirtualization driver, the same physical real GPIO pin corresponding to the backend virtual pin can be simultaneously passed to two or more guest virtual machines. Regarding the output mode of the physical real GPIO pin, the upper layer application can negotiate the usage time of the shared pin through the switch application in the guest virtual machine, so as to realize the reuse of the shared pin among different guest virtual machines.
[0061] In some embodiments, each physical GPIO pin can be connected to the host virtual machine 101 via a data pass-through channel. Each guest virtual machine can be configured with its own userspace switch application, and these userspace switch applications can be connected via inter-domain communication, ensuring that only one guest virtual machine uses the shared pin at a time.
[0062] It should be noted that the number of guest virtual machines, front-end virtual pins, back-end virtual pins, and physical GPIO pins in the above architecture diagram is determined by the actual operating conditions. Figure 1 The examples shown are merely illustrative.
[0063] The above system architecture is merely illustrative. The pin multiplexing method, apparatus, device, and storage medium for multi-virtual machine systems provided in this application include, but are not limited to, the above system architecture.
[0064] Figure 2 A flowchart illustrating a pin multiplexing method for a multi-virtual machine system provided in this application embodiment is shown below. Figure 2 As shown in the embodiments of this application, the pin multiplexing method for a multi-virtual machine system includes:
[0065] S101: When a request is received that the current guest virtual machine needs to use a shared pin, check whether other guest virtual machines are occupying the shared pin through the current guest virtual machine.
[0066] As described in the foregoing embodiments, a shared pin is at least one identical physical GPIO pin configured for use by the current guest virtual machine and other guest virtual machines. Here, "current guest virtual machine" is a general term for guest virtual machines that currently need to use the physical GPIO pin. The current guest virtual machine can be... Figure 1 The first guest virtual machine, the second guest virtual machine, or other guest virtual machines in the system. For example... Figure 1 In this context, if the current guest virtual machine is the first guest virtual machine, then the other guest virtual machines are guest virtual machines that correspond to GPIO 0, including the second virtual machine.
[0067] When a guest virtual machine wants to use a shared pin for output to perform business operations, it sends a request to the host virtual machine to use the shared pin. When the host virtual machine receives the request from the guest virtual machine, it checks whether the shared pin is occupied by another guest virtual machine. If the check determines that the shared pin is occupied by another guest virtual machine, step S102 is executed; otherwise, if the shared pin is not occupied, step S104 is executed.
[0068] S102: The application notifies the guest virtual machine that is using the shared pin to suspend the use of the shared pin by the current guest virtual machine's on / off switch.
[0069] If the host virtual machine determines that a shared pin is being used by another guest virtual machine (e.g., the second guest virtual machine), it will notify the guest virtual machine using the host virtual machine's on / off application to suspend the use of the shared pin. For example, if the host virtual machine is the first guest virtual machine and the guest virtual machine using the second guest virtual machine is the first guest virtual machine's on / off application to notify the second guest virtual machine to suspend the use of the shared pin.
[0070] S103: Release the shared pin by the switch application of the guest virtual machine that occupies the shared pin, so that the current guest virtual machine can use the shared pin.
[0071] After the guest virtual machine occupying the shared pin is notified to suspend the use of the shared pin, the master virtual machine releases the shared pin through the switch application of the guest virtual machine occupying the shared pin, thereby enabling the current guest virtual machine that needs to use the shared pin to use the shared pin, realizing the reuse of the shared pin between the current guest virtual machine and the guest virtual machine occupying the shared pin.
[0072] S104: The current guest virtual machine uses a shared pin.
[0073] If it is determined through the current guest virtual machine that the shared pin is not occupied by other guest virtual machines, the current guest virtual machine can directly use the shared pin to output and carry out business.
[0074] This application provides a pin multiplexing method for a multi-virtual machine system. The multi-virtual machine system includes a master virtual machine and several guest virtual machines. The guest virtual machines use the same GPIO pin component, which includes multiple physical GPIO pins. When a request is received from the current guest virtual machine to use a shared pin, the system checks whether other guest virtual machines are occupying the shared pin. The shared pin is at least one physical GPIO pin that is configured for use by the current guest virtual machine and other guest virtual machines. If so, the system notifies the guest virtual machine occupying the shared pin to suspend its use of the shared pin through the current guest virtual machine's on / off application. Then, the system releases the shared pin through the on / off application of the guest virtual machine occupying the shared pin, allowing the current guest virtual machine to use the shared pin. First, it is determined whether the shared pin is occupied. If it is occupied, the application notifies the guest virtual machine occupying the shared pin through the current guest virtual machine's on / off switch, so that the guest virtual machine occupying the shared pin stops using the shared pin to release the shared pin. The current guest virtual machine then uses the shared pin, realizing the reuse of the shared pin among different guest virtual machines. This meets the physical real GPIO pin reuse requirements, allowing multiple guest virtual machines to reuse more resources in scenarios where the pin is shared, thus saving hardware costs.
[0075] Figure 3 A flowchart illustrating another pin multiplexing method for a multi-virtual machine system provided in this application example is shown below. Figure 3 As shown in the embodiments of this application, the pin multiplexing method for a multi-virtual machine system includes:
[0076] S201: When a request is received that the current guest virtual machine needs to use a shared pin, the output level of the shared pin is obtained through the switch application of the current guest virtual machine.
[0077] S202: Check if any other guest virtual machine is occupying the shared pin based on the output level of the shared pin.
[0078] When the host virtual machine receives a request from the current guest virtual machine to use a shared pin, it obtains the output level of the shared pin through a switch application running in the current guest virtual machine. It then uses this output level to determine whether the shared pin is being used by another guest virtual machine. The switch application running in the current guest virtual machine is used to allow the current guest virtual machine to use or release the shared pin.
[0079] In some embodiments, a possible implementation of checking whether another guest virtual machine is occupying the shared pin by reading the shared pin output level may include:
[0080] The output level of the shared pin is compared with a preset level to determine if they match. If they match, the pin is occupied, and the identifier of the guest virtual machine occupying the pin can be obtained. Otherwise, if they do not match, the shared pin is not occupied. The identifier is used to identify the guest virtual machine occupying the pin, facilitating interaction with it.
[0081] In some embodiments, the preset level can be the corresponding level value when the shared pin is output, and the specific setting can be set according to the actual working conditions. This application embodiment does not limit this.
[0082] As can be seen, by checking the current guest virtual machine's on / off application, it can be determined whether the shared pin is occupied. If it is determined that the shared pin is occupied by another guest virtual machine, then step S203 is executed. Otherwise, if it is determined that the shared pin is not occupied by another guest virtual machine, then step S205 is executed.
[0083] S203: The application notifies the guest virtual machine occupying the shared pin to close the GPIO device file of the shared pin through the current guest virtual machine's on / off switch.
[0084] If the host virtual machine determines that a shared pin is being used by another guest virtual machine, it will notify the guest virtual machine using the host virtual machine's on / off application to disable the GPIO device file of the shared pin. This will cause the guest virtual machine using the shared pin to stop using the shared pin. For example, if the host virtual machine is the first guest virtual machine and the guest virtual machine using the shared pin is the second guest virtual machine, then the host virtual machine will notify the second guest virtual machine to stop using the shared pin through the first guest virtual machine's on / off application.
[0085] S204: The switch application of the guest virtual machine occupying the shared pin notifies the pin application to release the shared pin, so that the current guest virtual machine can use the shared pin.
[0086] After the guest virtual machine occupying the shared pin is notified to suspend the use of the shared pin, the host virtual machine notifies the corresponding pin application to release the shared pin through the on / off application of the guest virtual machine occupying the shared pin. The current guest virtual machine that needs to use the shared pin can then use the shared pin normally, realizing the reuse of the shared pin between the current guest virtual machine and the guest virtual machine occupying the shared pin.
[0087] In some embodiments, the pin application is a corresponding application in each guest virtual machine that can release shared pins. The specific content of the application is not limited in the embodiments of this application.
[0088] S205: The current guest virtual machine uses a shared pin.
[0089] If it is determined that the shared pin is not occupied by other guest virtual machines, the current guest virtual machine can directly use the shared pin to output and carry out business.
[0090] This application provides a pin multiplexing method for a multi-virtual machine system. The multi-virtual machine system includes a master virtual machine and several guest virtual machines. The guest virtual machines use the same GPIO pin component, which includes multiple physical GPIO pins. When the master virtual machine receives a request from a guest virtual machine to use a shared pin, it obtains the output level of the shared pin through the host application of the current guest virtual machine and checks whether other guest virtual machines are occupying the shared pin based on the output level. If the shared pin is occupied, the host application notifies the guest virtual machine occupying the shared pin to close the GPIO device file of the shared pin. Then, the host application notifies its pin application to release the shared pin, allowing the current guest virtual machine to use the shared pin normally, thus realizing the multiplexing of the shared pin among different guest virtual machines. In the architecture of the multi-virtual machine system provided in this application embodiment, the same physical real GPIO pin can be passed to two or more guest virtual machines for shared use. Through the interaction between the two or more guest virtual machines, the same physical real GPIO pin can be reused between different guest virtual machines, thereby enabling multiple guest virtual machines to reuse more resources in the scenario of sharing pins, saving hardware and resource management costs.
[0091] Figure 4 This is a schematic diagram of a pin multiplexing device for a multi-virtual machine system provided in an embodiment of this application. The multi-virtual machine system includes a host virtual machine and several guest virtual machines. The guest virtual machines use the same GPIO pin component, which includes multiple physical GPIO pins. Figure 4 As shown in the embodiment of this application, the pin multiplexing device 300 for a multi-virtual machine system includes:
[0092] The pin checking module 301 is used to check whether other guest virtual machines occupy the shared pin when the current guest virtual machine receives a request to use the shared pin. The shared pin is at least one physical real GPIO pin that is configured for use by the current guest virtual machine and other guest virtual machines.
[0093] The notification module 302 is used to notify the guest virtual machine occupying the shared pin to suspend its use of the shared pin by means of the current guest virtual machine's on / off application if it is determined that another guest virtual machine is occupying the shared pin.
[0094] The reuse module 303 is used to release the shared pin by the switch application of the guest virtual machine that occupies the shared pin, so that the current guest virtual machine can use the shared pin.
[0095] In one possible design, the pin inspection module 301 is specifically used for:
[0096] Obtain the output level of the shared pin through the current virtual machine's switch application;
[0097] Check if any other guest virtual machine is using the shared pin based on the output level of the shared pin.
[0098] In one possible design, the pin inspection module 301 is also used for:
[0099] Determine whether the output level of the shared pin is consistent with the preset level. The preset level is the level value when the shared pin is in output mode.
[0100] If so, it indicates that the shared pin is being used by another guest virtual machine.
[0101] In one possible design, the notification module 302 is specifically used for:
[0102] The application notifies the guest virtual machine that is using the shared pin to close the GPIO device file on the shared pin by switching the current guest virtual machine on and off.
[0103] In one possible design, module 303 is reused, specifically for:
[0104] The switch application of the guest virtual machine that occupies the shared pin notifies the pin application to release the shared pin.
[0105] In one possible design, the current guest virtual machine's switch application and the guest virtual machine's switch application occupying the shared pin are connected via inter-domain communication.
[0106] In one possible design, several guest virtual machines load the front-end virtual pin drivers deployed on several guest virtual machines through standard paravirtualization drivers, and use the GPIO pin components by calling the GPIO pin components based on the back-end virtual pins deployed on the master virtual machine corresponding to the front-end virtual pins, with each back-end virtual pin having a corresponding relationship with a physical real GPIO pin.
[0107] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 5 As shown, the electronic device 500 may include a processor 501 and a memory 502 communicatively connected to the processor 501.
[0108] Memory 502 is used to store programs. Specifically, the program may include program code, which includes computer-executable instructions.
[0109] The memory 502 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0110] The processor 501 is used to execute computer execution instructions stored in the memory 502 to implement the pin multiplexing method of the multi-virtual machine system provided in the above embodiments.
[0111] The processor 501 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0112] Optionally, the memory 502 can be either standalone or integrated with the processor 501. When the memory 502 is a device independent of the processor 501, the electronic device 500 may further include:
[0113] Bus 503 is used to connect processor 501 and memory 502. The bus can be an industry standard architecture (ISA) bus, a peripheral component (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc., but this does not mean there is only one bus or one type of bus.
[0114] Optionally, in a specific implementation, if the memory 502 and the processor 501 are integrated on a single chip, the memory 502 and the processor 501 can communicate through an internal interface.
[0115] This application also provides a computer-readable storage medium, which may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. Specifically, the computer-readable storage medium stores computer-executable instructions, which are used in the various steps of the methods in the above embodiments.
[0116] This application also provides a computer program product, including computer execution instructions that, when executed by a processor, implement the steps of the methods described above.
[0117] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.
[0118] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A pin multiplexing method for a multi-virtual machine system, characterized in that, The multi-virtual machine system includes a host virtual machine and several guest virtual machines, the guest virtual machines using the same GPIO pin component, the GPIO pin component including multiple physical GPIO pins; the method includes: When a request is received that the current guest virtual machine needs to use a shared pin, the switch application of the current guest virtual machine is used to check whether other guest virtual machines occupy the shared pin. The shared pin is at least one of the same physical GPIO pins configured for use by the current guest virtual machine and the other guest virtual machines. If so, the current guest virtual machine's on / off application sends a notification to the guest virtual machine occupying the shared pin, so that the guest virtual machine occupying the shared pin suspends the use of the shared pin; In response to the notification, the shared pin is released by the switch application of the guest virtual machine that is occupying the shared pin, so that the current guest virtual machine can use the shared pin.
2. The pin reuse method according to claim 1, characterized in that, The step of checking whether other guest virtual machines are occupying the shared pin through the current guest virtual machine's on / off application includes: The output level of the shared pin is obtained through the switch application of the current guest virtual machine; Check whether any other guest virtual machine is occupying the shared pin based on the output level of the shared pin.
3. The pin reuse method according to claim 2, characterized in that, The step of checking whether other guest virtual machines are occupying the shared pin based on the output level of the shared pin includes: Determine whether the output level of the shared pin is consistent with the preset level, where the preset level is the level value when the shared pin is in output mode; If so, it is determined that the shared pin is occupied by the other guest virtual machine.
4. The pin multiplexing method of claim 2, wherein, The current guest virtual machine's on / off application sends a notification to the guest virtual machine occupying the shared pin, causing the guest virtual machine occupying the shared pin to suspend its use of the shared pin, including: The application notifies the guest virtual machine occupying the shared pin to close the GPIO device file of the shared pin by the current guest virtual machine's switch.
5. The pin multiplexing method of claim 4, wherein, The step of releasing the shared pin through the switch application of the guest virtual machine that occupies the shared pin includes: The switch application of the guest virtual machine that occupies the shared pin notifies the pin application to release the shared pin.
6. The pin multiplexing method of claim 1, wherein, The current guest virtual machine's switch application and the guest virtual machine's switch application occupying the shared pin are connected via inter-domain communication.
7. The pin multiplexing method according to any one of claims 1 to 6, wherein, The guest virtual machines use a standard paravirtualization driver to load the front-end virtual pin driver deployed on the guest virtual machines. The back-end virtual pins deployed on the master virtual machine, corresponding to the front-end virtual pins, call the GPIO pin components based on the back-end pin driver to use the GPIO pin components. Each back-end virtual pin has a corresponding relationship with the physical real GPIO pin.
8. A pin multiplexing device for a multi-virtual machine system, characterized in that, The multi-virtual machine system includes a host virtual machine and several guest virtual machines, the guest virtual machines using the same GPIO pin component, the GPIO pin component including multiple physical GPIO pins; the device includes: The pin checking module is used to check whether other guest virtual machines occupy the shared pin when a request is received from the current guest virtual machine to use the shared pin through the switch application of the current guest virtual machine. The shared pin is at least one of the same physical GPIO pins configured for use by the current guest virtual machine and other guest virtual machines. The notification module is used to send a notification to the guest virtual machine occupying the shared pin if it is determined that the other guest virtual machine occupies the shared pin, so that the guest virtual machine occupying the shared pin will suspend the use of the shared pin. A reuse module is configured to, in response to the notification, release the shared pin by the switch application of the guest virtual machine that occupies the shared pin, so that the current guest virtual machine can use the shared pin.
9. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the pin multiplexing method for a multi-virtual machine system as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the pin multiplexing method of a multi-virtual machine system as described in any one of claims 1-7.
11. A computer program product comprising computer-executable instructions, which, when executed by a processor, are used to implement the pin multiplexing method for a multi-virtual machine system as described in any one of claims 1-7.