WL#11080: Components: implement the minimal chassis

Affects: Server-8.0   —   Status: Complete

Components need only the registry and the dynamic loader to operate.
And whatever services they require.

But right now the minimal chassis is bundled with the server component.
So the line between the two is blurry.

And because of the way the dynamic linkers work it's not hard for component
authors to refer to symbols from the server component by accident since this is
always present. 

This worklog is about separating the server component out of the minimal chassis
and making it a normal component that's loaded into the minimal chassis. 

The minimal chassis is also useful to uncover these dynamic linker references
and prevent them. 

Plus it will allow hosting components that are not the server in a
self-contained executable. 
NFR0: The mysql_server component will be separated from mysqld binary and
it will be a proper component, with all attributes and macros of one,
DEFINE_COMPONENT() etc.
NFR0.1: Note that the mysqld binary will still be a single binary that will
statically link the minimal chassis and the server component.
FR1: registry and dynamic loader services will become a separate static
library that implements the minimal chassis.
FR2: A public API function(so-called bootstrap) exposed by minimal_chassis
library, which will initialize the registry and dynamic loader and returns the
registry pointer.
FR3: The bootstrap function of the minimal_chassis library, will be called only
once by the application.
FR4: A public API function exposed by minimal chassis i.e deinit function, will
de-initialize the registry and dynamic loader initialization stuff. This will be
called once per application, at the application exit time.
FR5: Due to the minimal chassis turning into a library that doesn't depend on
anything the current instrumentation of it in P_S will be removed and the
instrumented calls will be replaced with C library calls.
NFR1: note: After this wl is pushed, any one tries to implement the registry and
dynamic loader services has to use "mysql_minimal_chassis" instead of
mysql_server". And to acquire service, one has to use
"registry.mysql_minimal_chassis" instead of "registry.mysql_server".
NFR2: There will be two implementations of below service in the registry:
"mysql_runtime_error.mysql_minimal_chassis"(while initializing minimal chassis)
and "mysql_runtime_error.mysql_server" (This will be the default service when
the mysql server component is loaded.
The big picture:
----------------
1. Start the application(for example mysql server).
2. Init the minimal chassis.
   the signature looks like minimal_chassis_bootstrap(SERVICE_TYPE(registry) *
*registry, mysql_component_t *component)
   Receive the registry handle as an output parameter.
   pointer to the component as a optional parameter. 
3. install at least one(optionally more) main component (for example
mysql_server component).
4. Create a new runnable service in mysql_server component.
5. deinit the minimal chassis, while in the process of unloading all loaded
components
6. end the application as usual

For #3: We make the minimal chassis init function take a OPTIONAL pointer to a
component structure, so that, if supplied it will satisfy #3. 
This can be used to install the main component(i.e mysql_server component).

For #4: We can define a new service called
"mysql_libminchassis_runnable". This will be implemented in the server component
and registered by it. And the app will refuse to run if it doesn't find at least
one implementation of it (the default) once it loads the main component. Then
the app will simply acquire a reference to mysql_libminchassis_runnable, call
run() and will wait for it to return.
Once it returns, it will release the reference it's got and proceed with the
rest of the steps. This extra reference will also prevent people from unloading
the main component manually. It looks as follows
int main()
{
  registry r = minimal_chassis_bootstrap(SERVICE_TYPE(registry) * *registry,
mysql_component_t *component);
  runnable ru= r->acquire("mysql_libminchassis_runnable");
  status= ru->run();
  r->release(ru);
  minimal_chassis_deinit(r);
  return status;
}
Create a directory components/libminchassis, which will have files to make
minimal_chassis library.

Move below files  form components/mysql_server to the new directory
components/minimal_chassis
registry.cc, registry.h, dynamic_loader.cc, dynamic_loader.h,
dynamic_loader_path_filter.cc, dynamic_loader_path_filter.h,
registry_metadata.cc.inc and registry_metadata.h.inc


mysql_services_bootstrap()
{
   remove registry_init();
   remove dynamic_loader_init();
   remove dynamic_loader_scheme_file_init();
}

minimal_chassis_bootstrap(SERVICE_TYPE(registry) * *registry)
{
   registry_init();
   Load the registry, registry_registration, registry_query,
registry_metadata_enumerate, registry_metadata_query, dynamic_loader,
dynamic_loader_scheme_file, dynamic_loader_query,
dynamic_loader_metadata_enumerate, dynamic_loader_metadata_query and
dynamic_loader_scheme_file services into the registry.
   dynamic_loader_init();
   dynamic_loader_scheme_file_init();
   *registry= registry_handle;
}

Before calling mysql_services_bootstrap() we need to call
minimal_chassis_bootstrap().
minimal_chassis_bootstrap() will give a registry pointer, load the mysql_server
component services into the registry in mysql_services_bootstrap()

minimal_chassis_shutdown()
{
  Shutdowns service registry making sure all basic services of registry and
dynamic_loader are unregistered.
  Will fail if any service implementation is in use.
  shutdown_dynamic_loader();
  registry_deinit();
}

component_infrastructure_deinit()
{
  remove shutdown_dynamic_loader();
  call minimal_chassis_shutdown() at the end.
}

mysql_services_shutdown()
{
  remove registry_deinit();
}

components/mysql_server/CMakeLists.txt
Link the newly created minimal_chassis library to the component_mysql_server
library.

wl testing:
-----------
A test driver will be written, which has a binary running only the minimal
chassis library and holding no references to any other library (mysys, P_S etc).