Skip to content

Commit

Permalink
add another C-wrapper: osv_run_app()
Browse files Browse the repository at this point in the history
In preparation to support building and running ZFS images on
the kernel built with most symbols hidden, this patch adds new
C function - osv_run_app() - that wraps code to run an arbitrary app.
This will allow an application like mkfs.so to be changed to not have to depend
on C++ symbols like osv::run() from OSv kernel.

Refs #1186

Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Jul 7, 2022
1 parent d1d0dd1 commit fa3b38e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/osv_c_wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ void osv_current_app_on_termination_request(void (*handler)()) {
osv::this_application::on_termination_request(handler);
}

extern "C" OSV_MODULE_API
int osv_run_app(const char *app_path, const char *args[], int args_len) {
int ret;
std::vector<std::string> _args(args, args + args_len);
auto ok = run(app_path, _args, &ret);
assert(ok);
return ret;
}

extern bool verbose;
extern "C" OSV_MODULE_API
bool osv_debug_enabled() {
Expand Down
1 change: 1 addition & 0 deletions exported_symbols/osv_module_api.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ osv_get_all_app_threads
osv_get_all_threads
osv_hypervisor_name
osv_processor_features
osv_run_app
osv_version
5 changes: 5 additions & 0 deletions include/osv/osv_c_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ bool osv_debug_enabled();
*/
void osv_current_app_on_termination_request(void (*handler)());

/*
* Start an app and wait until it terminates
*/
int osv_run_app(const char *app_path, const char *args[], int args_len);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit fa3b38e

Please sign in to comment.