Summary of the invention
The purpose of the present invention is intended to for above-mentioned problems of the prior art, provides a kind of based on linux container
Device virtualization system can realize that equipment is multiplexed in more Android platforms based on container technique, especially can be to not having
There is the equipment of open source code to realize virtualization.
Another object of the present invention is intended to provide a kind of device virtualization method based on linux container.
In order to reach the goals above, the present invention is realized using following technical scheme.
The device virtualization system based on linux container that the present invention provides a kind of, suitable for based on linux container
Android virtual platform, including the container management service being arranged under root namespace;Container management service is according to configuration text
Part creates one or more containers, android system is run in each container, while loading virtual device service end;
Android system is provided with HAL;In android system starting, the HAL load virtual unit visitor of the same name with Manufacturer News library
Family end;
Virtual unit client realizes that android system HAL is the interface function that equipment subsystem defines;Virtual unit
Client further comprises first processing module and Second processing module;
Equipment operation request from android system is sent to virtual device service end by first processing module;Equipment
Operation requests include synchronizer operation requests and asynchronous device operation requests;
Second processing module monitors equipment operation result or equipment from virtual device service end and actively submits asynchronous thing
Part, and equipment operation result or equipment will be received actively submit asynchronous event and be submitted to android system;
Virtual device service end realizes that Manufacturer News library readjustment android system HAL corresponds to the interface letter of equipment subsystem
Number;Virtual device service end further comprises third processing module and fourth processing module;
Third processing module monitors the equipment operation request from virtual unit client, and the equipment according to receiving
Operation requests call the equipment operation function in relevant device Manufacturer News library to complete the operation to equipment, or are grasped according to equipment
It requests, constructs equipment operation result;
Fourth processing module sends equipment operation result or the asynchronous event of actively submitting from equipment to virtual unit
Client;
Manufacturer News library, is provided by equipment supplier;Manufacturer News library is that manufacturer's open source dynamic base or manufacturer close source dynamic
Library.
The above-mentioned device virtualization system based on linux container, when request is synchronizer operation requests, the first processing
Synchronizer operation requests from android system are sent to virtual device service end by module, while being responsible for receiving corresponding
The synchronizer operating result of return, and synchronizer operating result is submitted to android system;Alternatively, the first processing mould
Block calls Second processing module, receives the synchronizer operating result accordingly returned, and synchronizer operating result is submitted to
Android system;
When equipment operation result is constructed by third processing module, third processing module is asked according to the equipment operation received
Construction equipment operation is sought as a result, being responsible for construction equipment operation result feeding back to virtual unit client simultaneously;Alternatively, at third
It manages module and calls fourth processing module, construction equipment operation result is fed back into virtual unit client.
The above-mentioned device virtualization system based on linux container is sent to virtual device service in first processing module
End further comprises the function call number set;Function call number and android system HAL interface correspond.
The above-mentioned device virtualization system based on linux container, virtual device service end further comprise request filter module
Block and response filtering module;
Filtering module is requested, according to the request filtering rule of setting, virtual device service end third processing module is received
To equipment operation request be filtered;Virtual device service end decides whether agent operation equipment subsystem according to filter result
System, or construction relevant device operating result;
Filtering module is responded, according to the response filtering rule of setting, intercepts and captures all hardware equipment upwardly through virtual unit
The asynchronous event that server-side fourth processing module is submitted to and its be filtered;Virtual device service end is according to filter result, certainly
It is fixed whether asynchronous event to be sent to virtual unit client.
The above-mentioned device virtualization system based on linux container responds filtering module, is filtered and is advised according to the response of setting
Then, the equipment operation result for influencing two or more virtual unit client is filtered, with reference to sending device operation requests
Information/attribute of virtual unit client, construction equipment operation is as a result, and anti-by virtual device service end fourth processing module
It feeds virtual unit client.
The above-mentioned device virtualization system based on linux container, virtual device service end further realizes Manufacturer News library
The interface function of transmission function pointer and parameter;Call the interface that function pointer and function parameter are passed to void in Manufacturer News library
Quasi- device clients, and then android system HAL is passed to, and under setting condition, function pointer and parameter are completed by HAL
Readjustment.
The device virtualization method based on above system that invention further provides a kind of, android system HAL with set
Virtual unit client and virtual device service end are loaded between standby subsystem;Equipment operation is asked by virtual unit client
It asks and is sent to virtual device service end;Then by the equipment operation function in the calling Manufacturer News library of virtual device service end, reality
Now to the agency of equipment operation, or construction asynchronous device operating result, realize the multiplexing to equipment subsystem, specifically include with
Lower step:
The Android platform based on linux container is initialized, virtual unit client and virtual device service end are loaded;
It will be sent to from the request of the equipment operation of android system upper layer application by virtual unit client and virtually set
Standby server-side;
The equipment operation request from virtual unit client is monitored by virtual device service end, and according to receiving
Equipment operation function in equipment operation request call device manufacturer's dynamic base is completed to equipment operation, is realized to equipment operation
Agency;Alternatively, according to the equipment operation request construction equipment operation received as a result, realizing the multiplexing to equipment subsystem;
The equipment operation result of equipment operation result or construction that agency completes is fed back to by virtual device service end
Virtual unit client;
The equipment operation from virtual device service end is monitored as a result, and setting what is received by virtual unit client
Standby operating result is submitted to android system.
The above-mentioned device virtualization method based on linux container, actively submits asynchronous event for equipment subsystem, passes through
Virtual device service end further sends the asynchronous event of actively submitting from equipment subsystem to virtual unit client;
The equipment from virtual device service end is monitored by virtual unit client and actively submits asynchronous event, and will be connect
The equipment received actively submits asynchronous event and is submitted to android system.
The above-mentioned device virtualization method based on linux container, the equipment for needing function pointer to complete function call
Subsystem, by the way of acting on behalf of to function pointer, Manufacturer News library calls virtual device service end by function pointer and function
Parameter passes to virtual unit client, and then passes to android system HAL;
Under setting condition, function pointer and parameter are sent to virtual device service end, virtual device service end by HAL
By receiving function pointer and parameter, the function in Manufacturer News library is called, the calling of function pointer is completed, is realized to function
The agency of pointer.
The above-mentioned device virtualization method based on linux container, to function pointer agency, the specific implementation steps are as follows:
S1, according to function pointer function prototype present in HAL, call back function is acted on behalf of in the realization of virtual unit client;
The proxy function to android system HAL transmission function pointer is realized at S2, virtual device service end, and by manufacturer
Dynamic base is called, and function pointer and parameter are passed to virtual unit client;
The function pointer received and parameter are saved in memory by S3, virtual unit client, and using current interior
The value for depositing address alternative parameter, as the parameter for acting on behalf of call back function;
S4, virtual unit client are transmitted the parameter for acting on behalf of call back function obtained in call back function and step S3 is acted on behalf of
Give android system HAL;
S5, under setting condition, HAL calling acts on behalf of call back function, acts on behalf of call back function and parses its parameter, obtains the parameter
The function pointer and parameter of pointed memory headroom, are then sent to virtual device service end by HAL;
S6, function pointer and parameter of the virtual device service end to receive call the parameter in Manufacturer News library, complete
The calling of function pointer.
Device virtualization technical solution provided by the invention based on linux container has at least one of following beneficial to effect
Fruit:
(1) it is based on technical solution provided by the invention, it can be in more Android platforms based on linux container technology
Realize the multiplexing of the task equipments (the especially equipment operation function library without open source code) such as Radio;
(2) by loading virtual unit client in multiple android systems in linux kernel and container management service
End and virtual device service end complete to realize device virtualization to the agency of equipment operation, propose one kind and are different from tradition and set
The new method of standby virtual method;
(3) the device virtualization technology provided through the invention can be supported due to requiring no knowledge about device drives source code
A variety of different vendor's equipment avoid needing to provide the cumbersome of virtual hardware equipment for distinct device in traditional virtual method;
(4) multiple android systems can be supported by the virtual device service end of setting simultaneously, improve the utilization of resources
Rate;
(5) for the equipment for needing function pointer to complete function call, the present invention is by virtual device service end and virtually
Device clients can further realize the agency to function pointer, provide extending space to develop more application.
Specific embodiment
Clear, complete description is carried out below with reference to technical solution of the attached drawing to various embodiments of the present invention, it is clear that is retouched
Stating embodiment is only a part of the embodiments of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, originally
Field those of ordinary skill obtained all other embodiment without making creative work, belongs to this hair
Bright protected range.
Device virtualization technical solution provided by the invention, can be applied to the terminal device based on android system, example
Such as smart phone, tablet computer.Technical solution provided by the invention is researched and developed based on android system.Android
System devises a hardware abstraction layer (Hardware between linux kernel and Android framework
Abstraction Layer, abbreviation HAL).HAL is also each module definition one other than defining HAL entirety standard interface
A standard interface, such as the HAL interface of Radio module.The realization of HAL interface function is completed by hardware supplier, generally with
The form of dynamic base is issued.Android HAL is adjusted by the way that these dynamic bases are loaded into the process of corresponding equipment subsystem
Hardware resource is used with equipment operation function therein.
It is difficult in android system using conventional method reality for some current task equipments (such as Radio, Sensor)
The problem of now virtualizing.The present invention is based on agent skill groups, propose a kind of device virtualization system and method, can be suitable for setting
The standby equipment for being driven to not open source code realizes equipment multiplexing, obtains in the place that traditional equipment virtual method is difficult to carry out
Preferable effect.It is pointed out that device virtualization system and method provided by the invention, may be equally applicable for equipment
The equipment for being driven to open source code.
One, the device virtualization system based on linux container
Fig. 1 shows the device virtualization system framework figure based on linux container provided according to embodiments of the present invention.This hair
The device virtualization system 100 based on linux container of bright offer, the container management service including linux kernel is arranged in
101;Container management service 101 creates one or more containers according to configuration file, runs android system in each container
104.The device virtualization system 100 further includes equipment virtual client 105 and equipment component 102.
Virtual unit client 105 is to be loaded by HAL in android system starting, close source dynamic base with manufacturer
103 is of the same name.Can android system a one by one in office be loaded with virtual unit client corresponding with each equipment subsystem
105.Virtual unit client 105 realizes that android system HAL is the interface function that equipment subsystem defines, and according to interface
Function creation dynamic link libraries, in order to dynamically load when system starting.Virtual unit client 105 is equivalent in Android
Virtual equipment corresponding with equipment subsystem, directly interacts with android system HAL106 in system 104.
Virtual unit client 105 further comprises first processing module and Second processing module: first processing module, will
Equipment operation request from android system is sent to virtual device service end 102;Second processing module is monitored from void
The equipment operation result or equipment for proposing standby server-side actively submit asynchronous event, and will receive equipment operation result or equipment
It actively submits asynchronous event and is submitted to android system.Equipment operation request in first processing module includes that synchronizer is grasped
Request (such as device status inquiries operation) and asynchronous device operation requests (such as equipment opening operation).When for synchronizer
When operation requests, sending synchronizer operation requests and reception synchronizer operating result can be used a processing module and has come
At that is, the synchronizer operation requests from android system are sent to virtual device service end by first processing module, simultaneously
It is responsible to receive the synchronizer operating result accordingly returned, and synchronizer operating result is submitted to android system;Here
Second processing module can not be needed.Another kind is achieved in that, is called Second processing module by first processing module, is received
The synchronizer operating result accordingly returned, and synchronizer operating result is submitted to android system.
Virtual device service end 102 is loaded by container management service 101.The load of container management service 101 and each equipment
The corresponding virtual device service end 102 of subsystem.Virtual device service end 102 realizes that manufacturer closes the readjustment of source dynamic base 103
Interface function of the android system HAL for equipment subsystem.It, can be according to these interface functions for the ease of later period application
Dynamic link libraries is created, is loaded when virtual device service end 102 initializes, naturally it is also possible to directly connect such interface function
It is connected to container management service 101.
Virtual device service end 102 further comprises third processing module and fourth processing module: third processing module, prison
Sound the equipment operation request of self-virtualizing device clients, and according to the equipment operation request call relevant device factory received
Quotient closes operation of the completion of the equipment operation function in source dynamic base 103 to equipment, or is requested according to equipment operation, constructs equipment
Operating result;Fourth processing module by the equipment operation result for acting on behalf of the equipment operation result or construction completed or comes from equipment
Asynchronous event of actively submitting send virtual unit client to.Construction equipment operation result include synchronizer operating result and
Asynchronous device operating result.When equipment operation result is constructed by third processing module, constructs synchronizer operating result and incite somebody to action
The synchronizer operating result of construction, which feeds back to virtual unit client, can be used a processing module to complete, i.e., at third
Reason module is according to the equipment operation request construction equipment operation received as a result, being responsible for simultaneously by construction equipment operation result feedback
Give virtual unit client;Here Second processing module can not needed.Another kind is achieved in that third processing module is called
Construction equipment operation result is fed back to virtual unit client by fourth processing module.
Above-mentioned first processing module, Second processing module, third processing module and fourth processing module can use line
The mode of journey is realized.Due to being difficult to realize call between thread, sending synchronizer operation requests and receiving synchronizer behaviour
Make result to realize using same thread;It constructs synchronizer operating result and feeds back the synchronizer operating result of construction
It is similarly realized in same thread to virtual unit client.
Manufacturer closes source dynamic base 103 and is provided by equipment supplier.Here it is lifted with the equipment for closing source dynamic base 103 with manufacturer
Example is illustrated, and is because traditional virtual method cannot achieve to having the virtual of not open source code equipment, and the present invention provides
Device virtualization system the problem of exactly can solve this respect, convenient for illustrating the difference of the present invention with traditional virtual method.
In fact, device virtualization system provided by the invention can also be applied to equipment (i.e. manufacturer's open source dynamic with exploitation source code
Library).
By taking Radio equipment and Sensor equipment as an example, further instruction is provided to the composition of device virtualization system.Such as
Shown in Fig. 2, container management service 101 creates two containers according to configuration file, runs android system in each container,
That is client Android 1 1041 and client Android 2 1042.
Client Android 1 and Radio HAL1061 and Sensor HAL1062 are designed with Android 2.Work as visitor
When family Android 1 starts, load that with Radio manufacturer to close the Radio of the same name of source dynamic base 1031 virtual by Raido HAL1061
Device clients 1051;Load that with Sensor manufacturer to close the Sensor of the same name of source dynamic base 1032 virtual by Sensor HAL1062
Device clients 1052.Client Android 2 also does same processing.
Container management service loads Radio virtual device service corresponding with Radio and Sensor equipment subsystem respectively
Hold 1021 and Sensor virtual device service end 1022.
Detailed explanation is carried out to device virtualization system below with reference to the creation process of device virtualization system.
The creation of device virtualization system mainly includes following procedure:
(1) initialize the Android platform based on linux container technology, the platform initialization the following steps are included:
The starting of 1.1Linux kernel, jumps and executes init process;
1.2init process parses and initializes root namespace, starts container management service 101;
1.3 container management service devices 101 read the preparation file editted in advance, according to appearance to be started in configuration file
Device number parameter determines to create how many a containers, and run in each container android system init process (such as
Android 1 1041 and Android 2 are 1042);
Android system 104 in 1.4 each containers starts to start;Initialization is completed.
Said vesse management service 101 is a finger daemon positioned at root namespace, for being created according to configuration file
One or more containers are built, can be used for initializing and destroying container.
(2) load virtual unit client 105: in 104 start-up course of client's android system, HAL106 adds automatically
Carry with manufacturer close the virtual unit client 105 of the same name of source dynamic base 103 (such as Radio virtual unit client 1051 and
Sensor virtual unit client 1052), start the initialization of Androud system 104 and virtual unit client 105.
By taking Radio equipment subsystem as an example, in 1041 start-up course of Android1, Radio HAL1061 can add automatically
It carries and closes the Radio virtual unit client 1051 of the same name of source dynamic base 1031 with Radio device manufacturer.In order to realize in above-mentioned
Hold, Radio virtual unit client 1051 must realize that Radio HAL1061 is the interface letter that Radio equipment subsystem defines
Number, and dynamic link libraries is created according to interface function, in order to dynamically load when system starting.It is real for Radio equipment
Existing interface function includes that the function in module initialization function RIL_Init and structural body RIL_RadioFunctions refers to
Needle.Function pointer in RIL_RadioFunctions is the interface function for operating Radio equipment.Module initialization function
It is as follows that RIL_Init and structural body RIL_RadioFunctions describes paragraph:
typedef struct{
int version;
RIL_RequestFunc onRequest;
RIL_RadioStateRequest onStateRequest;
RIL_Supports supports;
RIL_Cancel onCancel;
RIL_GetVersion getVersion;
}RIL_RadioFunctions;
Wherein, onRequest corresponds to equipment operation request interface, onStateRequest corresponding states request interface,
Whether supports corresponding requests test interface supports certain request for testing current dynamic base, and the corresponding revocation of onCanel is specified
Request interface, getVersion is corresponding to obtain manufacturer RIL dynamic library version interface.
It realizes above-mentioned interface function, and is compiled into virtual unit client link dynamic base, when for Android1 operation,
Radio HAL1061 dynamically load.
Function pointer in structural body RIL_RadioFunctions operates the interface function of Radio equipment, is process
Between far call client function.This class function needs calling sequence method to handle function parameter, finally according to void
The communication protocol defined between quasi- device clients 105 and virtual device service end 102 is packaged, and is subsequently sent to virtually set
Standby server-side 102;Virtual device service end 102 is also required to carry out unserializing operation to received data after receiving, then
The step of capable of executing below, explaining in detail will hereinafter be provided.
(3) load virtual device service end: virtual device service end 102 is loaded by container management service 101.Container Management
Service 101 loads virtual device service end 102 (such as Radio virtual device service end 1021 for each equipment subsystem
With Sensor virtual device service end 1022).
When client's android system starts, container management service 101 initializes virtual device service end 102, is
(such as Radio is empty at each virtual device service end 102 for client's android system (such as Android 1 and Android 2)
Propose standby server-side 1021 and Sensor virtual device service end 1022) registration virtual unit, it monitors and comes from each android system
Virtual unit client 105 (such as Radio virtual unit client 1051 and Sensor virtual unit client 1052)
Equipment operation request.The initialization at virtual device service end 102 includes initializing to the module itself, and set to hardware
Standby initialization.
Virtual device service end 102 load and initialization manufacturer close source dynamic base 103, to device service carry out using.For
Realize the content, virtual device service end 102 must realize that manufacturer closes source dynamic base 103 and adjusts back android system HAL106
The interface of corresponding equipment subsystem returns to operating result this interface define equipment or actively submits the interface letter of asynchronous event
Number.This interface is realized at virtual device service end 102, is in order to by the equipment operation operating result at virtual device service end 102
Or it actively submits asynchronous event and is submitted to virtual unit client 105.It is noted above, it can be according to these interface functions
Creation connection dynamic base, loads when virtual device service end 102 initializes;Such interface function can certainly directly be connected
It is connected to container management service 101, is further simplified program operation;Or it uses in this field at other similar means
Reason is called convenient for the later period.
By taking Radio equipment subsystem as an example, Radio virtual device service end 1021 need to be realized in structural body RIL_Env
Function pointer.Structural body RIL_Env contains Radio equipment and returns to operating result or actively submit the interface letter of asynchronous event
Number.It is as follows that structural body RIL_Env describes paragraph:
struct RIL_Env{
void(*OnRequestComplete)(RIL_Token t,RIL_Errno e,
void*response,size_t responselen);
void(*OnUnsolicitedResponse)(int unsolResponse,const void*data,
size_t datalen);
void(*RequestTimedCallback)(RIL_TimedCallback callback,
void*param,const struct timeval*relativeTime);
};
Wherein, OnRequestComplete corresponds to asynchronous operation and completes interface, and OnUnsolicitedResponse is corresponding
Asynchronous event submits interface upwards, and RequestTimedCallback corresponds to manufacturer and closes the timing time that source dynamic base is requested to HAL
Adjust interface.
The interface that function pointer in structural body RIL_Evn, i.e. readjustment android system HAL106 correspond to equipment subsystem
Interface function, be the server-side function of far call between process.This class function need calling sequence method to function parameter into
Row processing, is finally sealed according to the communication protocol defined between virtual device service end 102 and virtual unit client 105
Dress, is subsequently sent to virtual unit client 105;Virtual unit client 105 is also required to carry out received data after receiving
Unserializing operation, then can just be submitted to android system 104, explaining in detail will hereinafter be provided.
Fig. 3 shows 102 frame diagram of virtual device service end provided according to embodiments of the present invention, with reference to the accompanying drawing to void
The structure for proposing standby server-side 102 explains.
Container management service 101 is client's android system in each virtual device service end 102 registration virtual unit
Content further comprises that container management service 101 is that the creation of each virtual unit client corresponds at virtual device service end 102
Virtual unit status architecture body.Multiple virtual unit status architecture bodies corresponding with same equipment subsystem constitute virtual unit
Status architecture body array 201.Virtual unit status architecture body is used to store the virtual unit state letter of virtual unit client 105
Breath, and safeguarded by virtual device service end 102.Virtual unit state includes at least to be virtualized in reflection android system
The state of equipment can also include the state etc. of reflection data connection.
By taking Radio equipment subsystem as an example, container management service 101 is that the Radio in Android 1 1041 is virtually set
Radio virtual unit client 1051 in standby client 1051 and Android 1 1042 takes in Radio virtual unit respectively
Business end 1021 creates two virtual unit status architecture bodies, and is safeguarded by Radio virtual device service end 1021.Two void
Quasi- status architecture body constitutes virtual state Array for structural body.
Virtual state structural body is used to record the virtual unit status information of virtual state client 105.For example, container tube
Reason service 101 is that Radio virtual unit client 1051 is created in Android 1 1041 at Radio virtual device service end 1021
Virtual unit status architecture body PerVPData is built, as follows for recording the status information of virtual Radio equipment:
typedef struct{
int radioState;
int screenOnOff;
int dataOnOff;
//...
}PerVPData;
Wherein, radioState corresponds to the open and close state (i.e. virtual unit client state) of Radio, screenOnOff
The open and close state (i.e. android system state) of corresponding screen, the open and close state etc. of dataOnOff corresponding data connection.
In order to improve the working efficiency at virtual device service end 102, virtual device service end 102 is additionally provided with request filtering
Module 202 and response filtering module 203.
Request filtering module 202 connects virtual device service end third processing module according to the request filtering rule of setting
The equipment operation request received is filtered (equipment operation that i.e. virtual unit client 105 is sent is requested) and is filtered;It is empty
It proposes standby server-side 102 and agent operation equipment subsystem is decided whether according to filter result, or request structure according to equipment operation
Make respective synchronization/asynchronous device operating result.
Filtering module 202 is requested, is responsible for the equipment operation sent to virtual unit client 105 request and is filtered.Please
Ask filtering module 202 can be with reference to all virtual unit states being placed in virtual unit status architecture body array, according to what is formulated
Filtering rule is requested, filter result is provided;Virtual device service end 102 is according to filter result, to setting in equipment operation request
Standby operation is arbitrated, and then decides whether to operate hardware device again.
The request filtering rule used in the present embodiment is as follows:
2.1 request for that may change the equipment operation of real equipment state or virtual unit state, such as equipment
The operation such as open and close can be handled according to the determination strategy formulated.By taking equipment open and close operation as an example, more commonly used judgement plan
Slightly it is: (1) only virtual in android system involved in all virtual unit status architecture bodies for the request of pass hull closure
The state for changing equipment is in closed state, and the request of pass hull closure is acted on behalf of at virtual device service end 102, pass hull closure, and same
When by virtual unit state update be in off state;Otherwise virtual device service end construction is turned off the asynchronous device operation of equipment
As a result, simultaneously the update of virtual unit state is in off state simultaneously;(2) for the request of opening equipment, as long as there is a request
Equipment is opened, just agency opens the request of equipment, and is updated to open by virtual unit state simultaneously.
2.2 for monopolizing the equipment operation of class, such as makes a phone call, and is requested by virtual device service end 102 according to sending
Current android system be in foreground and still arbitrated from the background, decide whether to carry out equipment operation agency;Currently
When android system is in foreground, virtual device service end proxy device operation (such as making a phone call);Current Android system
When system is in backstage, the refusal of virtual device service end 102 is background proxy, while constructor failure asynchronous device operation is tied
Fruit.
2.3 for status inquiry class equipment operation, and virtual device service end 102 directly will be in virtual unit status architecture body
Virtual unit state be configured to synchronizer operating result return.
2.4 act on behalf of other types of equipment operation apart from the above, virtual device service end 102.
From it is above-mentioned to request filtering module 202 analysis it can be seen that
(1) for situation involved in filtering rule 2.1, regardless of whether virtual device service end 102 carries out equipment operation
Agency;It is both needed to request to be updated corresponding virtual unit state according to equipment operation;
It (2) can be with reference device operation requests and HAL for the asynchronous device operating result of construction involved in filtering rule
In the interface that defines for equipment subsystem be designed;
(3) virtual device service end 102 can not only realize the agency to equipment operation, and can be according to not sympathizing with
Condition constructs equipment operation as a result, equipment operation is virtualized, realizes the multiplexing of equipment subsystem;Realize answering for equipment subsystem
With can make equipment operation not influences the operation that real equipment corresponds to other virtual unit clients.
It will be appreciated by those skilled in the art that request filtering rule given above, is merely illustrative of, request is filtered
The effect of module carries out in detail, not having any restriction effect to the present invention.Those skilled in the art completely can be in this hair
Under bright guiding theory, filtering rule is modified slightly to reach other purposes.Therefore, this hair also can not surpassed to the modification of filtering rule
Bright protection scope.
Filtering module 203 is responded, according to the response filtering rule of setting, intercepts and captures all hardware equipment upwardly through virtually setting
Asynchronous event that standby server-side fourth processing module is submitted simultaneously is filtered it;It is tied according to filtering at virtual device service end 102
Fruit decides whether for asynchronous event to be sent to virtual unit client 105.
Asynchronous event is directed in the present embodiment, the response filtering rule of use is as follows:
3.1 setting configuration strategies carry out the event that each virtual unit client 105 can receive according to strategy
Setting.
In the present embodiment, rule of thumb data, are classified asynchronous event, are broadly divided into conventional asynchronous event, set
Standby state class asynchronous event and other asynchronous events.Conventional asynchronous event is mainly the higher asynchronous event of occurrence frequency, example
It such as receives calls, short message prompting, the prompting of qq prompting message, wechat.It is not high that other asynchronous events are primarily referred to as occurrence frequency
Asynchronous event.Above-mentioned classification be not it is absolute, can be adjusted whenever necessary according to the variation of occurrence frequency.For normal
Asynchronous event is advised, configuration strategy is usually used.
It is reminded for example, definition only has client Android 1 1041 to can receive incoming call/short message, and other clients
Android can only use the function (such as data connection function) except this.
3.2 notify class event, such as the message of mark opening of device, closed state for equipment state, it is necessary to reference pair
The virtual unit state of virtual unit client 105 is answered to be filtered it, if not setting with the virtual of virtual unit client 105
Equipment state notice class event is just sent to virtual unit client 105, otherwise not responded by standby state conflict.It cannot allow
Virtual unit client 105 receives the state notifying event to conflict with oneself state.
3.3 are filtered other events, setting default filtering rule to them.For example, default rule can be set
Are as follows: default is sent to all virtual unit clients 105, or default is merely sent to the virtual unit that equipment is open state
Client 105.
For the asynchronous device operating result after the proxy device operation of virtual device service end, responding filtering module 203 can
Not to be filtered to all asynchronous device operating results, and it is filtered just for response in need, such as influence
The asynchronous device operating result needs of two or more virtual unit client are filtered.It is established as with data channel process
Example, the Radio virtual unit client 1051 of client Android 1 1041 initiate data channel and establish request, and radio is virtual
Device service end 1021 is requested according to equipment operation, proxy device operation, and response (the equipment operation knot that real equipment returns
Fruit) it include the network informations such as IP address, gateway information that real equipment obtains at operator;But it after introducing virtualization, deposits
In multiple virtual unit clients, necessarily using the respectively different network informations, therefore needed herein to equipment operation result
It is filtered.With reference to information/attribute of Radio virtual unit client 1051, the reasonable asynchronous device operation knot of construction one
Fruit (includes virtual ip address and gateway information), returns to the Radio virtual unit client 1051 of Android 1 1041, builds
Data between the Radio virtual unit client 1051 and Radio virtual device service end 1021 of vertical Android 1 1041
Channel.Number between the Radio virtual unit client 1051 and Radio virtual device service end 1021 of Android 1 1041
According to Path Setup method, those skilled in the art can be established using conventional means.
From it is above-mentioned to response filtering module 203 analysis it can be seen that
(1) by filtering rule 3.2, the event to conflict with virtual unit client state can be filtered out, is guaranteed each
The state that virtual unit client receives is compared with the state that itself is in matches;
(2) by filtering rule 3.1 and 3.3, can be improved asynchronous event distributes efficiency;
(3) to the asynchronous device operating result for influencing two or more virtual unit client, virtual device service end 102
With reference to information/attribute of sending device operation requests virtual unit client, asynchronous device operating result is constructed, this is further
Embody the virtualization effect of system in the application.
It will be appreciated by those skilled in the art that response filtering rule given above, is merely illustrative of, response is filtered
The effect of module carries out in detail, not having any restriction effect to the present invention.Those skilled in the art completely can be in this hair
Under bright guiding theory, filtering rule is modified slightly to reach other purposes.Therefore, this hair also can not surpassed to the modification of filtering rule
Bright protection scope.
Two, equipment operation is acted on behalf of and realizes device virtualization
The creation process of the above bonding apparatus virtualization system, is described in detail device virtualization system.Under
It is acted on behalf of in face of equipment operation and realizes that the process of device virtualization is described in detail.
Before being illustrated to device virtualization implementation, need first to the sequencing method that is used in the present embodiment and anti-
Sequencing method explains.Present invention introduces serializing and unserializing functions, at the parameter of remote function calls
Reason, by Parameter Switch at the form that can store or transmit.The present invention has used for reference the thought of conventional sequence and unserializing, right
Each parameter carries out serializing processing, and guarantee all saves the relevant all information of the parameter, it is sufficient in new process
The parameter is reconstructed in space.
1, sequencing method:
It is input that function, which is serialized, with function parameter and buffer area, and according to data type, construction sends buffer area.For remote
Journey calls function parameter, and serializing operating procedure is as follows:
The value of parameter p is copied to transmission buffer area by 4.1;
4.2 judge parameter p whether pointer, if not being to jump to step 4.6;
P is directed toward memory shared by type T by 4.3 copies to transmission buffer area;
Whether 4.4 judge in type T to be structural body type, if not being to jump to step 4.6;
Each of 4.5 couples of structural body T member variable, jumps to step 4.1 and is investigated;
4.6 processing terminate.
For the buffer area that remote function call parameter is constituted, the serialisation step is as follows:
Buffer contents are copied to transmission buffer area by 4.7.
The data of 4.8 pairs of buffer areas storage, jump to 4.1 and are handled.
The serializing of 4.9 buffer datas terminates.
2, unserializing method:
The input of unserializing is consistent with serializing function, but the purpose is to the buffer area progress to parameter and parameter composition
Reconstruct.Unserializing operating procedure is as follows:
5.1 judge that the type of parameter p, structural body type in this way then jump to step 5.2;Pointer type in this way, then jump
To step 5.3;Otherwise step 5.6 is jumped to.
5.2 for structural body p all members, jump to step 5.1 and handled.
5.3 judge the value of p, if value is NULL, jump to step 5.6.
P is assigned a value of pointed type in the address in current process space by 5.4.
5.5 judge whether p is structural body pointer type, if so, jumping at the structural body that step 5.2 is directed toward p
Reason.
5.6 parameter unserializings terminate.
For buffer area, specific step is as follows for unserializing:
5.7 store data type according to the information such as HAL standard interface, analysis buffers.To all data in buffer area
Type jumps to step 5.1 and is handled.
5.8 buffer area unserializings terminate.
Serializing operation and unserializing operation are the conventional means of this field, be can be completed for not needing serializing
Data transmission, those skilled in the art, which can choose, does not serialize data, and directly transmits, such as binary data
Deng.
After multiple android systems start on the same hardware platform, the problem of equipment is multiplexed can be faced, to understand
Certainly secondary problem, the present invention realize device virtualization using agent skill group, propose a kind of device virtualization based on linux container
Method loads virtual unit client 105 and virtual device service end 102 between android system HAL and equipment subsystem;
Equipment operation request is sent to virtual device service end 102 by virtual unit client 105;Then by virtual device service
End 102 calls manufacturer to close the equipment operation function in source dynamic base 103, realizes the agency to equipment operation, or construction equipment
Operating result realizes the multiplexing to equipment subsystem, and Fig. 4 shows the device virtualization method flow diagram based on linux container,
The following steps are included:
A1 initializes the Android platform based on linux container, loads virtual unit client 105 and virtual unit clothes
Business end 102;
A2 will be sent to by virtual unit client 105 from the request of the equipment operation of android system upper layer application
Virtual device service end 102;
A3 monitors the equipment operation from virtual unit client 105 by virtual device service end 102 and requests, and root
The equipment operation function in source dynamic base 103 is closed according to the equipment operation request call device manufacturer received, completes to grasp equipment
Make, realize to the agency of equipment operation;Alternatively, according to the equipment operation request construction equipment operation received as a result, realization pair
The multiplexing of equipment subsystem;
A4, the equipment operation result of the equipment operation result or construction of being completed agency by virtual device service end 102
Feed back to virtual unit client 105;
A5 monitors the equipment operation from virtual device service end 102 as a result, and will connect by virtual unit client 105
The equipment operation result received is submitted to android system.
For step A1, detailed description is had been given in the device virtualization system creation process of front, no longer superfluous here
It states.
The purpose of step A2 is to request to be sent to virtually by virtual unit client 105 by HAL interface by equipment operation
The interface function of 105 dynamic link libraries of virtual unit client is called at device service end 102, specifically, HAL106, and equipment is grasped
It requests to pass to virtual device service end 102 in the form of function call.
The agency of HAL interface is defined in virtual unit public head file further according to HAL interface for convenience
Function call number, function call number and the function in HAL interface correspond, while also closing in source dynamic base 103 with manufacturer
Equipment operation function correspond.The function call and function parameter is sent to virtual device service end 102 together.
The realization of above-mentioned steps A2, further comprise it is following step by step:
A21 is requested according to the equipment operation of android system upper layer application, and HAL is called in virtual unit client 105
Interface function;
By taking Radio equipment as an example, equipment operation request is interface function onRequest, and will be in fact at present first
Module is managed, function prototype is as follows:
typedef void(*RIL_RequestFunc)(int request,void*data,size_t datalen,
RIL_Token t);
Wherein request is equipment operation request number, represents specific equipment operation;Data and datalen is constituted interior
Deposit parameter needed for space contains equipment operation;T is then the handle for identifying equipment operation.
Function parameter is carried out serializing processing by A22,105 first processing module of virtual unit client;Serializing operation
It is referred to the sequencing method that front provides;
It is then in interface function onResquest, it carries out sequence to 4 parameters of oneself for Radio equipment
Columnization processing.
A23, the number for being saved function call number and serializing processing by 105 first processing module of virtual unit client
According to being sent to virtual device service end 102;Communication protocol between virtual unit client 105 and virtual device service end 102
It can be defined according to the conventional means of this field;By taking Radio equipment as an example, Radio virtual unit client 1051 can be with
It sends the function call number of corresponding onRequest itself and serializing treated data to by a transmission function
Radio virtual device service end 1021.
The purpose of step A3 is that virtual device service end 102 calls manufacturer to close source according to the equipment operation request received
Equipment operation function in dynamic base 103 is completed to equipment operation, is realized to the agency of equipment operation;Alternatively, according to receiving
Equipment operation request construction synchronous/asynchronous equipment operation as a result, realizing multiplexing to equipment subsystem.
The realization of above-mentioned steps A3, as shown in figure 5, further comprise it is following step by step:
A31 is monitored at virtual unit client 105 first by 102 third processing module of virtual device service end
Manage the equipment operation request of module;
A32, when receiving equipment operation request, 102 third processing module of virtual device service end extracts function call
Number, and antitone sequence method reconstruction of function parameter is used, it is allowed to effective in current process space;Then equipment operation is requested to be added
Waiting list waits the processing at virtual device service end.The unserializing method that unserializing operation can be provided using front.
For above-mentioned Radio equipment, i.e., function call number is extracted at Radio virtual device service end 1021, and utilizes inverted sequence
Columnization operation is reconstructed parameter to obtain 4 parameters.
A33,102 third processing module of virtual device service end carry out equipment operation secondary with reference to virtual unit state
It cuts out, decides whether to act on behalf of equipment operation representated by function call number obtained by step A31;If being acted on behalf of, into step
Rapid A34;If entering step 35 without agency;
For Radio equipment, i.e., parameter request is arbitrated.It can be according to request filtering rule, by requested
It filters module and action type is judged according to parameter request, if operation influences real equipment state or virtual unit state, or
Whether it is the equipment operation for monopolizing class, equipment operation request is filtered using request filtering module, Radio virtual unit clothes
End 1021 be engaged according to filter result, decides whether to act on behalf of equipment operation.
A34,102 third processing module of virtual device service end call manufacturer to close source using function call number and function parameter
Corresponding equipment operation function in dynamic base 103 is completed to equipment operation.
For Radio equipment, according to function call number, another is called, manufacturer is implemented in and closes connecing in source dynamic base 103
Then mouth function onRequest completes equipment operation using 4 parameters that step A32 is obtained.
A35, the equipment operation for that can not carry out agency are requested, the reference of 102 third processing module of virtual device service end
Equipment operation request, constructs corresponding synchronous/asynchronous equipment operation result.
Equipment operation for that can not carry out agency is requested, and several situations are included at least: (1) device status inquiries operation is asked
It asks;(2) operation requests of real equipment state or virtual unit state are influenced;(3) android system is in the exclusive class on backstage
Operation requests.
For situation (1), 102 third processing module of virtual device service end is using in respective virtual equipment state structural body
Virtual unit state construct synchronizer operating result.Then will serializing treated that synchronizer operating result is fed back to
105 first processing module of virtual unit client or Second processing module.For Radio equipment, Radio virtual unit client
1051 calling interface function onStateRequest, Radio virtual device service ends 1021 are inquiring respective virtual Radio knot
In structure body after the value of parameter radiostate, serializing processing will be done to the value, thereafter as the return of onStateRequest
Value is fed directly to Radio virtual unit client 1,051 the by 1021 third processing module of Radio virtual device service end
One processing module or Second processing module.
For situation (2), with reference to virtual unit state in virtual unit status architecture body, construction does not influence other virtually to set
The equipment operation result of standby client operation.Then by function call number and serializing, treated that asynchronous device operating result is anti-
105 Second processing module of virtual unit client of feeding.For Radio equipment, when shutoff operation request not with virtual unit
When all virtual unit state consistencies in status architecture body array, the operation of pass hull closure cannot be implemented, construction equipment is closed
Asynchronous device operating result, using equipment close be used as parameter calling interface function OnRequestComplete, general
The parameter of OnRequestComplete is serialized;Then will function call number corresponding with OnRequestComplete and
Treated that data pass through 1021 third processing module of Radio virtual device service end or fourth processing module together for serializing
Feed back to 1051 Second processing module of Radio virtual unit client;It virtually sets the virtual unit client is corresponding simultaneously
Standby state is updated to close.
For situation (3), since android system is in backstage, background proxy behaviour is refused at virtual device service end 102
Make, therefore the direct constructor in virtual device service end 102 failure asynchronous device operating result.Then by function call number and sequence
Treated that asynchronous device operating result feeds back to 105 Second processing module of virtual unit client for columnization.Radio is set
It is standby, will be as parameter, calling interface function OnRequestComplete after asynchronous device operating result construction, it will
Its parameter carries out serializing processing;Then by function call number and serializing, treated that data pass through Radio together virtually sets
Standby 1021 third processing module of server-side or fourth processing module feed back to 1051 second processing of Radio virtual unit client
Module.
After the completion of step A31~A35, from a procedural view, it is equivalent to and has been completed to the agency of equipment operation or right
The multiplexing of equipment subsystem.As can be seen from the above analysis, in device virtualization method provided by the invention, there is no use
Virtual machine is arranged in the method for analog machine, but completes above-mentioned task with the virtual device service end of setting.Pass through this side
Formula requires no knowledge about device drives source code, can support a variety of different vendor's equipment, avoids needing needle in traditional virtual method
The cumbersome of virtual hardware equipment is provided to distinct device.
The purpose of step A4 is that equipment operation result is fed back to virtual unit client by virtual device service end 102
105 first processing modules or Second processing module.Generally, equipment operation structure is returned there are two types of mode: for time-consuming few
Equipment is operated, the design specification of android system is usually followed, equipment operation result is immediately returned to android system
105 first processing module of virtual unit client (when first processing module can receive synchronizer operating result simultaneously) or
Two processing modules (when first processing module completes the reception to synchronizer operating result in the form of calling), such as equipment state
Inquiry operation (has been given) in step A35;And remaining most time-consuming more equipment operations (are primarily referred to as by void
Propose the equipment operation that the standby agency of server-side 102 completes), equipment operation result returns to virtual unit in a manner of asynchronous message
105 Second processing module of client.It is noted above, when equipment operation result is constructed by third processing module, virtually set
Standby 102 third processing module of server-side can be according to the equipment operation request construction equipment operation result received;It is responsible for simultaneously
It is fed back to virtual unit client 105;And the part step A35 has described in detail through virtual device service end 102
The equipment operation result of construction feeds back to the process of virtual unit client 105, therefore step A4 relevant portion is here no longer
It explains.
Certainly, third processing module can also call fourth processing module to feed back to the equipment operation result of construction virtually
Device clients 105.In this case, fourth processing module, the equipment operation result according to construction are that parameter calls readjustment
The interface function of HAL;The parameter of interface function is subjected to serializing processing;Then by function call number and serializing, treated
Data pass through 102 fourth processing module of virtual device service end together and feed back to 105 second processing of Radio virtual unit client
Module.
Equipment operation result after the completion of acting on behalf of for virtual device service end 102 is returned in a manner of asynchronous message virtually to be set
The case where standby 105 Second processing module of client, further comprise it is following step by step:
A41, manufacturer, which closes source dynamic base 103, calls and is implemented in the readjustment HAL interface at virtual device service end 102, to virtual
Device clients 105 return to asynchronous operation result.
It is then that manufacturer closes source dynamic base 103 and uses asynchronous operation result as parameter calling interface letter for Radio equipment
Number OnRequestComplete.
Equipment operation result is carried out serializing processing by A42,102 fourth processing module of virtual device service end;Serializing
Operation is referred to the sequencing method that front provides.
For Radio equipment, the parameter of OnRequestComplete preserves equipment operation as a result, will
The parameter of OnRequestComplete is serialized.
The data that serializing processing saves are sent virtual unit by A43,102 fourth processing module of virtual device service end
105 Second processing module of client.
It is exactly that 1021 fourth processing module of Radio virtual device service end will be with for Radio equipment
The data that the corresponding function call number of OnRequestComplete and serializing processing save are sent to Radio virtual unit visitor
Family end 1051.
Comparison step A4 also relates to a kind of special circumstances, i.e., influence two or more virtual unit client 105 is different
Equipment operation is walked as a result, processing for such request, has explained in detail when introducing and responding filtering module 203.For this
Kind of situation, 102 fourth processing module of virtual device service end need to first pass through after step A41 response filtering module 203 into
Row filtering, then according to filter result, with reference to information/attribute of sending device operation requests virtual unit client, construction one
A reasonable equipment operation is as a result, feed back to virtual unit client for equipment operation result according still further to step A42, A43 mode
105。
The purpose of step A5 is that equipment operation result is further fed back to Android system by virtual unit client 105
System.Since the data that virtual unit client 105 initially receives are to be serialized, need to carry out antitone sequence operation to it,
It is allowed to effective in current process space;The unserializing method that unserializing operation can be provided using front.Virtual unit visitor
Client's android system is given the data delivery obtained after unserializing to again in family end 105.
In addition to the equipment operation access that android system upper layer application is actively initiated, some hardware devices are also oriented
Android system actively submits the demand of asynchronous event, such as Radio equipment needs that android system is notified to have phone arrival.
In the present embodiment, asynchronous event is sent to virtual unit client 105 by virtual device service end 102, then by
Virtual unit client 105 is submitted to android system, specific operation process with submit the similar of equipment operation result, including
Below step by step:
B1, manufacturer, which closes source dynamic base 103, calls and is implemented in the readjustment HAL interface at virtual device service end 102, to virtually setting
Standby client 105 submits asynchronous event.
It is then that manufacturer closes source dynamic base 103 and uses asynchronous event as parameter calling interface function for Radio equipment
RIL_onUnsolicitedResponse。
B2 needs the asynchronous event responded to carry out with reference to each virtual unit state by 203 pairs of filtering module of response
Filter;102 fourth processing module of virtual device service end is according to filter result, it is determined whether it is virtual that asynchronous event is distributed to this
Corresponding 105 Second processing module of virtual unit client of equipment.
It in step bl is determined, can be according to response filtering rule, using response filtering module to all hardware equipment of intercepting and capturing
The asynchronous event submitted upwards is filtered, and 102 fourth processing module of virtual device service end decides whether according to filter result
The event is distributed to 105 Second processing module of virtual unit client.By the response filtering module of setting, can be improved different
Step event distributes working efficiency, and virtual unit client 105 is avoided to receive the event with itself virtual unit state conflict,
Guarantee state that each virtual unit client receives compared with the state that itself is in etc..
For example, for Radio equipment, if certain virtual unit is in close state, corresponding virtual unit
Client cannot receive any event disagreed with its state, such as signal strength event.So respond filtering module
It needs to filter out such asynchronous event.
Asynchronous event is carried out serializing processing by B3,102 fourth processing module of virtual device service end;Serializing operation can
With the sequencing method provided referring to front.
For Radio equipment, i.e., the argument sequenceization of interface function RIL_onUnsolicitedResponse is handled.
B4,102 fourth processing module of virtual device service end send out the data that function call number and serializing processing save
It is sent to 105 Second processing module of virtual unit client.
For Radio equipment, i.e. Radio virtual device service end 1021 will be with RIL_onUnsolicitedResponse
Treated that data are sent collectively to Radio virtual unit client 1051 for corresponding function call number and serializing.
B5 is monitored by 105 Second processing module of virtual unit client and is come from 102 fourth process mould of virtual device service end
The asynchronous event of block, and the asynchronous event received is submitted to android system.
The purpose of step B5 is that asynchronous event is further fed back to android system by virtual unit client 105.By
It is to be serialized in the data that virtual unit client 105 initially receives, needs to carry out antitone sequence operation to it, be allowed to
It is effective in current process space;The unserializing method that unserializing operation can be provided using front.Virtual unit client
105 give the data delivery obtained after unserializing to client's android system again.
Equipment operation request and equipment operation in the present embodiment is the result is that by the unified setting of device manufacturer.In the present invention
Cited equipment operation request and equipment operation result are only for the purpose of illustration, refer in particular to there is no any, this field skill
Art personnel completely can be different according to used equipment, replaced accordingly, and this replacement can not be beyond the present invention
Protection scope.
Three, proxy function pointer
Above for be the most equipment operations faced in general terminal device, and for some equipment grasp
Make, is then the calling for needing function pointer that could complete to close function in the dynamic base of source from manufacturer, realizes equipment operation.It is directed to
Such situation, manufacturer close the meeting calling interface of source dynamic base 103, submit a function pointer and parameter to Android HAL106,
So that HAL106 in due course can adjust back the function pointer.
And for function pointer, substantially only function entrance address cannot carry out memory as General Parameters and copy
Shellfish, therefore cannot be serialized and unserializing, the present embodiment provides a kind of function pointer Proxy Method, can make to be present in remote
Function pointer in eikonal number call parameters can performed effectively distally.
If Android HAL106 has similar following function prototype:
void RIL_requestTimedCallback(RIL_TimedCallback callback,
void*param,const struct timeval*relativeTime);
When using device virtualization scheme of the present invention, just have following function calling relationship: manufacturer closes source
The proxy function RIL_requestTimedCallback that dynamic base 103 calls virtual device service end 102 to realize refers to function
Needle (callback) and function parameter (arg) are transmitted to virtual unit client 105, and then pass to Android HAL106,
HAL106 in due course adjusts back function pointer (callback).For the agency of function pointer, can be passed through
One processing module, Second processing module, third processing module and fourth processing module realize, can also be for function pointer
Corresponding processing module is separately provided in virtual unit client and virtual device service end respectively in special circumstances.
Fig. 6 shows function pointer Proxy Method flow chart.In specific implementation, the function that the present embodiment uses refers to
Needle agent operation the following steps are included:
S1, according to function pointer prototype present in HAL106, call back function is acted on behalf of in the realization of virtual unit client 105.
In the present embodiment, according to above-mentioned function prototype RIL_requestTimedCallback, virtual unit client 105 is real
An existing function callback_proxy.
The proxy function to android system HAL transmission function pointer is realized at S2, virtual device service end 102, and by factory
Quotient closes the calling of source dynamic base 103, and function pointer and parameter are passed to virtual unit client 105.In the present embodiment, virtually set
The proxy function that standby server-side 102 is realized is requestTimedCallback_proxy;Manufacturer closes the calling of source dynamic base 103
The proxy function requestTimedCallback_proxy at virtual device service end 102, by the parameter in addition to function pointer
Arg carries out serializing processing, and then by function call number, function pointer and serializing, treated that data pass to virtually together
Device service end 105.This process can be complete in the fourth processing module at virtual device service end 102 or individual processing module
At.
The function pointer received and parameter are saved in memory by S3, virtual unit client 105, and using current
The value of memory address alternative parameter, as the parameter for acting on behalf of call back function.In the present embodiment, 105 basis of virtual unit client
Function call number calling acts on behalf of call back function callback_proxy, and carries out unserializing processing to the data received and reconstruct
The function pointer callback same parameter arg received is saved in memory, and is replaced using current memory address by parameter
Arg original value, as the parameter arg_proxy for acting on behalf of call back function callback_proxy;Here callback_proxy
It is responsible for function reading pointer and parameter arg from the memory headroom that parameter arg_proxy is directed toward.This process can be in virtual unit
The Second processing module of client 105 or individual processing module are completed.
S4, virtual unit client 105 act on behalf of the parameter of call back function by acting on behalf of obtained in call back function and step S3
Pass to android system HAL106.In the present embodiment, by the parameter in function pointer callback_proxy and step S3
Arg_proxy passes to Android HAL106;This process can virtual unit client 105 Second processing module or
Individual processing module is completed.
S5, under setting condition, HAL106 calling acts on behalf of call back function, acts on behalf of call back function and parses its parameter, is somebody's turn to do
The function pointer and parameter of memory headroom pointed by parameter, are then sent to virtual device service end by HAL.The condition of setting can
It with depending on the specific requirement of distinct device, such as sets at regular intervals, HAL106 just adjusts back linear function pointer.This
In embodiment, when HAL106 call back function pointer, HAL106 calls function callbank_proxy, function callbank_
Proxy analytic parameter arg_proxy obtains the function pointer callback and ginseng of memory headroom performed by parameter arg_proxy
Number arg;Parameter arg is carried out serializing processing by virtual unit client 105, then by function pointer callback and serializing
Data that treated are sent collectively to virtual device service end 102.This process can be at the first of virtual unit client 105
It manages module or individual processing module is completed.
S6, function pointer and parameter of the virtual device service end 102 to receive call manufacturer to close in source dynamic base 103
Function, complete the readjustment of function pointer.In the present embodiment, virtual device service end 102 receives the generation of callback_proxy
Reason request, does function pointer with the callback received, arg does parameter, completes the readjustment of function pointer;Then further according to letter
Number pointer and parameter call manufacturer to close the function in source dynamic base 103, complete subsequent operation.This process can be in virtual unit visitor
The third processing module at family end 105 or individual processing module are completed.
For different equipment, the purpose of call back function pointer is not identical, and specific effect is also different because of equipment.At this
As long as can be realized the purpose of function pointer readjustment in invention.
In conclusion the device virtualization technology based on linux container provided through the invention, can be realized to equipment
The agency of operation and function pointer can make a variety of task equipments such as Radio realize multiplexing, difficult in traditional equipment virtual method
Preferable effect is achieved with the place of implementation.
Those of ordinary skill in the art will understand that the embodiments described herein, which is to help reader, understands this hair
Bright principle, it should be understood that protection scope of the present invention is not limited to such specific embodiments and embodiments.This field
Those of ordinary skill disclosed the technical disclosures can make according to the present invention and various not depart from the other each of essence of the invention
The specific variations and combinations of kind, these variations and combinations are still within the scope of the present invention.