2005-08-23 13:31:32 +02:00
|
|
|
/* Utility to start or stop system services. Requests are sent to the
|
|
|
|
* reincarnation server that does the actual work.
|
|
|
|
*
|
|
|
|
* Changes:
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
* Nov 22, 2009: added basic live update support (Cristiano Giuffrida)
|
|
|
|
* Jul 22, 2005: Created (Jorrit N. Herder)
|
2005-08-23 13:31:32 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
#include <stdarg.h>
|
2007-01-22 16:25:41 +01:00
|
|
|
#include <assert.h>
|
2005-08-02 18:00:07 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2006-10-20 17:01:32 +02:00
|
|
|
#include <pwd.h>
|
2006-05-11 17:30:56 +02:00
|
|
|
#include <unistd.h>
|
2009-09-21 16:49:04 +02:00
|
|
|
#include <limits.h>
|
2010-01-25 15:22:09 +01:00
|
|
|
#include <lib.h>
|
2005-08-02 18:00:07 +02:00
|
|
|
#include <minix/config.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/type.h>
|
|
|
|
#include <minix/ipc.h>
|
2006-10-20 17:01:32 +02:00
|
|
|
#include <minix/rs.h>
|
2005-08-02 18:00:07 +02:00
|
|
|
#include <minix/syslib.h>
|
2008-12-11 15:43:53 +01:00
|
|
|
#include <minix/sysinfo.h>
|
2009-09-21 16:49:04 +02:00
|
|
|
#include <minix/bitmap.h>
|
2009-10-14 09:20:13 +02:00
|
|
|
#include <minix/paths.h>
|
2010-04-08 15:41:35 +02:00
|
|
|
#include <minix/sef.h>
|
2010-04-09 23:56:44 +02:00
|
|
|
#include <minix/dmap.h>
|
2005-08-02 18:00:07 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2006-10-20 17:01:32 +02:00
|
|
|
#include <configfile.h>
|
2005-08-02 18:00:07 +02:00
|
|
|
|
2010-07-01 10:32:33 +02:00
|
|
|
#include <machine/archtypes.h>
|
|
|
|
#include <timers.h>
|
|
|
|
#include "kernel/proc.h"
|
|
|
|
|
2005-08-23 13:31:32 +02:00
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* This array defines all known requests. */
|
|
|
|
PRIVATE char *known_requests[] = {
|
|
|
|
"up",
|
|
|
|
"down",
|
2005-10-20 22:31:18 +02:00
|
|
|
"refresh",
|
2006-10-20 17:01:32 +02:00
|
|
|
"restart",
|
2005-10-12 17:07:38 +02:00
|
|
|
"shutdown",
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
"update",
|
2010-06-28 23:38:29 +02:00
|
|
|
"clone",
|
2010-07-05 21:37:08 +02:00
|
|
|
"edit",
|
2005-08-02 18:00:07 +02:00
|
|
|
"catch for illegal requests"
|
|
|
|
};
|
|
|
|
#define ILLEGAL_REQUEST sizeof(known_requests)/sizeof(char *)
|
|
|
|
|
|
|
|
/* Global error number set for failed system calls. */
|
|
|
|
#define OK 0
|
2006-10-31 14:35:04 +01:00
|
|
|
|
|
|
|
#define RUN_CMD "run"
|
|
|
|
#define RUN_SCRIPT "/etc/rs.single" /* Default script for 'run' */
|
2010-07-01 20:48:25 +02:00
|
|
|
#define SELF_BINARY "self"
|
|
|
|
#define SELF_REQ_PATH "/dev/null"
|
2009-12-17 02:53:26 +01:00
|
|
|
#define PATH_CONFIG _PATH_SYSTEM_CONF /* Default config file */
|
2010-04-08 15:41:35 +02:00
|
|
|
#define DEFAULT_LU_STATE SEF_LU_STATE_WORK_FREE /* Default lu state */
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
#define DEFAULT_LU_MAXTIME 0 /* Default lu max time */
|
2005-08-02 18:00:07 +02:00
|
|
|
|
2010-04-09 23:56:44 +02:00
|
|
|
/* Define names for options provided to this utility. */
|
|
|
|
#define OPT_COPY "-c" /* copy executable image */
|
|
|
|
#define OPT_REUSE "-r" /* reuse executable image */
|
|
|
|
#define OPT_NOBLOCK "-n" /* unblock caller immediately */
|
2010-07-01 20:48:25 +02:00
|
|
|
#define OPT_REPLICA "-p" /* create replica for the service */
|
2010-04-09 23:56:44 +02:00
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* Define names for arguments provided to this utility. The first few
|
|
|
|
* arguments are required and have a known index. Thereafter, some optional
|
|
|
|
* argument pairs like "-args arglist" follow.
|
|
|
|
*/
|
|
|
|
#define ARG_NAME 0 /* own application name */
|
|
|
|
|
2006-05-11 17:30:56 +02:00
|
|
|
/* The following are relative to optind */
|
|
|
|
#define ARG_REQUEST 0 /* request to perform */
|
2010-01-05 20:39:27 +01:00
|
|
|
#define ARG_PATH 1 /* system service */
|
2006-10-20 17:01:32 +02:00
|
|
|
#define ARG_LABEL 1 /* name of system service */
|
2006-05-11 17:30:56 +02:00
|
|
|
|
|
|
|
#define MIN_ARG_COUNT 1 /* require an action */
|
2005-08-02 18:00:07 +02:00
|
|
|
|
|
|
|
#define ARG_ARGS "-args" /* list of arguments to be passed */
|
|
|
|
#define ARG_DEV "-dev" /* major device number for drivers */
|
2010-04-09 23:56:44 +02:00
|
|
|
#define ARG_DEVSTYLE "-devstyle" /* device style */
|
2005-10-12 17:07:38 +02:00
|
|
|
#define ARG_PERIOD "-period" /* heartbeat period in ticks */
|
2006-10-20 17:01:32 +02:00
|
|
|
#define ARG_SCRIPT "-script" /* name of the script to restart a
|
2009-12-17 02:53:26 +01:00
|
|
|
* system service
|
2006-10-20 17:01:32 +02:00
|
|
|
*/
|
2007-01-22 16:25:41 +01:00
|
|
|
#define ARG_LABELNAME "-label" /* custom label name */
|
2006-10-20 17:01:32 +02:00
|
|
|
#define ARG_CONFIG "-config" /* name of the file with the resource
|
|
|
|
* configuration
|
|
|
|
*/
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
|
|
|
|
#define ARG_LU_STATE "-state" /* the live update state required */
|
|
|
|
#define ARG_LU_MAXTIME "-maxtime" /* max time to prepare for the update */
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
#define SERVICE_LOGIN "service" /* passwd file entry for services */
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
#define MAX_CLASS_RECURS 100 /* Max nesting level for classes */
|
2005-08-02 18:00:07 +02:00
|
|
|
|
|
|
|
/* The function parse_arguments() verifies and parses the command line
|
|
|
|
* parameters passed to this utility. Request parameters that are needed
|
|
|
|
* are stored globally in the following variables:
|
|
|
|
*/
|
|
|
|
PRIVATE int req_type;
|
2006-10-31 14:35:04 +01:00
|
|
|
PRIVATE int do_run= 0; /* 'run' command instead of 'up' */
|
2010-04-09 23:56:44 +02:00
|
|
|
PRIVATE char *req_label = NULL;
|
|
|
|
PRIVATE char *req_path = NULL;
|
2010-07-01 20:48:25 +02:00
|
|
|
PRIVATE char *req_path_self = SELF_REQ_PATH;
|
2009-05-12 18:52:00 +02:00
|
|
|
PRIVATE char *req_args = "";
|
2010-04-09 23:56:44 +02:00
|
|
|
PRIVATE int req_major = 0;
|
|
|
|
PRIVATE int req_dev_style = STYLE_NDEV;
|
|
|
|
PRIVATE long req_period = 0;
|
|
|
|
PRIVATE char *req_script = NULL;
|
|
|
|
PRIVATE char *req_ipc = NULL;
|
2007-05-02 17:20:28 +02:00
|
|
|
PRIVATE char *req_config = PATH_CONFIG;
|
2006-10-20 17:01:32 +02:00
|
|
|
PRIVATE int class_recurs; /* Nesting level of class statements */
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
PRIVATE int req_lu_state = DEFAULT_LU_STATE;
|
|
|
|
PRIVATE int req_lu_maxtime = DEFAULT_LU_MAXTIME;
|
2005-08-02 18:00:07 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Buffer to build "/command arg1 arg2 ..." string to pass to RS server. */
|
|
|
|
PRIVATE char command[4096];
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
/* Arguments for RS to start a new service */
|
|
|
|
PRIVATE struct rs_start rs_start;
|
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* An error occurred. Report the problem, print the usage, and exit.
|
|
|
|
*/
|
|
|
|
PRIVATE void print_usage(char *app_name, char *problem)
|
|
|
|
{
|
2007-04-23 16:42:58 +02:00
|
|
|
fprintf(stderr, "Warning, %s\n", problem);
|
|
|
|
fprintf(stderr, "Usage:\n");
|
|
|
|
fprintf(stderr,
|
2010-07-05 21:37:08 +02:00
|
|
|
" %s [%s %s %s %s] (up|run|edit|update) <binary|%s> [%s <args>] [%s <special>] [%s <style>] [%s <ticks>] [%s <path>] [%s <name>] [%s <path>] [%s <state>] [%s <time>]\n",
|
2010-07-01 20:48:25 +02:00
|
|
|
app_name, OPT_COPY, OPT_REUSE, OPT_NOBLOCK, OPT_REPLICA, SELF_BINARY,
|
2010-04-09 23:56:44 +02:00
|
|
|
ARG_ARGS, ARG_DEV, ARG_DEVSTYLE, ARG_PERIOD, ARG_SCRIPT,
|
|
|
|
ARG_LABELNAME, ARG_CONFIG, ARG_LU_STATE, ARG_LU_MAXTIME);
|
2010-07-13 23:11:44 +02:00
|
|
|
fprintf(stderr, " %s down <label>\n", app_name);
|
|
|
|
fprintf(stderr, " %s refresh <label>\n", app_name);
|
|
|
|
fprintf(stderr, " %s restart <label>\n", app_name);
|
|
|
|
fprintf(stderr, " %s clone <label>\n", app_name);
|
2007-04-23 16:42:58 +02:00
|
|
|
fprintf(stderr, " %s shutdown\n", app_name);
|
|
|
|
fprintf(stderr, "\n");
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* A request to the RS server failed. Report and exit.
|
2005-08-02 18:00:07 +02:00
|
|
|
*/
|
2010-01-25 15:22:09 +01:00
|
|
|
PRIVATE void failure(void)
|
2005-08-02 18:00:07 +02:00
|
|
|
{
|
2010-01-25 15:22:09 +01:00
|
|
|
fprintf(stderr, "Request to RS failed: %s (error %d)\n", strerror(errno), errno);
|
|
|
|
exit(errno);
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
|
|
|
|
2005-08-23 13:31:32 +02:00
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* Parse and verify correctness of arguments. Report problem and exit if an
|
|
|
|
* error is found. Store needed parameters in global variables.
|
|
|
|
*/
|
2006-05-15 14:08:43 +02:00
|
|
|
PRIVATE int parse_arguments(int argc, char **argv)
|
2005-08-02 18:00:07 +02:00
|
|
|
{
|
|
|
|
struct stat stat_buf;
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
char *hz, *buff;
|
2005-10-12 17:07:38 +02:00
|
|
|
int req_nr;
|
2010-04-09 23:56:44 +02:00
|
|
|
int c, i, j;
|
2010-04-27 13:17:30 +02:00
|
|
|
int c_flag, r_flag, n_flag, p_flag;
|
2010-07-05 21:37:08 +02:00
|
|
|
int label_required;
|
2006-05-11 17:30:56 +02:00
|
|
|
|
2009-08-18 13:36:01 +02:00
|
|
|
c_flag = 0;
|
|
|
|
r_flag = 0;
|
2010-04-09 23:56:44 +02:00
|
|
|
n_flag = 0;
|
2010-04-27 13:17:30 +02:00
|
|
|
p_flag = 0;
|
|
|
|
while (c= getopt(argc, argv, "rcnp?"), c != -1)
|
2006-05-11 17:30:56 +02:00
|
|
|
{
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
case '?':
|
2006-05-15 14:08:43 +02:00
|
|
|
print_usage(argv[ARG_NAME], "wrong number of arguments");
|
2006-05-11 17:30:56 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
case 'c':
|
2009-08-18 13:36:01 +02:00
|
|
|
c_flag = 1;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
c_flag = 1; /* -r implies -c */
|
|
|
|
r_flag = 1;
|
2006-05-11 17:30:56 +02:00
|
|
|
break;
|
2010-04-09 23:56:44 +02:00
|
|
|
case 'n':
|
|
|
|
n_flag = 1;
|
2008-02-21 17:20:22 +01:00
|
|
|
break;
|
2010-04-27 13:17:30 +02:00
|
|
|
case 'p':
|
|
|
|
p_flag = 1;
|
|
|
|
break;
|
2006-05-11 17:30:56 +02:00
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s: getopt failed: %c\n",
|
2006-05-15 14:08:43 +02:00
|
|
|
argv[ARG_NAME], c);
|
2006-05-11 17:30:56 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2005-08-02 18:00:07 +02:00
|
|
|
|
|
|
|
/* Verify argument count. */
|
2006-05-15 14:08:43 +02:00
|
|
|
if (argc < optind+MIN_ARG_COUNT) {
|
|
|
|
print_usage(argv[ARG_NAME], "wrong number of arguments");
|
2005-08-02 18:00:07 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
|
2006-10-31 14:35:04 +01:00
|
|
|
if (strcmp(argv[optind+ARG_REQUEST], RUN_CMD) == 0)
|
|
|
|
{
|
|
|
|
req_nr= RS_UP;
|
|
|
|
do_run= TRUE;
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
2006-10-31 14:35:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Verify request type. */
|
|
|
|
for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) {
|
|
|
|
if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (req_type == ILLEGAL_REQUEST) {
|
|
|
|
print_usage(argv[ARG_NAME], "illegal request type");
|
|
|
|
exit(ENOSYS);
|
|
|
|
}
|
|
|
|
req_nr = RS_RQ_BASE + req_type;
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
rs_start.rss_flags = RSS_SYS_BASIC_CALLS | RSS_VM_BASIC_CALLS;
|
2010-07-05 21:37:08 +02:00
|
|
|
if (req_nr == RS_UP || req_nr == RS_UPDATE || req_nr == RS_EDIT) {
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
u32_t system_hz;
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
if (c_flag)
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
rs_start.rss_flags |= RSS_COPY;
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2009-08-18 13:36:01 +02:00
|
|
|
if(r_flag)
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
rs_start.rss_flags |= RSS_REUSE;
|
2010-04-09 23:56:44 +02:00
|
|
|
|
|
|
|
if(n_flag)
|
|
|
|
rs_start.rss_flags |= RSS_NOBLOCK;
|
|
|
|
|
2010-04-27 13:17:30 +02:00
|
|
|
if(p_flag)
|
|
|
|
rs_start.rss_flags |= RSS_REPLICA;
|
|
|
|
|
2010-07-01 20:48:25 +02:00
|
|
|
req_path = argv[optind+ARG_PATH];
|
|
|
|
if(req_nr == RS_UPDATE && !strcmp(req_path, SELF_BINARY)) {
|
2010-07-05 21:37:08 +02:00
|
|
|
/* Self update needs no real path or configuration file. */
|
2010-07-01 20:48:25 +02:00
|
|
|
req_config = NULL;
|
|
|
|
req_path = req_path_self;
|
|
|
|
rs_start.rss_flags |= RSS_SELF_LU;
|
|
|
|
}
|
|
|
|
|
2006-10-31 14:35:04 +01:00
|
|
|
if (do_run)
|
|
|
|
{
|
|
|
|
/* Set default recovery script for RUN */
|
|
|
|
req_script = RUN_SCRIPT;
|
|
|
|
}
|
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Verify argument count. */
|
2006-05-15 14:08:43 +02:00
|
|
|
if (argc - 1 < optind+ARG_PATH) {
|
|
|
|
print_usage(argv[ARG_NAME], "action requires a binary to start");
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
2005-08-02 18:00:07 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Verify the name of the binary of the system service. */
|
2010-07-01 20:48:25 +02:00
|
|
|
if(!(rs_start.rss_flags & RSS_SELF_LU)) {
|
|
|
|
if (req_path[0] != '/') {
|
|
|
|
print_usage(argv[ARG_NAME], "binary should be absolute path");
|
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
if (stat(req_path, &stat_buf) == -1) {
|
|
|
|
perror(req_path);
|
|
|
|
fprintf(stderr, "couldn't get stat binary\n");
|
|
|
|
exit(errno);
|
|
|
|
}
|
|
|
|
if (! (stat_buf.st_mode & S_IFREG)) {
|
|
|
|
print_usage(argv[ARG_NAME], "binary is not a regular file");
|
|
|
|
exit(EINVAL);
|
|
|
|
}
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
/* Get HZ. */
|
|
|
|
if(getsysinfo_up(PM_PROC_NR,
|
|
|
|
SIU_SYSTEMHZ, sizeof(system_hz), &system_hz) < 0) {
|
|
|
|
system_hz = DEFAULT_HZ;
|
|
|
|
fprintf(stderr, "WARNING: reverting to default HZ %d\n",
|
2010-04-08 17:02:32 +02:00
|
|
|
(int) system_hz);
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
}
|
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Check optional arguments that come in pairs like "-args arglist". */
|
2006-05-15 14:08:43 +02:00
|
|
|
for (i=optind+MIN_ARG_COUNT+1; i<argc; i=i+2) {
|
|
|
|
if (! (i+1 < argc)) {
|
|
|
|
print_usage(argv[ARG_NAME], "optional argument not complete");
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
2006-05-15 14:08:43 +02:00
|
|
|
if (strcmp(argv[i], ARG_ARGS)==0) {
|
|
|
|
req_args = argv[i+1];
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2006-05-15 14:08:43 +02:00
|
|
|
else if (strcmp(argv[i], ARG_PERIOD)==0) {
|
|
|
|
req_period = strtol(argv[i+1], &hz, 10);
|
2008-12-11 15:43:53 +01:00
|
|
|
if (strcmp(hz,"HZ")==0) req_period *= system_hz;
|
2010-07-05 21:37:08 +02:00
|
|
|
if (req_period < 0) {
|
|
|
|
print_usage(argv[ARG_NAME], "bad period argument");
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
}
|
2006-05-15 14:08:43 +02:00
|
|
|
else if (strcmp(argv[i], ARG_DEV)==0) {
|
|
|
|
if (stat(argv[i+1], &stat_buf) == -1) {
|
2007-02-23 19:22:46 +01:00
|
|
|
perror(argv[i+1]);
|
2006-05-15 14:08:43 +02:00
|
|
|
print_usage(argv[ARG_NAME], "couldn't get status of device");
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(errno);
|
|
|
|
}
|
|
|
|
if ( ! (stat_buf.st_mode & (S_IFBLK | S_IFCHR))) {
|
2006-05-15 14:08:43 +02:00
|
|
|
print_usage(argv[ARG_NAME], "special file is not a device");
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
req_major = (stat_buf.st_rdev >> MAJOR) & BYTE;
|
2010-04-09 23:56:44 +02:00
|
|
|
if(req_dev_style == STYLE_NDEV) {
|
|
|
|
req_dev_style = STYLE_DEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], ARG_DEVSTYLE)==0) {
|
|
|
|
char* dev_style_keys[] = { "STYLE_DEV", "STYLE_DEVA", "STYLE_TTY",
|
|
|
|
"STYLE_CTTY", "STYLE_CLONE", NULL };
|
|
|
|
int dev_style_values[] = { STYLE_DEV, STYLE_DEVA, STYLE_TTY,
|
|
|
|
STYLE_CTTY, STYLE_CLONE };
|
|
|
|
for(j=0;dev_style_keys[j]!=NULL;j++) {
|
|
|
|
if(!strcmp(dev_style_keys[j], argv[i+1])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dev_style_keys[j] == NULL) {
|
|
|
|
print_usage(argv[ARG_NAME], "bad device style");
|
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
req_dev_style = dev_style_values[j];
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
else if (strcmp(argv[i], ARG_SCRIPT)==0) {
|
|
|
|
req_script = argv[i+1];
|
|
|
|
}
|
2007-01-22 16:25:41 +01:00
|
|
|
else if (strcmp(argv[i], ARG_LABELNAME)==0) {
|
|
|
|
req_label = argv[i+1];
|
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
else if (strcmp(argv[i], ARG_CONFIG)==0) {
|
|
|
|
req_config = argv[i+1];
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
else if (strcmp(argv[i], ARG_LU_STATE)==0) {
|
|
|
|
errno=0;
|
|
|
|
req_lu_state = strtol(argv[i+1], &buff, 10);
|
|
|
|
if(errno || strcmp(buff, "")) {
|
2010-04-09 23:56:44 +02:00
|
|
|
print_usage(argv[ARG_NAME], "bad live update state");
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
if(req_lu_state == SEF_LU_STATE_NULL) {
|
2010-04-09 23:56:44 +02:00
|
|
|
print_usage(argv[ARG_NAME], "null live update state");
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], ARG_LU_MAXTIME)==0) {
|
|
|
|
errno=0;
|
|
|
|
req_lu_maxtime = strtol(argv[i+1], &hz, 10);
|
|
|
|
if(errno || (strcmp(hz, "") && strcmp(hz, "HZ"))
|
|
|
|
|| req_lu_maxtime<0) {
|
|
|
|
print_usage(argv[ARG_NAME],
|
|
|
|
"bad live update max time");
|
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
if (strcmp(hz,"HZ")==0) req_lu_maxtime *= system_hz;
|
2007-01-22 16:25:41 +01:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
else {
|
2006-05-15 14:08:43 +02:00
|
|
|
print_usage(argv[ARG_NAME], "unknown optional argument given");
|
2005-08-02 18:00:07 +02:00
|
|
|
exit(EINVAL);
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2010-06-28 23:38:29 +02:00
|
|
|
else if (req_nr == RS_DOWN || req_nr == RS_REFRESH || req_nr == RS_RESTART
|
|
|
|
|| req_nr == RS_CLONE) {
|
2005-10-12 17:07:38 +02:00
|
|
|
|
|
|
|
/* Verify argument count. */
|
2006-10-20 17:01:32 +02:00
|
|
|
if (argc - 1 < optind+ARG_LABEL) {
|
2010-06-28 23:38:29 +02:00
|
|
|
print_usage(argv[ARG_NAME], "action requires a target label");
|
2005-08-02 18:00:07 +02:00
|
|
|
exit(EINVAL);
|
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
req_label= argv[optind+ARG_LABEL];
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2005-10-20 22:31:18 +02:00
|
|
|
else if (req_nr == RS_SHUTDOWN) {
|
2005-10-21 15:28:26 +02:00
|
|
|
/* no extra arguments required */
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
|
|
|
|
2010-07-05 21:37:08 +02:00
|
|
|
label_required = (rs_start.rss_flags & RSS_SELF_LU) || (req_nr == RS_EDIT);
|
|
|
|
if(label_required && !req_label) {
|
2010-07-01 20:48:25 +02:00
|
|
|
print_usage(argv[ARG_NAME], "label option mandatory for target action");
|
|
|
|
exit(EINVAL);
|
|
|
|
}
|
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* Return the request number if no error were found. */
|
2005-10-12 17:07:38 +02:00
|
|
|
return(req_nr);
|
2005-08-02 18:00:07 +02:00
|
|
|
}
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
PRIVATE void fatal(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
fprintf(stderr, "fatal error: ");
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
#define KW_SERVICE "service"
|
2006-10-20 17:01:32 +02:00
|
|
|
#define KW_UID "uid"
|
2010-07-13 23:11:44 +02:00
|
|
|
#define KW_SIGMGR "sigmgr"
|
2010-07-01 10:32:33 +02:00
|
|
|
#define KW_SCHEDULER "scheduler"
|
|
|
|
#define KW_PRIORITY "priority"
|
|
|
|
#define KW_QUANTUM "quantum"
|
2010-07-20 09:27:45 +02:00
|
|
|
#define KW_CPU "cpu"
|
2006-10-20 17:01:32 +02:00
|
|
|
#define KW_IRQ "irq"
|
|
|
|
#define KW_IO "io"
|
|
|
|
#define KW_PCI "pci"
|
|
|
|
#define KW_DEVICE "device"
|
|
|
|
#define KW_CLASS "class"
|
|
|
|
#define KW_SYSTEM "system"
|
2008-02-21 17:20:22 +01:00
|
|
|
#define KW_IPC "ipc"
|
2009-09-21 16:49:04 +02:00
|
|
|
#define KW_VM "vm"
|
2009-12-02 10:54:50 +01:00
|
|
|
#define KW_CONTROL "control"
|
2010-07-13 23:11:44 +02:00
|
|
|
#define KW_ALL "ALL"
|
|
|
|
#define KW_ALL_SYS "ALL_SYS"
|
|
|
|
#define KW_NONE "NONE"
|
|
|
|
#define KW_BASIC "BASIC"
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
FORWARD void do_service(config_t *cpe, config_t *config);
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
PRIVATE void do_class(config_t *cpe, config_t *config)
|
|
|
|
{
|
|
|
|
config_t *cp, *cp1;
|
|
|
|
|
|
|
|
if (class_recurs > MAX_CLASS_RECURS)
|
|
|
|
{
|
|
|
|
fatal(
|
|
|
|
"do_class: nesting level too high for class '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
class_recurs++;
|
|
|
|
|
|
|
|
/* Process classes */
|
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_class: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_uid: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find entry for the class */
|
|
|
|
for (cp= config; cp; cp= cp->next)
|
|
|
|
{
|
|
|
|
if (!(cp->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_class: expected list at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cp->file, cp->line);
|
|
|
|
}
|
|
|
|
cp1= cp->list;
|
|
|
|
if ((cp1->flags & CFG_STRING) ||
|
|
|
|
(cp1->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_class: expected word at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cp1->file, cp1->line);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
/* At this place we expect the word KW_SERVICE */
|
|
|
|
if (strcmp(cp1->word, KW_SERVICE) != 0)
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_class: exected word '%S' at %s:%d",
|
2009-12-17 02:53:26 +01:00
|
|
|
KW_SERVICE, cp1->file, cp1->line);
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
cp1= cp1->next;
|
|
|
|
if ((cp1->flags & CFG_STRING) ||
|
|
|
|
(cp1->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_class: expected word at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cp1->file, cp1->line);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
/* At this place we expect the name of the service */
|
2006-10-20 17:01:32 +02:00
|
|
|
if (strcmp(cp1->word, cpe->word) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cp == NULL)
|
|
|
|
{
|
|
|
|
fatal(
|
2009-12-02 10:54:50 +01:00
|
|
|
"do_class: no entry found for class '%s' at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
2009-12-17 02:53:26 +01:00
|
|
|
do_service(cp1->next, config);
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class_recurs--;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_uid(config_t *cpe)
|
|
|
|
{
|
|
|
|
uid_t uid;
|
|
|
|
struct passwd *pw;
|
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a uid */
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
fatal("do_uid: just one uid/login expected at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_uid: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_uid: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
pw= getpwnam(cpe->word);
|
|
|
|
if (pw != NULL)
|
|
|
|
uid= pw->pw_uid;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uid= strtol(cpe->word, &check, 0);
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_uid: bad uid/login '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rs_start.rss_uid= uid;
|
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
PRIVATE void do_sigmgr(config_t *cpe)
|
|
|
|
{
|
|
|
|
endpoint_t sigmgr_ep;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* Process a signal manager value */
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
fatal("do_sigmgr: just one sigmgr value expected at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_sigmgr: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_sigmgr: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp(cpe->word, "SELF")) {
|
|
|
|
sigmgr_ep = SELF;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = minix_rs_lookup(cpe->word, &sigmgr_ep);
|
|
|
|
if(r != OK) {
|
|
|
|
fatal("do_sigmgr: unknown sigmgr %s at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rs_start.rss_sigmgr= sigmgr_ep;
|
|
|
|
}
|
|
|
|
|
2010-07-01 10:32:33 +02:00
|
|
|
PRIVATE void do_scheduler(config_t *cpe)
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
endpoint_t scheduler_ep;
|
|
|
|
int r;
|
2010-07-01 10:32:33 +02:00
|
|
|
|
|
|
|
/* Process a scheduler value */
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
fatal("do_scheduler: just one scheduler value expected at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_scheduler: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_scheduler: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
|
|
|
|
if(!strcmp(cpe->word, "KERNEL")) {
|
|
|
|
scheduler_ep = KERNEL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = minix_rs_lookup(cpe->word, &scheduler_ep);
|
|
|
|
if(r != OK) {
|
|
|
|
fatal("do_scheduler: unknown scheduler %s at %s:%d",
|
2010-07-01 10:32:33 +02:00
|
|
|
cpe->word, cpe->file, cpe->line);
|
2010-07-13 23:11:44 +02:00
|
|
|
}
|
2010-07-01 10:32:33 +02:00
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
rs_start.rss_scheduler= scheduler_ep;
|
2010-07-01 10:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_priority(config_t *cpe)
|
|
|
|
{
|
|
|
|
int priority_val;
|
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a priority value */
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
fatal("do_priority: just one priority value expected at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_priority: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_priority: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
priority_val= strtol(cpe->word, &check, 0);
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_priority: bad priority value '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priority_val < 0 || priority_val >= NR_SCHED_QUEUES)
|
|
|
|
{
|
|
|
|
fatal("do_priority: priority %d out of range at %s:%d",
|
|
|
|
priority_val, cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-20 09:27:45 +02:00
|
|
|
rs_start.rss_priority= priority_val;
|
2010-07-01 10:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_quantum(config_t *cpe)
|
2006-10-20 17:01:32 +02:00
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
int quantum_val;
|
2006-10-20 17:01:32 +02:00
|
|
|
char *check;
|
|
|
|
|
2010-07-01 10:32:33 +02:00
|
|
|
/* Process a quantum value */
|
2006-10-20 17:01:32 +02:00
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
fatal("do_quantum: just one quantum value expected at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
fatal("do_quantum: unexpected sublist at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
fatal("do_quantum: unexpected string at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-01 10:32:33 +02:00
|
|
|
quantum_val= strtol(cpe->word, &check, 0);
|
2006-10-20 17:01:32 +02:00
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
fatal("do_quantum: bad quantum value '%s' at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2010-07-01 10:32:33 +02:00
|
|
|
if (quantum_val <= 0)
|
|
|
|
{
|
|
|
|
fatal("do_quantum: quantum %d out of range at %s:%d",
|
|
|
|
quantum_val, cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-20 09:27:45 +02:00
|
|
|
rs_start.rss_quantum= quantum_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_cpu(config_t *cpe)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a quantum value */
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
fatal("do_cpu: just one value expected at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_cpu: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_cpu: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
cpu= strtol(cpe->word, &check, 0);
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_cpu: bad value '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpu <= 0)
|
|
|
|
{
|
|
|
|
fatal("do_cpu: %d out of range at %s:%d",
|
|
|
|
cpu, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
rs_start.rss_cpu= cpu;
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_irq(config_t *cpe)
|
|
|
|
{
|
|
|
|
int irq;
|
2010-07-13 23:11:44 +02:00
|
|
|
int first;
|
2006-10-20 17:01:32 +02:00
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a list of IRQs */
|
2010-07-13 23:11:44 +02:00
|
|
|
first = TRUE;
|
2006-10-20 17:01:32 +02:00
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_irq: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_irq: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
|
|
|
|
/* No IRQ allowed? (default) */
|
|
|
|
if(!strcmp(cpe->word, KW_NONE)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_irq: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All IRQs are allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_ALL)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_irq: %s keyword not allowed in list",
|
|
|
|
KW_ALL);
|
|
|
|
}
|
|
|
|
rs_start.rss_nr_irq = RSS_IO_ALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set single IRQs as specified in the configuration. */
|
2006-10-20 17:01:32 +02:00
|
|
|
irq= strtoul(cpe->word, &check, 0);
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_irq: bad irq '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (rs_start.rss_nr_irq >= RSS_NR_IRQ)
|
|
|
|
fatal("do_irq: too many IRQs (max %d)", RSS_NR_IRQ);
|
|
|
|
rs_start.rss_irq[rs_start.rss_nr_irq]= irq;
|
|
|
|
rs_start.rss_nr_irq++;
|
2010-07-13 23:11:44 +02:00
|
|
|
first = FALSE;
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_io(config_t *cpe)
|
|
|
|
{
|
|
|
|
unsigned base, len;
|
2010-07-13 23:11:44 +02:00
|
|
|
int first;
|
2006-10-20 17:01:32 +02:00
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a list of I/O ranges */
|
2010-07-13 23:11:44 +02:00
|
|
|
first = TRUE;
|
2006-10-20 17:01:32 +02:00
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_io: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_io: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
|
|
|
|
/* No range allowed? (default) */
|
|
|
|
if(!strcmp(cpe->word, KW_NONE)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_io: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All ranges are allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_ALL)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_io: %s keyword not allowed in list",
|
|
|
|
KW_ALL);
|
|
|
|
}
|
|
|
|
rs_start.rss_nr_io = RSS_IO_ALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set single ranges as specified in the configuration. */
|
2006-10-20 17:01:32 +02:00
|
|
|
base= strtoul(cpe->word, &check, 0x10);
|
|
|
|
len= 1;
|
|
|
|
if (check[0] == ':')
|
|
|
|
{
|
|
|
|
len= strtoul(check+1, &check, 0x10);
|
|
|
|
}
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_io: bad I/O range '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rs_start.rss_nr_io >= RSS_NR_IO)
|
|
|
|
fatal("do_io: too many I/O ranges (max %d)", RSS_NR_IO);
|
|
|
|
rs_start.rss_io[rs_start.rss_nr_io].base= base;
|
|
|
|
rs_start.rss_io[rs_start.rss_nr_io].len= len;
|
|
|
|
rs_start.rss_nr_io++;
|
2010-07-13 23:11:44 +02:00
|
|
|
first = FALSE;
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_pci_device(config_t *cpe)
|
|
|
|
{
|
|
|
|
u16_t vid, did;
|
|
|
|
char *check, *check2;
|
|
|
|
|
|
|
|
/* Process a list of PCI device IDs */
|
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_pci_device: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_pci_device: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
vid= strtoul(cpe->word, &check, 0x10);
|
|
|
|
if (check[0] == '/')
|
|
|
|
did= strtoul(check+1, &check2, 0x10);
|
|
|
|
if (check[0] != '/' || check2[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_pci_device: bad ID '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
if (rs_start.rss_nr_pci_id >= RS_NR_PCI_DEVICE)
|
2006-10-20 17:01:32 +02:00
|
|
|
{
|
|
|
|
fatal("do_pci_device: too many device IDs (max %d)",
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
RS_NR_PCI_DEVICE);
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
rs_start.rss_pci_id[rs_start.rss_nr_pci_id].vid= vid;
|
|
|
|
rs_start.rss_pci_id[rs_start.rss_nr_pci_id].did= did;
|
|
|
|
rs_start.rss_nr_pci_id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_pci_class(config_t *cpe)
|
|
|
|
{
|
|
|
|
u8_t baseclass, subclass, interface;
|
|
|
|
u32_t class_id, mask;
|
|
|
|
char *check;
|
|
|
|
|
|
|
|
/* Process a list of PCI device class IDs */
|
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_pci_device: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_pci_device: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
baseclass= strtoul(cpe->word, &check, 0x10);
|
|
|
|
subclass= 0;
|
|
|
|
interface= 0;
|
|
|
|
mask= 0xff0000;
|
|
|
|
if (check[0] == '/')
|
|
|
|
{
|
|
|
|
subclass= strtoul(check+1, &check, 0x10);
|
|
|
|
mask= 0xffff00;
|
|
|
|
if (check[0] == '/')
|
|
|
|
{
|
|
|
|
interface= strtoul(check+1, &check, 0x10);
|
|
|
|
mask= 0xffffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check[0] != '\0')
|
|
|
|
{
|
|
|
|
fatal("do_pci_class: bad class ID '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
class_id= (baseclass << 16) | (subclass << 8) | interface;
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
if (rs_start.rss_nr_pci_class >= RS_NR_PCI_CLASS)
|
2006-10-20 17:01:32 +02:00
|
|
|
{
|
|
|
|
fatal("do_pci_class: too many class IDs (max %d)",
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
RS_NR_PCI_CLASS);
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
2010-05-27 11:18:49 +02:00
|
|
|
rs_start.rss_pci_class[rs_start.rss_nr_pci_class].pciclass=
|
2006-10-20 17:01:32 +02:00
|
|
|
class_id;
|
|
|
|
rs_start.rss_pci_class[rs_start.rss_nr_pci_class].mask= mask;
|
|
|
|
rs_start.rss_nr_pci_class++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_pci(config_t *cpe)
|
|
|
|
{
|
|
|
|
if (cpe == NULL)
|
|
|
|
return; /* Empty PCI statement */
|
|
|
|
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_pci: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_pci: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(cpe->word, KW_DEVICE) == 0)
|
|
|
|
{
|
|
|
|
do_pci_device(cpe->next);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_CLASS) == 0)
|
|
|
|
{
|
|
|
|
do_pci_class(cpe->next);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fatal("do_pci: unexpected word '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2008-02-21 17:20:22 +01:00
|
|
|
PRIVATE void do_ipc(config_t *cpe)
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
char *list, *word;
|
|
|
|
char *word_all = RSS_IPC_ALL;
|
|
|
|
char *word_all_sys = RSS_IPC_ALL_SYS;
|
2008-02-21 17:20:22 +01:00
|
|
|
size_t listsize, wordlen;
|
2010-07-13 23:11:44 +02:00
|
|
|
int first;
|
2008-02-21 17:20:22 +01:00
|
|
|
|
|
|
|
list= NULL;
|
|
|
|
listsize= 1;
|
|
|
|
list= malloc(listsize);
|
|
|
|
if (list == NULL)
|
|
|
|
fatal("do_ipc: unable to malloc %d bytes", listsize);
|
|
|
|
list[0]= '\0';
|
|
|
|
|
|
|
|
/* Process a list of process names that are allowed to be
|
|
|
|
* contacted
|
|
|
|
*/
|
2010-07-13 23:11:44 +02:00
|
|
|
first = TRUE;
|
2008-02-21 17:20:22 +01:00
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_ipc: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_ipc: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
word = cpe->word;
|
|
|
|
|
|
|
|
/* All (system) ipc targets are allowed? */
|
|
|
|
if(!strcmp(word, KW_ALL) || !strcmp(word, KW_ALL_SYS)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_ipc: %s keyword not allowed in list",
|
|
|
|
word);
|
|
|
|
}
|
|
|
|
word = !strcmp(word, KW_ALL) ? word_all : word_all_sys;
|
|
|
|
}
|
2008-02-21 17:20:22 +01:00
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
wordlen= strlen(word);
|
2008-02-21 17:20:22 +01:00
|
|
|
|
|
|
|
listsize += 1 + wordlen;
|
|
|
|
list= realloc(list, listsize);
|
|
|
|
if (list == NULL)
|
|
|
|
{
|
|
|
|
fatal("do_ipc: unable to realloc %d bytes",
|
|
|
|
listsize);
|
|
|
|
}
|
|
|
|
strcat(list, " ");
|
2010-07-13 23:11:44 +02:00
|
|
|
strcat(list, word);
|
|
|
|
first = FALSE;
|
2008-02-21 17:20:22 +01:00
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
2008-02-21 17:20:22 +01:00
|
|
|
printf("do_ipc: got list '%s'\n", list);
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
2008-02-21 17:20:22 +01:00
|
|
|
|
|
|
|
if (req_ipc)
|
|
|
|
fatal("do_ipc: req_ipc is set");
|
|
|
|
req_ipc= list;
|
|
|
|
}
|
|
|
|
|
2009-09-21 16:49:04 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *label;
|
|
|
|
int call_nr;
|
|
|
|
} vm_table[] =
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
{ "EXIT", VM_EXIT },
|
|
|
|
{ "FORK", VM_FORK },
|
|
|
|
{ "BRK", VM_BRK },
|
|
|
|
{ "EXEC_NEWMEM", VM_EXEC_NEWMEM },
|
|
|
|
{ "PUSH_SIG", VM_PUSH_SIG },
|
|
|
|
{ "WILLEXIT", VM_WILLEXIT },
|
|
|
|
{ "ADDDMA", VM_ADDDMA },
|
|
|
|
{ "DELDMA", VM_DELDMA },
|
|
|
|
{ "GETDMA", VM_GETDMA },
|
2009-09-21 16:49:04 +02:00
|
|
|
{ "REMAP", VM_REMAP },
|
2010-07-13 23:11:44 +02:00
|
|
|
{ "SHM_UNMAP", VM_SHM_UNMAP },
|
2009-09-21 16:49:04 +02:00
|
|
|
{ "GETPHYS", VM_GETPHYS },
|
2010-07-13 23:11:44 +02:00
|
|
|
{ "GETREF", VM_GETREF },
|
|
|
|
{ "RS_SET_PRIV", VM_RS_SET_PRIV },
|
|
|
|
{ "QUERY_EXIT", VM_QUERY_EXIT },
|
|
|
|
{ "NOTIFY_SIG", VM_NOTIFY_SIG },
|
2010-01-19 22:00:20 +01:00
|
|
|
{ "INFO", VM_INFO },
|
2010-07-13 23:11:44 +02:00
|
|
|
{ "RS_UPDATE", VM_RS_UPDATE },
|
|
|
|
{ "RS_MEMCTL", VM_RS_MEMCTL },
|
2009-09-21 16:49:04 +02:00
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
PRIVATE void do_vm(config_t *cpe)
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
int i, first;
|
2009-09-21 16:49:04 +02:00
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
first = TRUE;
|
2009-09-21 16:49:04 +02:00
|
|
|
for (; cpe; cpe = cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_vm: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_vm: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
/* Only basic calls allowed? (default). */
|
|
|
|
if(!strcmp(cpe->word, KW_BASIC)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_vm: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No calls allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_NONE)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_vm: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
rs_start.rss_flags &= ~RSS_VM_BASIC_CALLS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All calls are allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_ALL)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_vm: %s keyword not allowed in list",
|
|
|
|
KW_ALL);
|
|
|
|
}
|
|
|
|
for (i = 0; i < NR_VM_CALLS; i++)
|
|
|
|
SET_BIT(rs_start.rss_vm, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set single calls as specified in the configuration. */
|
2009-09-21 16:49:04 +02:00
|
|
|
for (i = 0; vm_table[i].label != NULL; i++)
|
|
|
|
if (!strcmp(cpe->word, vm_table[i].label))
|
|
|
|
break;
|
|
|
|
if (vm_table[i].label == NULL)
|
|
|
|
fatal("do_vm: unknown call '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
|
|
|
SET_BIT(rs_start.rss_vm, vm_table[i].call_nr - VM_RQ_BASE);
|
2010-07-13 23:11:44 +02:00
|
|
|
first = FALSE;
|
2009-09-21 16:49:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *label;
|
|
|
|
int call_nr;
|
|
|
|
} system_tab[]=
|
|
|
|
{
|
|
|
|
{ "PRIVCTL", SYS_PRIVCTL },
|
|
|
|
{ "TRACE", SYS_TRACE },
|
|
|
|
{ "KILL", SYS_KILL },
|
|
|
|
{ "SEGCTL", SYS_SEGCTL },
|
|
|
|
{ "UMAP", SYS_UMAP },
|
|
|
|
{ "VIRCOPY", SYS_VIRCOPY },
|
|
|
|
{ "PHYSCOPY", SYS_PHYSCOPY },
|
|
|
|
{ "IRQCTL", SYS_IRQCTL },
|
|
|
|
{ "INT86", SYS_INT86 },
|
|
|
|
{ "DEVIO", SYS_DEVIO },
|
|
|
|
{ "SDEVIO", SYS_SDEVIO },
|
|
|
|
{ "VDEVIO", SYS_VDEVIO },
|
|
|
|
{ "ABORT", SYS_ABORT },
|
|
|
|
{ "IOPENABLE", SYS_IOPENABLE },
|
|
|
|
{ "READBIOS", SYS_READBIOS },
|
|
|
|
{ "STIME", SYS_STIME },
|
|
|
|
{ "VMCTL", SYS_VMCTL },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
PRIVATE void do_system(config_t *cpe)
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
int i, first;
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
/* Process a list of 'system' calls that are allowed */
|
2010-07-13 23:11:44 +02:00
|
|
|
first = TRUE;
|
2006-10-20 17:01:32 +02:00
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_system: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_system: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
/* Only basic calls allowed? (default). */
|
|
|
|
if(!strcmp(cpe->word, KW_BASIC)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_system: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No calls allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_NONE)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_system: %s keyword not allowed in list",
|
|
|
|
KW_NONE);
|
|
|
|
}
|
|
|
|
rs_start.rss_flags &= ~RSS_SYS_BASIC_CALLS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All calls are allowed? */
|
|
|
|
if(!strcmp(cpe->word, KW_ALL)) {
|
|
|
|
if(!first || cpe->next) {
|
|
|
|
fatal("do_system: %s keyword not allowed in list",
|
|
|
|
KW_ALL);
|
|
|
|
}
|
|
|
|
for (i = 0; i < NR_SYS_CALLS; i++)
|
|
|
|
SET_BIT(rs_start.rss_system, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set single calls as specified in the configuration. */
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
for (i = 0; system_tab[i].label != NULL; i++)
|
|
|
|
if (!strcmp(cpe->word, system_tab[i].label))
|
2006-10-20 17:01:32 +02:00
|
|
|
break;
|
|
|
|
if (system_tab[i].label == NULL)
|
|
|
|
fatal("do_system: unknown call '%s' at %s:%d",
|
|
|
|
cpe->word, cpe->file, cpe->line);
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
SET_BIT(rs_start.rss_system, system_tab[i].call_nr - KERNEL_CALL);
|
2010-07-13 23:11:44 +02:00
|
|
|
first = FALSE;
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 10:54:50 +01:00
|
|
|
PRIVATE void do_control(config_t *cpe)
|
|
|
|
{
|
|
|
|
int nr_control = 0;
|
|
|
|
|
|
|
|
/* Process a list of 'control' labels. */
|
|
|
|
for (; cpe; cpe= cpe->next)
|
|
|
|
{
|
|
|
|
if (cpe->flags & CFG_SUBLIST)
|
|
|
|
{
|
|
|
|
fatal("do_control: unexpected sublist at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->flags & CFG_STRING)
|
|
|
|
{
|
|
|
|
fatal("do_control: unexpected string at %s:%d",
|
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
if (nr_control >= RS_NR_CONTROL)
|
2009-12-02 10:54:50 +01:00
|
|
|
{
|
|
|
|
fatal(
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
"do_control: RS_NR_CONTROL is too small (%d needed)",
|
2009-12-02 10:54:50 +01:00
|
|
|
nr_control+1);
|
|
|
|
}
|
|
|
|
|
2010-04-08 17:02:32 +02:00
|
|
|
rs_start.rss_control[nr_control].l_addr = (char*) cpe->word;
|
2009-12-02 10:54:50 +01:00
|
|
|
rs_start.rss_control[nr_control].l_len = strlen(cpe->word);
|
|
|
|
rs_start.rss_nr_control = ++nr_control;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
PRIVATE void do_service(config_t *cpe, config_t *config)
|
2006-10-20 17:01:32 +02:00
|
|
|
{
|
|
|
|
config_t *cp;
|
|
|
|
|
|
|
|
/* At this point we expect one sublist that contains the varios
|
|
|
|
* resource allocations
|
|
|
|
*/
|
|
|
|
if (!(cpe->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-17 02:53:26 +01:00
|
|
|
fatal("do_service: expected list at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
if (cpe->next != NULL)
|
|
|
|
{
|
|
|
|
cpe= cpe->next;
|
2009-12-17 02:53:26 +01:00
|
|
|
fatal("do_service: expected end of list at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
cpe= cpe->list;
|
|
|
|
|
|
|
|
/* Process the list */
|
|
|
|
for (cp= cpe; cp; cp= cp->next)
|
|
|
|
{
|
|
|
|
if (!(cp->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-17 02:53:26 +01:00
|
|
|
fatal("do_service: expected list at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cp->file, cp->line);
|
|
|
|
}
|
|
|
|
cpe= cp->list;
|
|
|
|
if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-17 02:53:26 +01:00
|
|
|
fatal("do_service: expected word at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(cpe->word, KW_CLASS) == 0)
|
|
|
|
{
|
|
|
|
do_class(cpe->next, config);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_UID) == 0)
|
|
|
|
{
|
|
|
|
do_uid(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
if (strcmp(cpe->word, KW_SIGMGR) == 0)
|
|
|
|
{
|
|
|
|
do_sigmgr(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-01 10:32:33 +02:00
|
|
|
if (strcmp(cpe->word, KW_SCHEDULER) == 0)
|
2006-10-20 17:01:32 +02:00
|
|
|
{
|
2010-07-01 10:32:33 +02:00
|
|
|
do_scheduler(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_PRIORITY) == 0)
|
|
|
|
{
|
|
|
|
do_priority(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_QUANTUM) == 0)
|
|
|
|
{
|
|
|
|
do_quantum(cpe->next);
|
2006-10-20 17:01:32 +02:00
|
|
|
continue;
|
|
|
|
}
|
2010-07-20 09:27:45 +02:00
|
|
|
if (strcmp(cpe->word, KW_CPU) == 0)
|
|
|
|
{
|
|
|
|
do_cpu(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
if (strcmp(cpe->word, KW_IRQ) == 0)
|
|
|
|
{
|
|
|
|
do_irq(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_IO) == 0)
|
|
|
|
{
|
|
|
|
do_io(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_PCI) == 0)
|
|
|
|
{
|
|
|
|
do_pci(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(cpe->word, KW_SYSTEM) == 0)
|
|
|
|
{
|
|
|
|
do_system(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2008-02-21 17:20:22 +01:00
|
|
|
if (strcmp(cpe->word, KW_IPC) == 0)
|
|
|
|
{
|
|
|
|
do_ipc(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-21 16:49:04 +02:00
|
|
|
if (strcmp(cpe->word, KW_VM) == 0)
|
|
|
|
{
|
|
|
|
do_vm(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-02 10:54:50 +01:00
|
|
|
if (strcmp(cpe->word, KW_CONTROL) == 0)
|
|
|
|
{
|
|
|
|
do_control(cpe->next);
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void do_config(char *label, char *filename)
|
|
|
|
{
|
|
|
|
config_t *config, *cp, *cpe;
|
|
|
|
|
|
|
|
config= config_read(filename, 0, NULL);
|
|
|
|
if (config == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "config_read failed for '%s': %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
/* Find an entry for our service */
|
2006-10-20 17:01:32 +02:00
|
|
|
for (cp= config; cp; cp= cp->next)
|
|
|
|
{
|
|
|
|
if (!(cp->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_config: expected list at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cp->file, cp->line);
|
|
|
|
}
|
|
|
|
cpe= cp->list;
|
|
|
|
if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_config: expected word at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
/* At this place we expect the word KW_SERVICE */
|
|
|
|
if (strcmp(cpe->word, KW_SERVICE) != 0)
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_config: exected word '%S' at %s:%d",
|
2009-12-17 02:53:26 +01:00
|
|
|
KW_SERVICE, cpe->file, cpe->line);
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
cpe= cpe->next;
|
|
|
|
if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
|
|
|
|
{
|
2009-12-02 10:54:50 +01:00
|
|
|
fatal("do_config: expected word at %s:%d",
|
2006-10-20 17:01:32 +02:00
|
|
|
cpe->file, cpe->line);
|
|
|
|
}
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
/* At this place we expect the name of the service. */
|
2006-10-20 17:01:32 +02:00
|
|
|
if (strcmp(cpe->word, label) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cp == NULL)
|
|
|
|
{
|
2010-01-13 15:44:19 +01:00
|
|
|
fprintf(stderr, "service: service '%s' not found in '%s'\n",
|
|
|
|
label, filename);
|
2009-12-02 10:54:50 +01:00
|
|
|
exit(1);
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cpe= cpe->next;
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
do_service(cpe, config);
|
2006-10-20 17:01:32 +02:00
|
|
|
}
|
2005-08-23 13:31:32 +02:00
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
/* Main program.
|
|
|
|
*/
|
|
|
|
PUBLIC int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
message m;
|
2010-01-27 11:23:58 +01:00
|
|
|
int result = EXIT_SUCCESS;
|
2005-10-20 22:31:18 +02:00
|
|
|
int request;
|
2010-02-19 11:00:32 +01:00
|
|
|
char *progname = NULL;
|
2006-10-20 17:01:32 +02:00
|
|
|
struct passwd *pw;
|
2005-08-02 18:00:07 +02:00
|
|
|
|
|
|
|
/* Verify and parse the command line arguments. All arguments are checked
|
|
|
|
* here. If an error occurs, the problem is reported and exit(2) is called.
|
|
|
|
* all needed parameters to perform the request are extracted and stored
|
|
|
|
* global variables.
|
|
|
|
*/
|
2005-10-20 22:31:18 +02:00
|
|
|
request = parse_arguments(argc, argv);
|
2005-08-02 18:00:07 +02:00
|
|
|
|
|
|
|
/* Arguments seem fine. Try to perform the request. Only valid requests
|
|
|
|
* should end up here. The default is used for not yet supported requests.
|
|
|
|
*/
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
result = OK;
|
2005-10-20 22:31:18 +02:00
|
|
|
switch(request) {
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
case RS_UPDATE:
|
|
|
|
m.RS_LU_STATE = req_lu_state;
|
|
|
|
m.RS_LU_PREPARE_MAXTIME = req_lu_maxtime;
|
|
|
|
/* fall through */
|
2005-10-20 22:31:18 +02:00
|
|
|
case RS_UP:
|
2010-07-05 21:37:08 +02:00
|
|
|
case RS_EDIT:
|
2006-10-20 17:01:32 +02:00
|
|
|
/* Build space-separated command string to be passed to RS server. */
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
progname = strrchr(req_path, '/');
|
|
|
|
assert(progname); /* an absolute path was required */
|
|
|
|
progname++; /* skip last slash */
|
2006-10-20 17:01:32 +02:00
|
|
|
strcpy(command, req_path);
|
|
|
|
command[strlen(req_path)] = ' ';
|
|
|
|
strcpy(command+strlen(req_path)+1, req_args);
|
|
|
|
|
|
|
|
rs_start.rss_cmd= command;
|
|
|
|
rs_start.rss_cmdlen= strlen(command);
|
|
|
|
rs_start.rss_major= req_major;
|
2010-04-09 23:56:44 +02:00
|
|
|
rs_start.rss_dev_style= req_dev_style;
|
2006-10-20 17:01:32 +02:00
|
|
|
rs_start.rss_period= req_period;
|
|
|
|
rs_start.rss_script= req_script;
|
2007-01-22 16:25:41 +01:00
|
|
|
if(req_label) {
|
2009-12-02 10:54:50 +01:00
|
|
|
rs_start.rss_label.l_addr = req_label;
|
|
|
|
rs_start.rss_label.l_len = strlen(req_label);
|
2007-01-22 16:25:41 +01:00
|
|
|
} else {
|
2009-12-02 10:54:50 +01:00
|
|
|
rs_start.rss_label.l_addr = progname;
|
|
|
|
rs_start.rss_label.l_len = strlen(progname);
|
2007-01-22 16:25:41 +01:00
|
|
|
}
|
2006-10-20 17:01:32 +02:00
|
|
|
if (req_script)
|
|
|
|
rs_start.rss_scriptlen= strlen(req_script);
|
|
|
|
else
|
|
|
|
rs_start.rss_scriptlen= 0;
|
|
|
|
|
2009-12-17 02:53:26 +01:00
|
|
|
pw= getpwnam(SERVICE_LOGIN);
|
2006-10-20 17:01:32 +02:00
|
|
|
if (pw == NULL)
|
2009-12-17 02:53:26 +01:00
|
|
|
fatal("no passwd file entry for '%s'", SERVICE_LOGIN);
|
2006-10-20 17:01:32 +02:00
|
|
|
rs_start.rss_uid= pw->pw_uid;
|
|
|
|
|
2010-07-13 23:11:44 +02:00
|
|
|
rs_start.rss_sigmgr= DSRV_SM;
|
|
|
|
rs_start.rss_scheduler= DSRV_SCH;
|
|
|
|
rs_start.rss_priority= DSRV_Q;
|
|
|
|
rs_start.rss_quantum= DSRV_QT;
|
2010-07-20 09:27:45 +02:00
|
|
|
rs_start.rss_cpu = DSRV_CPU;
|
2010-07-01 10:32:33 +02:00
|
|
|
|
2007-01-22 16:25:41 +01:00
|
|
|
if (req_config) {
|
|
|
|
assert(progname);
|
|
|
|
do_config(progname, req_config);
|
|
|
|
}
|
2010-07-13 23:11:44 +02:00
|
|
|
|
|
|
|
assert(rs_start.rss_priority < NR_SCHED_QUEUES);
|
|
|
|
assert(rs_start.rss_quantum > 0);
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2008-02-21 17:20:22 +01:00
|
|
|
if (req_ipc)
|
|
|
|
{
|
|
|
|
rs_start.rss_ipc= req_ipc+1; /* Skip initial space */
|
|
|
|
rs_start.rss_ipclen= strlen(rs_start.rss_ipc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-13 23:11:44 +02:00
|
|
|
char *default_ipc = RSS_IPC_ALL_SYS;
|
|
|
|
rs_start.rss_ipc= default_ipc;
|
|
|
|
rs_start.rss_ipclen= strlen(default_ipc);
|
2008-02-21 17:20:22 +01:00
|
|
|
}
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
m.RS_CMD_ADDR = (char *) &rs_start;
|
|
|
|
break;
|
2005-10-20 22:31:18 +02:00
|
|
|
case RS_DOWN:
|
|
|
|
case RS_REFRESH:
|
2006-10-20 17:01:32 +02:00
|
|
|
case RS_RESTART:
|
2010-06-28 23:38:29 +02:00
|
|
|
case RS_CLONE:
|
2006-10-20 17:01:32 +02:00
|
|
|
m.RS_CMD_ADDR = req_label;
|
|
|
|
m.RS_CMD_LEN = strlen(req_label);
|
2005-10-21 15:28:26 +02:00
|
|
|
break;
|
2005-10-20 22:31:18 +02:00
|
|
|
case RS_SHUTDOWN:
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
break;
|
2005-08-02 18:00:07 +02:00
|
|
|
default:
|
|
|
|
print_usage(argv[ARG_NAME], "request is not yet supported");
|
|
|
|
result = EGENERIC;
|
|
|
|
}
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
|
|
|
|
/* Build request message and send the request. */
|
|
|
|
if(result == OK) {
|
2010-07-05 21:37:08 +02:00
|
|
|
if (_syscall(RS_PROC_NR, request, &m) == -1)
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
failure();
|
|
|
|
result = m.m_type;
|
|
|
|
}
|
|
|
|
|
2005-08-02 18:00:07 +02:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|