WO2023116859A1 - 传感器设备虚拟化的方法、装置、电子设备和存储介质 - Google Patents

传感器设备虚拟化的方法、装置、电子设备和存储介质 Download PDF

Info

Publication number
WO2023116859A1
WO2023116859A1 PCT/CN2022/141256 CN2022141256W WO2023116859A1 WO 2023116859 A1 WO2023116859 A1 WO 2023116859A1 CN 2022141256 W CN2022141256 W CN 2022141256W WO 2023116859 A1 WO2023116859 A1 WO 2023116859A1
Authority
WO
WIPO (PCT)
Prior art keywords
sensor device
fuse
virtual node
linux system
daemon
Prior art date
Application number
PCT/CN2022/141256
Other languages
English (en)
French (fr)
Inventor
邓宝安
Original Assignee
抖音视界有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 抖音视界有限公司 filed Critical 抖音视界有限公司
Publication of WO2023116859A1 publication Critical patent/WO2023116859A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Definitions

  • the present disclosure relates to the field of computer technology, for example, to the field of Linux and Android compatible technology.
  • Linux systems generally implement Android system compatibility through containers, such as Android in a box (Anbox), using the Linux namespace to run a complete Android system in a container.
  • the Android container in the Linux system accesses the sensor sensor device, the sensor device can be accessed by sharing the node of the sensor device under the directory /dev/.
  • the sensor device can only be used by the Linux system or the Android container.
  • the Android container's access to the sensor device is not managed by the Linux system. If the Linux system and the Android container access the sensor device at the same time, conflicts will occur.
  • the present disclosure provides a sensor device virtualization method, device, electronic device, storage medium and computer program product.
  • the present disclosure provides a method for sensor device virtualization, including:
  • the virtual node is shared with the Android container in the Linux system;
  • the Android container communicates with the sensor device through the fuse daemon process.
  • the present disclosure provides an apparatus for sensor device virtualization, including:
  • the virtual module is set to create a virtual node corresponding to the sensor device in the Linux system
  • a sharing module configured to share the virtual node with the Android container in the Linux system
  • the communication module is configured to communicate with the sensor device through the fuse daemon daemon process for the Android container.
  • the present disclosure provides an electronic device, including:
  • a memory connected in communication with the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processing
  • the device can execute the method in any embodiment of the present disclosure.
  • the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method in any embodiment of the present disclosure.
  • the present disclosure provides a computer program product, including a computer program, when the computer program is executed by a processor, the method in any embodiment of the present disclosure is implemented.
  • FIG. 1 is a schematic diagram of a method for sensor device virtualization according to an embodiment of the present disclosure
  • Fig. 2 is a schematic diagram of a method for sensor device virtualization according to another embodiment of the present disclosure
  • FIG. 3 is a schematic diagram of an internal framework of a Linux system according to an embodiment of the present disclosure
  • Fig. 4 is a device block diagram of sensor device virtualization according to an embodiment of the present disclosure.
  • Fig. 5 is a device block diagram of sensor device virtualization according to another embodiment of the present disclosure.
  • FIG. 6 is a block diagram of an electronic device used to implement the method for virtualizing a sensor device according to an embodiment of the present disclosure.
  • the technical solutions of the embodiments of the present disclosure are applied to the scenario where the Linux system and the Android system run simultaneously, wherein the Android system runs in a host Linux system in the form of a container, and the host Linux system can be connected to one or more sensor devices.
  • the sensor devices involved in the embodiments of the present disclosure may be of various types, including but not limited to: temperature sensors, humidity sensors, pressure sensors, position sensors, speed sensors, acceleration sensors, thermal sensors, and the like.
  • the interaction between the Linux system or the Android system and the sensor device can be a two-way operation, including input operation and output operation.
  • the input operation means that the Linux system or the Android system can obtain data from sensor devices, such as obtaining data such as temperature, humidity and pressure.
  • the output operation means that the Linux system or the Android system can control the parameters of the sensor device, such as adjusting the sensitivity, accuracy, frequency range or error range of the sensor, and so on.
  • the embodiment of the present disclosure realizes the unified management of the sensor device by the host Linux system by virtualizing the sensor device, and can effectively solve the compatibility problem of the sensor device when running the Android container in the Linux system.
  • FIG. 1 is a schematic diagram of a method for sensor device virtualization in an embodiment of the present disclosure. As shown in Figure 1, the method includes:
  • S101 Create a virtual node corresponding to the sensor device in the Linux system.
  • S104 The Android container communicates with the sensor device through the fuse daemon daemon process.
  • creating a virtual node corresponding to the sensor device in the Linux system includes: using a user space file system (File system in Userspace, fuse) in the Linux system to create a virtual node corresponding to the sensor device.
  • a user space file system File system in Userspace, fuse
  • fuse is a module used in Linux to mount some network spaces to a local file system, and is a file system completely implemented in user mode.
  • Linux has supported the implementation of file systems in user space through fuses since version 2.6.14.
  • Implementing a file system in user space can greatly improve productivity, simplify the workload of providing a new file system for the operating system, and is applicable to various virtual file systems and network file systems.
  • the fuse driver can be thought of as a proxy that redirects requests to the backend user daemon. Different device files can be easily virtualized through fuse.
  • using fuse in the Linux system to create a virtual node corresponding to the sensor device includes: creating a fuse folder for the sensor device to generate a virtual node corresponding to the sensor device.
  • the embodiment of the present disclosure considers the two-way data transmission of the sensor device and the mutually exclusive characteristics of simultaneous access to the sensor device by the Linux system and the Android system, and uses fuse to realize the virtualization of the sensor device, which can not only realize the transmission of virtual events to the Android container, but also realize the Android Various operations of the container on the sensor device.
  • sharing the virtual node to the Android container in the Linux system includes: mounting the virtual node to the Android container in the Linux system through a mount function, so that the virtual node is visible to the Android container.
  • the above method further includes: modifying the sensor device registered in the Hardware Abstraction Layer (Hardware Abstraction Layer, HAL) to a virtual node.
  • HAL Hardware Abstraction Layer
  • the device node accessed by the Android container can be changed to a virtual node, which has the effect of isolating the sensor device, and realizes the Android container's access to the sensor device by accessing the virtual node.
  • /dev/fuse is the fuse driver node of Linux, and the fuse daemon daemon creates multiple folders such as fuse1/2/3... through this node, and each of these folders will be connected to a sensor under Linux Bind, and then share fuse1/2/3... under Linux to the Android container through mount-bind, and the hardware abstraction layer in the Android container accesses the sensor under Linux by accessing fuse1/2/3....
  • the Android container communicates with the sensor device through the fuse daemon process, including: when the Android container calls the interface function of the sensor device based on the HAL, the fuse daemon process operates the fuse_operations interface and the Linux system through the user space file system. communicate with the sensor server to complete the input operation or output operation to the sensor device.
  • fuse_operations is a set of interfaces, including multiple interfaces for operating sensor devices, such as open(), read(), write(), ioctl() and poll(), etc., these interfaces directly through the dbus bus Communicate with the sensor server sensor server in the Linux system to control and obtain data from sensor devices.
  • the call of the fuse_operations interface is implemented through the fuse daemon daemon process, which ensures the communication between the Android container and the sensor device, and realizes various operations of the Android container on the sensor device.
  • the unified management of the sensor device by the host Linux system is realized by virtualizing the sensor device.
  • the Linux system communicates directly with the sensor device, and the Android container communicates with the sensor device by accessing virtual nodes, which avoids conflicts when the Linux system and the Android container access the sensor device at the same time, and effectively solves the problem of the sensor device when running the Android container in the Linux system. compatibility issues.
  • Fig. 2 is a schematic diagram of a method for sensor device virtualization in an embodiment of the present disclosure. As shown in Figure 2, the method includes:
  • S201 Use fuse in the Linux system to create a virtual node corresponding to the sensor device.
  • the above step S201 may include: creating a fuse folder for the sensor device, and using the mount function to mount the fuse folder to the directory /dev/fuse to generate a virtual node corresponding to the sensor device.
  • S202 Mount the virtual node into the Android container in the Linux system through a mount function, so that the virtual node is visible to the Android container.
  • S203 Modify the sensor device registered in the HAL to a virtual node.
  • the sensor_open in the HAL can be modified, and the sensor device registered in the HAL can be modified to the fuse file corresponding to the virtual node, thereby ensuring that the HAL calls open(), read(), write(), ioctl() or poll() and other functions, it can be captured by the fuse daemon daemon process.
  • the function of the fuse daemon daemon process is to access the sensor server sensor server through the fuse daemon daemon process when the Android container accesses the virtual node, thereby realizing control and obtaining data of the sensor device.
  • the fuse daemon daemon can realize the call of various interfaces such as open(), read(), write(), ioctl() or poll() in fuse_operations , these interfaces directly communicate with the sensor server sensor server in the Linux system through the dbus bus to realize control and obtain sensor device data.
  • FIG. 3 is a schematic diagram of an internal framework of a Linux system in an embodiment of the present disclosure.
  • a Linux container (Linux Container, lxc) is used to run an Android container in a Linux system.
  • Use fuse to create a virtual node corresponding to the sensor device in the Linux system, mount the generated fuse folder to the directory /dev/fuse, and mount the fuse folder to the Android container in a container sharing manner. Modify the sensor devices registered in the HAL as virtual nodes. Create a fusedaemon daemon process in the Linux system.
  • the fuse daemon daemon communicates with the sensor server sensorfw server in the Linux system through the fuse_operations interface to complete the input operation or output operation of the sensor device.
  • the unified management of the sensor device by the host Linux system is realized by virtualizing the sensor device.
  • the Linux system communicates directly with the sensor device, and the Android container communicates with the sensor device by accessing virtual nodes, which avoids conflicts when the Linux system and the Android container access the sensor device at the same time, and effectively solves the problem of the sensor device when running the Android container in the Linux system. compatibility issues.
  • Fig. 4 is a device block diagram of sensor device virtualization according to an embodiment of the present disclosure.
  • the device includes: a virtual module 401, which is configured to create a virtual node corresponding to the sensor device in the Linux system; a sharing module 402, which is configured to share the virtual node to an Android container in the Linux system; a creation module 403, It is set to create a fuse daemon daemon process in the Linux system; the communication module 404 is set to communicate with the sensor device through the fuse daemon daemon process for the Android container.
  • the virtual module 401 includes: a virtual unit configured to use the user space file system fuse in the Linux system to create a virtual node corresponding to the sensor device.
  • the virtual unit is configured to: create a fuse folder for the sensor device, so as to generate a virtual node corresponding to the sensor device.
  • the sharing module 402 is configured to: mount the virtual node into the Android container in the Linux system through the mount function, so that the virtual node is visible to the Android container.
  • Fig. 5 is a block diagram of a device according to an embodiment of the disclosure. As shown in FIG. 5 , the device includes: a virtual module 501 , a sharing module 502 , a creation module 503 , a communication module 504 and a modification module 505 .
  • the functions of the virtual module 501, the sharing module 502, the creating module 503 and the communication module 504 are the same as those of the virtual module 401, the sharing module 402, the creating module 403 and the communication module 404 in the above embodiment respectively, and will not be repeated here.
  • the modification module 505 is configured to modify the sensor device registered in the hardware abstraction layer HAL into a virtual node.
  • the communication module 504 is set to: when the Android container calls the interface function of the sensor device based on the HAL, the fuse daemon daemon communicates with the sensor server in the Linux system through the user space file system to operate the fuse_operations interface, and completes the communication with the sensor. An input operation or an output operation for a device.
  • the above-mentioned device provided by the embodiments of the present disclosure realizes the unified management of the sensor device by the host Linux system by virtualizing the sensor device.
  • the Linux system communicates directly with the sensor device, and the Android container communicates with the sensor device by accessing virtual nodes, which avoids conflicts when the Linux system and the Android container access the sensor device at the same time, and effectively solves the problem of the sensor device when running the Android container in the Linux system. compatibility issues.
  • the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
  • FIG. 6 shows a schematic block diagram of an example electronic device 600 that may be used to implement embodiments of the present disclosure.
  • Electronic devices may be various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other computers.
  • Electronic devices may also be various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices.
  • the components, the connections and relationships between the components, and the functions of the components shown herein are by way of example only.
  • the device 600 includes a computing unit 601, which can be loaded into a random access memory (Random Access Memory, RAM) according to a computer program stored in a read-only memory (Read-Only Memory, ROM) 602 or from a storage unit 608. ) 603 to perform various actions and processes. In the RAM 603, various programs and data necessary for the operation of the device 600 can also be stored.
  • the computing unit 601, ROM 602, and RAM 603 are connected to each other through a bus 604.
  • An input/output (Input/Output, I/O) interface 605 is also connected to the bus 604 .
  • Multiple components in the device 600 are connected to the I/O interface 605, and the multiple components include: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk , an optical disc, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, and the like.
  • the communication unit 609 allows the device 600 to exchange information/data with other devices over a computer network such as the Internet and/or various telecommunication networks.
  • Computing unit 601 may be various general-purpose and/or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), a variety of dedicated artificial intelligence (Artificial Intelligence, AI) computing chips, a variety of operating Computing unit of machine learning model algorithm, digital signal processor (Digital Signal Processor, DSP), and processor, controller, microcontroller, etc.
  • the calculation unit 601 executes various methods and processes described above. For example, in some embodiments, the methods described above may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 608 .
  • part or all of the computer program may be loaded and/or installed on the device 600 via the ROM 602 and/or the communication unit 609.
  • a computer program When a computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of the methods described above may be performed.
  • the computing unit 601 may be configured in other ways (for example, by means of firmware) to execute the above method.
  • programmable processor can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
  • Program codes for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes can be provided to processors or controllers of general-purpose computers, special-purpose computers, or other programmable data processing devices, so that when the program codes are executed by the processors or controllers, the functions/operations specified in the flowcharts and/or block diagrams be implemented.
  • the program code may execute entirely or partially on the machine, or as a stand-alone software package that executes partly on the machine and partly on a remote machine or entirely on a remote machine or server.
  • a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device.
  • a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • a machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared semiconductor systems, devices, or devices, or any combination of the foregoing.
  • the machine-readable storage medium may include one or more wire-based electrical connections, a portable computer disk, a hard disk, RAM, ROM, Electrically Erasable Programmable Read-Only Memory (EPROM), or flash memory , optical fiber, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical storage device, magnetic storage device, or any combination of the foregoing.
  • the systems and techniques described herein can be implemented on a computer having a display device (e.g., a Cathode Ray Tube (CRT) or a Liquid Crystal Display (LCD)) to display information to the user.
  • a display device e.g., a Cathode Ray Tube (CRT) or a Liquid Crystal Display (LCD)
  • LCD Liquid Crystal Display
  • keyboard and pointing device such as a mouse or trackball
  • Other types of devices may also be configured to provide interaction with the user, for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and may be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
  • the systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system.
  • the components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include: Local Area Network (LAN), Wide Area Network (Wide Area Network, WAN), and the Internet.
  • a computer system may include clients and servers.
  • Clients and servers are generally remote from each other and typically interact through a communication network.
  • the relationship of client and server arises by running a computer program on the computer having a client-server relationship.
  • the server can be a cloud server, a server of a distributed system, or a server combined with a blockchain.
  • steps may be reordered, added or deleted using the various forms of the flow shown above.
  • steps described in the present disclosure may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present disclosure can be achieved, no limitation is imposed herein.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Stored Programmes (AREA)

Abstract

本公开提供了一种传感器设备虚拟化的方法、装置、电子设备和存储介质。该方法包括:在Linux系统中创建传感器设备对应的虚拟节点,将所述虚拟节点共享给所述Linux系统中的Android容器,在所述Linux系统中创建fuse daemon守护进程,所述Android容器通过所述fuse daemon守护进程与所述传感器设备进行通信。

Description

传感器设备虚拟化的方法、装置、电子设备和存储介质
本申请要求在2021年12月24日提交中国专利局、申请号为202111592516.6的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本公开涉及计算机技术领域,例如涉及Linux和Android兼容技术领域。
背景技术
Linux系统普遍通过容器来实现Android系统的兼容,如通过容器中的安卓(Android in a box,Anbox),使用Linux命名空间在容器中运行完整的Android系统。当Linux系统内的Android容器访问传感器sensor设备时,可以通过对目录/dev/下的传感器设备的节点共享的方式对传感器设备进行访问。
但是,共享的方式下传感器设备只能由Linux系统或Android容器一方使用,Android容器对于传感器设备的访问不受Linux系统管理,如果Linux系统和Android容器同时访问传感器设备,则会产生冲突。
发明内容
本公开提供了一种传感器设备虚拟化的方法、装置、电子设备、存储介质和计算机程序产品。
本公开提供了一种传感器设备虚拟化的方法,包括:
在Linux系统中创建传感器设备对应的虚拟节点;
将所述虚拟节点共享给所述Linux系统中的Android容器;
在所述Linux系统中创建fuse daemon守护进程;
所述Android容器通过所述fuse daemon守护进程与所述传感器设备进行通信。
本公开提供了一种传感器设备虚拟化的装置,包括:
虚拟模块,设置为在Linux系统中创建传感器设备对应的虚拟节点;
共享模块,设置为将所述虚拟节点共享给所述Linux系统中的Android容器;
创建模块,设置为在所述Linux系统中创建fuse daemon守护进程;
通信模块,设置为所述Android容器通过所述fuse daemon守护进程与所述传感器设备进行通信。
本公开提供了一种电子设备,包括:
至少一个处理器;以及
与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行本公开任一实施例中的方法。
本公开提供了一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行本公开任一实施例中的方法。
本公开提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现本公开任一实施例中的方法。
附图说明
图1是根据本公开一实施例中传感器设备虚拟化的方法示意图;
图2是根据本公开另一实施例中传感器设备虚拟化的方法示意图;
图3是根据本公开一实施例中Linux系统内部框架示意图;
图4是根据本公开一实施例中传感器设备虚拟化的装置框图;
图5是根据本公开另一实施例中传感器设备虚拟化的装置框图;
图6是用来实现本公开实施例的传感器设备虚拟化的方法的电子设备的框图。
具体实施方式
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的多种细节,应当将它们认为仅仅是示范性的。
本公开实施例的技术方案应用于Linux系统和Android系统同时运行的场景,其中,Android系统以容器的方式在主机Linux系统中运行,该主机Linux系统可以连接一个或多个传感器设备。本公开实施例涉及的传感器设备可以有多种类型,包括但不限于:温度传感器、湿度传感器、压力传感器、位置传感器、速度传感器、加速度传感器和热敏传感器等等。Linux系统或Android系统与传感器设备的交互可以是双向操作,包括输入操作和输出操作。其中,输入操作是指Linux系统或Android系统可以从传感器设备获取数据,如获取温度、湿度和压力等数据。输出操作是指Linux系统或Android系统可以控制传感器设备的参数,如调节传感器的灵敏度、精度、频率范围或误差范围等等。
本公开实施例通过对传感器设备进行虚拟化,实现主机Linux系统对传感器 设备的统一管理,可以有效地解决Linux系统中运行Android容器时传感器设备的兼容问题。
图1为本公开一实施例中传感器设备虚拟化的方法示意图。如图1所示,该方法包括:
S101:在Linux系统中创建传感器设备对应的虚拟节点。
S102:将虚拟节点共享给Linux系统中的Android容器。
S103:在Linux系统中创建fuse daemon守护进程。
S104:Android容器通过fuse daemon守护进程与传感器设备进行通信。
在一种实施方式中,在Linux系统中创建传感器设备对应的虚拟节点,包括:在Linux系统中使用用户空间文件系统(File system in Userspace,fuse),创建传感器设备对应的虚拟节点。
本公开实施例中,fuse是Linux中用于挂载一些网络空间到本地文件系统的模块,是完全在用户态实现的文件系统。Linux从2.6.14版本开始通过fuse支持在用户空间实现文件系统。在用户空间实现文件系统能够大幅提高生产率,简化了为操作系统提供新的文件系统的工作量,适用于多种虚拟文件系统和网络文件系统。fuse驱动程序可以视为将请求重定向到后端用户守护程序的代理。通过fuse可以很容易虚拟出不同的设备文件。
在一种实施方式中,在Linux系统中使用fuse,创建传感器设备对应的虚拟节点,包括:为传感器设备创建fuse文件夹,以生成传感器设备对应的虚拟节点。
本公开实施例考虑到传感器设备双向数据传输以及Linux系统和Android系统同时访问传感器设备互斥的特点,使用fuse来实现传感器设备的虚拟化,不仅能够实现传输虚拟事件给Android容器,而且能够实现Android容器对传感器设备的多种操作。
在一种实施方式中,将虚拟节点共享给Linux系统中的Android容器,包括:通过mount挂载函数将虚拟节点挂载到Linux系统中的Android容器中,以使虚拟节点对Android容器可见。
在一种实施方式中,上述方法还包括:将硬件抽象层(Hardware Abstraction Layer,HAL)中注册的传感器设备修改为虚拟节点。
通过修改HAL可以使Android容器访问的设备节点改为虚拟节点,起到了隔离传感器设备的效果,以访问虚拟节点的方式实现了Android容器对传感器设备的访问。
示例性地,/dev/fuse是Linux的fuse驱动节点,fuse daemon守护进程通过这个节点创建出fuse1/2/3…等多个文件夹,这些文件夹中的每个会与Linux下的一个传感器绑定,然后将Linux下的fuse1/2/3…通过mount-bind的方式共享到Android容器中,Android容器中的硬件抽象层通过访问fuse1/2/3…达到访问Linux下的传感器的目的。
在一种实施方式中,Android容器通过fuse daemon守护进程与传感器设备进行通信,包括:Android容器基于HAL调用传感器设备的接口函数时,fuse daemon守护进程通过用户空间文件系统操作fuse_operations接口与Linux系统内的传感器服务器通信,完成对传感器设备的输入操作或输出操作。
本公开实施例中,fuse_operations为一组接口,包括多个操作传感器设备的接口,如open(),read(),write(),ioctl()和poll()等等,这些接口通过dbus总线直接与Linux系统内的传感器服务器sensor server通讯,用于控制和获取传感器设备的数据。
通过fuse daemon守护进程实现了fuse_operations接口的调用,保证了Android容器与传感器设备的通信,实现了Android容器对传感器设备的多种操作。
本公开实施例提供的上述方法,通过对传感器设备进行虚拟化,实现主机Linux系统对传感器设备的统一管理。Linux系统与传感器设备直接通信,Android容器以访问虚拟节点的方式与传感器设备进行通信,避免了Linux系统和Android容器同时访问传感器设备时产生冲突,有效地解决了Linux系统中运行Android容器时传感器设备的兼容问题。
图2为本公开一实施例中传感器设备虚拟化的方法示意图。如图2所示,该方法包括:
S201:在Linux系统中使用fuse,创建传感器设备对应的虚拟节点。
本公开实施例中,上述步骤S201可以包括:为传感器设备创建fuse文件夹,使用mount挂载函数将fuse文件夹挂载到目录/dev/fuse下,以生成传感器设备对应的虚拟节点。
为传感器设备创建fuse文件夹可以参考传感器HAL中支持的传感器类型来创建,具体方式不限定。
S202:通过mount挂载函数将虚拟节点挂载到Linux系统中的Android容器中,以使虚拟节点对Android容器可见。
S203:将HAL中注册的传感器设备修改为虚拟节点。
在一种实施方式中,可以修改HAL中的sensor_open,将HAL中注册的传感器设备修改为虚拟节点对应的fuse文件,从而保证了HAL调用open(),read(),write(),ioctl()或poll()等函数时,可以由fuse daemon守护进程捕获到。
S204:在Linux系统中创建fuse daemon守护进程。
本公开实施例中,fuse daemon守护进程的作用是在Android容器访问虚拟节点时,通过fuse daemon守护进程能够访问传感器服务器sensor server,进而实现控制和获取传感器设备的数据。上述将虚拟节点对应的fuse文件夹挂载到目录/dev/fuse下以后,对该虚拟节点对应的fuse文件访问均会由fuse daemon守护进程获取并处理。
S205:Android容器基于HAL调用传感器设备的接口函数时,fuse daemon守护进程通过fuse_operations接口与Linux系统内的传感器服务器通信,完成对传感器设备的输入操作或输出操作。
在一种实施方式中,针对Android容器对虚拟节点的调用,fuse daemon守护进程可以实现fuse_operations中如open(),read(),write(),ioctl()或poll()等多种接口的调用,这些接口通过dbus总线直接与Linux系统内的传感器服务器sensor server通讯,实现控制和获取传感器设备数据。
图3为本公开一实施例中Linux系统内部框架示意图。如图3所示,在一种实施方式中,使用Linux容器(Linux Container,lxc)在Linux系统中运行Android容器。在Linux系统中使用fuse创建传感器设备对应的虚拟节点,生成的fuse文件夹挂载到目录/dev/fuse下,且将fuse文件夹以容器共享的方式挂载到Android容器中。将HAL中注册的传感器设备修改为虚拟节点。在Linux系统中创建fusedaemon守护进程。Android容器基于HAL调用传感器设备的接口函数时,fuse daemon守护进程通过fuse_operations接口与Linux系统内的传感器服务器sensorfw server通信,完成对传感器设备的输入操作或输出操作。
本公开实施例提供的上述方法,通过对传感器设备进行虚拟化,实现主机Linux系统对传感器设备的统一管理。Linux系统与传感器设备直接通信,Android容器以访问虚拟节点的方式与传感器设备进行通信,避免了Linux系统和Android容器同时访问传感器设备时产生冲突,有效地解决了Linux系统中运行Android容器时传感器设备的兼容问题。
图4是根据本公开一实施例中传感器设备虚拟化的装置框图。如图4所示, 该装置包括:虚拟模块401,设置为在Linux系统中创建传感器设备对应的虚拟节点;共享模块402,设置为将虚拟节点共享给Linux系统中的Android容器;创建模块403,设置为在Linux系统中创建fuse daemon守护进程;通信模块404,设置为Android容器通过fuse daemon守护进程与传感器设备进行通信。
在一种实施方式中,虚拟模块401包括:虚拟单元,设置为在Linux系统中使用用户空间文件系统fuse,创建传感器设备对应的虚拟节点。
在一种实施方式中,虚拟单元是设置为:为传感器设备创建fuse文件夹,以生成传感器设备对应的虚拟节点。
在一种实施方式中,共享模块402是设置为:通过mount挂载函数将虚拟节点挂载到Linux系统中的Android容器中,以使虚拟节点对Android容器可见。
图5是根据本公开一实施例中的装置框图。如图5所示,该装置包括:虚拟模块501、共享模块502、创建模块503、通信模块504和修改模块505。
虚拟模块501、共享模块502、创建模块503和通信模块504分别与上述实施例中的虚拟模块401、共享模块402、创建模块403和通信模块404功能相同,此处不赘述。
在一种实施方式中,修改模块505设置为将硬件抽象层HAL中注册的传感器设备修改为虚拟节点。
在一种实施方式中,通信模块504是设置为:Android容器基于HAL调用传感器设备的接口函数时,fuse daemon守护进程通过用户空间文件系统操作fuse_operations接口与Linux系统内的传感器服务器通信,完成对传感器设备的输入操作或输出操作。
本公开实施例提供的上述装置,通过对传感器设备进行虚拟化,实现主机Linux系统对传感器设备的统一管理。Linux系统与传感器设备直接通信,Android容器以访问虚拟节点的方式与传感器设备进行通信,避免了Linux系统和Android容器同时访问传感器设备时产生冲突,有效地解决了Linux系统中运行Android容器时传感器设备的兼容问题。
根据本公开的实施例,本公开还提供了一种电子设备、一种可读存储介质和一种计算机程序产品。
图6示出了可以用来实施本公开的实施例的示例电子设备600的示意性框图。电子设备可以是多种形式的数字计算机,诸如,膝上型计算机、台式计算 机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它计算机。电子设备还可以是多种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、部件之间的连接和关系、以及部件的功能仅仅作为示例。
如图6所示,设备600包括计算单元601,其可以根据存储在只读存储器(Read-Only Memory,ROM)602中的计算机程序或者从存储单元608加载到随机访问存储器(Random Access Memory,RAM)603中的计算机程序,来执行多种动作和处理。在RAM 603中,还可存储设备600操作所需的多种程序和数据。计算单元601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(Input/Output,I/O)接口605也连接至总线604。
设备600中的多个部件连接至I/O接口605,多个部件包括:输入单元606,例如键盘、鼠标等;输出单元607,例如多种类型的显示器、扬声器等;存储单元608,例如磁盘、光盘等;以及通信单元609,例如网卡、调制解调器、无线通信收发机等。通信单元609允许设备600通过诸如因特网的计算机网络和/或多种电信网络与其他设备交换信息/数据。
计算单元601可以是多种具有处理和计算能力的通用和/或专用处理组件。计算单元601的一些示例包括但不限于中央处理单元(Central Processing Unit,CPU)、图形处理单元(Graphics Processing Unit,GPU)、多种专用的人工智能(Artificial Intelligence,AI)计算芯片、多种运行机器学习模型算法的计算单元、数字信号处理器(Digital Signal Processor,DSP)、以及处理器、控制器、微控制器等。计算单元601执行上文所描述的多个方法和处理。例如,在一些实施例中,上述方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元608。在一些实施例中,计算机程序的部分或者全部可以经由ROM 602和/或通信单元609而被载入和/或安装到设备600上。当计算机程序加载到RAM 603并由计算单元601执行时,可以执行上文描述的方法的一个或多个步骤。备选地,在其他实施例中,计算单元601可以通过其他方式(例如,借助于固件)而被配置为执行上述方法。
本文中以上描述的系统和技术的多种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(Field Programmable Gate Array,FPGA)、专用集成电路(Application Specific Integrated Circuit,ASIC)、专用标准产品(Application Specific Standard Product,ASSP)、芯片上系统的系统(System on Chip,SOC)、负载可编程逻辑设备(Complex Programmable Logic Device,CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些多种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括 至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。
用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码由处理器或控制器执行时,流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行或部分地在机器上执行,程序代码也可以作为独立软件包一部分地在机器上执行且另一部分在远程机器上执行或完全在远程机器或服务器上执行。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的半导体系统、装置或设备,或者上述内容的任何组合。机器可读存储介质可以包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、RAM、ROM、可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EPROM)或快闪存储器、光纤、便捷式紧凑盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何组合。
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:向用户显示信息的显示装置(例如,阴极射线管(Cathode Ray Tube,CRT)或者液晶显示器(Liquid Crystal Display,LCD)监视器),以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以设置为提供与用户的交互,例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈),并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例 如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(Local Area Network,LAN)、广域网(Wide Area Network,WAN)和互联网。
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在计算机上运行具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,也可以为分布式系统的服务器,或者是结合了区块链的服务器。
应该理解,可以使用上面所示的多种形式的流程,重新排序、增加或删除步骤。例如,本发公开中记载的多个步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。

Claims (14)

  1. 一种传感器设备虚拟化的方法,包括:
    在Linux系统中创建传感器设备对应的虚拟节点;
    将所述虚拟节点共享给所述Linux系统中的Android容器;
    在所述Linux系统中创建fuse daemon守护进程;
    所述Android容器通过所述fuse daemon守护进程与所述传感器设备进行通信。
  2. 根据权利要求1所述的方法,其中,所述在Linux系统中创建传感器设备对应的虚拟节点,包括:
    在Linux系统中使用用户空间文件系统fuse,创建传感器设备对应的虚拟节点。
  3. 根据权利要求2所述的方法,其中,所述在Linux系统中使用fuse,创建传感器设备对应的虚拟节点,包括:
    为传感器设备创建fuse文件夹,以生成所述传感器设备对应的虚拟节点。
  4. 根据权利要求1所述的方法,其中,所述将所述虚拟节点共享给所述Linux系统中的Android容器,包括:
    通过mount挂载函数将所述虚拟节点挂载到所述Linux系统中的Android容器中,以使所述虚拟节点对所述Android容器可见。
  5. 根据权利要求1所述的方法,还包括:
    将硬件抽象层HAL中注册的所述传感器设备修改为所述虚拟节点。
  6. 根据权利要求5所述的方法,其中,所述Android容器通过所述fuse daemon守护进程与所述传感器设备进行通信,包括:
    在所述Android容器基于所述HAL调用所述传感器设备的接口函数的情况下,所述fuse daemon守护进程通过用户空间文件系统操作fuse_operations接口 与所述Linux系统内的传感器服务器通信,完成对所述传感器设备的输入操作或输出操作。
  7. 一种传感器设备虚拟化的装置,包括:
    虚拟模块,设置为在Linux系统中创建传感器设备对应的虚拟节点;
    共享模块,设置为将所述虚拟节点共享给所述Linux系统中的Android容器;
    创建模块,设置为在所述Linux系统中创建fuse daemon守护进程;
    通信模块,设置为所述Android容器通过所述fuse daemon守护进程与所述传感器设备对应的虚拟节点进行通信。
  8. 根据权利要求7所述的装置,其中,所述虚拟模块包括:
    虚拟单元,设置为在Linux系统中使用用户空间文件系统fuse,创建传感器设备对应的虚拟节点。
  9. 根据权利要求8所述的装置,其中,所述虚拟单元是设置为:
    为传感器设备创建fuse文件夹,以生成所述传感器设备对应的虚拟节点。
  10. 根据权利要求7所述的装置,其中,所述共享模块是设置为:
    通过mount挂载函数将所述虚拟节点挂载到所述Linux系统中的Android容器中,以使所述虚拟节点对所述Android容器可见。
  11. 根据权利要求7所述的装置,还包括:
    修改模块,设置为将硬件抽象层HAL中注册的所述传感器设备修改为所述虚拟节点。
  12. 根据权利要求11所述的装置,其中,所述通信模块是设置为:
    在所述Android容器基于所述HAL调用所述传感器设备的接口函数的情况下,所述fuse daemon守护进程通过用户空间文件系统操作fuse_operations接口与所述Linux系统内的传感器服务器通信,完成对所述传感器设备的输入操作或 输出操作。
  13. 一种电子设备,包括:
    至少一个处理器;以及
    与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-6中任一项所述的方法。
  14. 一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-6中任一项所述的方法。
PCT/CN2022/141256 2021-12-24 2022-12-23 传感器设备虚拟化的方法、装置、电子设备和存储介质 WO2023116859A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111592516.6 2021-12-24
CN202111592516.6A CN113986476A (zh) 2021-12-24 2021-12-24 传感器设备虚拟化的方法、装置、电子设备和存储介质

Publications (1)

Publication Number Publication Date
WO2023116859A1 true WO2023116859A1 (zh) 2023-06-29

Family

ID=79734187

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/141256 WO2023116859A1 (zh) 2021-12-24 2022-12-23 传感器设备虚拟化的方法、装置、电子设备和存储介质

Country Status (2)

Country Link
CN (1) CN113986476A (zh)
WO (1) WO2023116859A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113986476A (zh) * 2021-12-24 2022-01-28 北京鲸鲮信息系统技术有限公司 传感器设备虚拟化的方法、装置、电子设备和存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105808320A (zh) * 2016-03-11 2016-07-27 四川安嵌科技有限公司 基于Linux容器的设备虚拟化系统及方法
US20210097037A1 (en) * 2019-09-26 2021-04-01 International Business Machines Corporation Container software discovery and cataloging
CN113448740A (zh) * 2021-09-01 2021-09-28 北京鲸鲮信息系统技术有限公司 操作系统的电源管理方法及装置
CN113791875A (zh) * 2021-11-18 2021-12-14 北京鲸鲮信息系统技术有限公司 输入设备虚拟化的方法、装置、电子设备和存储介质
CN113986476A (zh) * 2021-12-24 2022-01-28 北京鲸鲮信息系统技术有限公司 传感器设备虚拟化的方法、装置、电子设备和存储介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110659246B (zh) * 2019-09-26 2022-05-03 北京百度网讯科技有限公司 基于容器的文件挂载方法、装置及电子设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105808320A (zh) * 2016-03-11 2016-07-27 四川安嵌科技有限公司 基于Linux容器的设备虚拟化系统及方法
US20210097037A1 (en) * 2019-09-26 2021-04-01 International Business Machines Corporation Container software discovery and cataloging
CN113448740A (zh) * 2021-09-01 2021-09-28 北京鲸鲮信息系统技术有限公司 操作系统的电源管理方法及装置
CN113791875A (zh) * 2021-11-18 2021-12-14 北京鲸鲮信息系统技术有限公司 输入设备虚拟化的方法、装置、电子设备和存储介质
CN113986476A (zh) * 2021-12-24 2022-01-28 北京鲸鲮信息系统技术有限公司 传感器设备虚拟化的方法、装置、电子设备和存储介质

Also Published As

Publication number Publication date
CN113986476A (zh) 2022-01-28

Similar Documents

Publication Publication Date Title
US11416275B2 (en) Techniques for migration paths
US10558649B2 (en) Database server system monitoring
US10341287B2 (en) Direct transmission of data between applications in a multi-tenant environment
JP6316694B2 (ja) クラウドスケールの異種データセンタ管理インフラストラクチャ
US11126618B1 (en) Computerized implementation framework to abstract data object definitions across multiple computing environments
WO2023088313A1 (zh) 输入设备虚拟化的方法、装置、电子设备和存储介质
US20150268982A1 (en) Virtual credential adapter for use with virtual machines
WO2023082716A1 (zh) 在Linux系统中操作安卓应用的方法、装置和设备
WO2023116859A1 (zh) 传感器设备虚拟化的方法、装置、电子设备和存储介质
CN115309511B (zh) 基于Xen的数据交互方法、装置、存储介质以及电子设备
CN113867993A (zh) 虚拟化的rdma方法、系统、存储介质及电子设备
US20220358049A1 (en) Memory access handling for peripheral component interconnect devices
US8886900B2 (en) Legacy data management
WO2023088199A1 (zh) 传感器设备适配的方法、装置、电子设备和存储介质
EP4106293A2 (en) Network configuring method and apparatus for cloud mobile phone, device and storage medium
CN116489177A (zh) 一种基于块存储的io访问方法、装置、电子设备及介质
US20210326150A1 (en) Integrated network boot operating system installation leveraging hyperconverged storage
CN115048060A (zh) 一种存储管理方法、装置、电子设备及存储介质
US20200356538A1 (en) Container-based virtualization for testing database system
US20240291890A1 (en) System and method for managing end point presenting devices
US11797358B2 (en) Method and system for performing application programming interface calls between heterogeneous applications and cloud service providers
US20240256317A1 (en) Systems and methods for backend architecture provisioning and emulation
US11983182B2 (en) System and method to enable a data analytics in a smart data accelerator interface device
US20230081147A1 (en) System and method for a system control processor-controlled partitioning of bare-metal system resources
US20220236913A1 (en) Method and system for efficient servicing of storage access requests

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22910170

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE