profile/ivi/node-startup-controller.git
11 years agoSpecify difference between NSM and NSM dummy in docmentation
Jonathan Maw [Wed, 1 Aug 2012 13:08:41 +0000 (14:08 +0100)]
Specify difference between NSM and NSM dummy in docmentation

Explicitly states the difference between the Node State Manager Dummy
and the real Node State Manager, i.e.
* The NSM dummy toggles between successfully setting the node state
  and failing to set the node state.
* The NSM dummy toggles between the LUC being required, and the LUC
  not being required.
* The NSM dummy will shut down its fast shutdown clients, then its
  normal shutdown clients, on receiving the SIGHUP signal

11 years agoAdd TSM test and improve layout of test document
Jonathan Maw [Wed, 1 Aug 2012 12:30:59 +0000 (13:30 +0100)]
Add TSM test and improve layout of test document

The improvements to the layout of the test document are that the
individual tests will now show up on the table of contents.

The Target Startup Monitor (TSM) tests check that the following cases
attempt to change the node state:
* The Node Startup Controller starting
* focussed.target starting
* unfocussed.target starting
* lazy.target starting

The following case should not attempt to change the node state:
* focussed.target stopping

11 years agoAdd testing skeleton
Jonathan Maw [Wed, 1 Aug 2012 09:22:54 +0000 (10:22 +0100)]
Add testing skeleton

Lays out the structure of the test document XML

11 years agoChange required version of systemd from 37 to 183
Jannis Pohlmann [Thu, 2 Aug 2012 14:15:55 +0000 (15:15 +0100)]
Change required version of systemd from 37 to 183

11 years agoFix build instructions to include creating the m4 directory
Jannis Pohlmann [Thu, 2 Aug 2012 14:14:03 +0000 (15:14 +0100)]
Fix build instructions to include creating the m4 directory

11 years agoUnregister exported D-Bus objects on finalization
Jonathan Maw [Thu, 2 Aug 2012 10:10:49 +0000 (11:10 +0100)]
Unregister exported D-Bus objects on finalization

Adds unregistration to the following services:
* legacy app handler
* shutdown client
* node startup controller
* nsm dummy lifecycle control
* nsm dummy consumer

11 years agoRework log messages a bit to make them more readable
Jannis Pohlmann [Wed, 1 Aug 2012 16:31:50 +0000 (17:31 +0100)]
Rework log messages a bit to make them more readable

11 years agoUse DLT_LOG_INFO rather than DLT_LOG_DEBUG for everything
Jannis Pohlmann [Wed, 1 Aug 2012 15:47:50 +0000 (16:47 +0100)]
Use DLT_LOG_INFO rather than DLT_LOG_DEBUG for everything

We can't get DLT to log our debug messages, setting LoggingLevel to 7
(LOG_DEBUG) in /etc/dlt.conf does not work as expected. So for now we'll
have to resort to logging all debug messages as info messages.

11 years agoAdjust DLT log levels (info -> debug, some warnings, some errors)
Jannis Pohlmann [Wed, 1 Aug 2012 15:04:02 +0000 (16:04 +0100)]
Adjust DLT log levels (info -> debug, some warnings, some errors)

11 years agoExclusively use DLT facilities to build log strings
Jannis Pohlmann [Wed, 1 Aug 2012 14:48:35 +0000 (15:48 +0100)]
Exclusively use DLT facilities to build log strings

We used to build the log strings using g_strdup_printf() but this
results in a certain amount of overhead and extra code.

11 years agoFix the name used for the LUCStarter::node-startup-controller property
Jannis Pohlmann [Wed, 1 Aug 2012 12:48:09 +0000 (13:48 +0100)]
Fix the name used for the LUCStarter::node-startup-controller property

11 years agoReplace g_debug/g_warning calls with DLT logging
Jannis Pohlmann [Wed, 1 Aug 2012 11:37:08 +0000 (12:37 +0100)]
Replace g_debug/g_warning calls with DLT logging

11 years agoUnregister the NSM dummy DLT connection at exit
Jannis Pohlmann [Wed, 1 Aug 2012 11:26:29 +0000 (12:26 +0100)]
Unregister the NSM dummy DLT connection at exit

11 years agoFix small issues in Makefiles to make "make distcheck" happy
Jannis Pohlmann [Tue, 31 Jul 2012 18:17:18 +0000 (19:17 +0100)]
Fix small issues in Makefiles to make "make distcheck" happy

11 years agoRename all remaining bits and pieces
Jannis Pohlmann [Tue, 31 Jul 2012 18:06:03 +0000 (19:06 +0100)]
Rename all remaining bits and pieces

11 years agoRename service files and boot-manager binary
Jannis Pohlmann [Tue, 31 Jul 2012 17:41:33 +0000 (18:41 +0100)]
Rename service files and boot-manager binary

11 years agoRename BMGR DLT app ID to NSC, rename MGR context to CTRL
Jannis Pohlmann [Tue, 31 Jul 2012 17:36:44 +0000 (18:36 +0100)]
Rename BMGR DLT app ID to NSC, rename MGR context to CTRL

11 years agoRename BootManagerApplication to NodeStartupControllerApplication
Jannis Pohlmann [Tue, 31 Jul 2012 17:32:30 +0000 (18:32 +0100)]
Rename BootManagerApplication to NodeStartupControllerApplication

11 years agoRename boot manager D-Bus interface and BootManagerService class
Jannis Pohlmann [Tue, 31 Jul 2012 17:15:06 +0000 (18:15 +0100)]
Rename boot manager D-Bus interface and BootManagerService class

11 years agoFirst step of renaming the Boot Manager to Node Startup Controller
Jannis Pohlmann [Tue, 31 Jul 2012 16:45:10 +0000 (17:45 +0100)]
First step of renaming the Boot Manager to Node Startup Controller

This includes mostly files, directories and the package/tarball name.
The classes and D-Bus interfaces will be renamed in the next step.

11 years agoQuery the "active-state" property of units in the "job-removed" handler
Francisco Redondo Marchena [Tue, 31 Jul 2012 15:52:06 +0000 (16:52 +0100)]
Query the "active-state" property of units in the "job-removed" handler

Our previous attempt to fix the TargetStartupMonitor failed because when
a target is stopped, systemd drops the unit from the system bus and the
proxies we created in TargetStartupMonitor were no longer associated
with these unit objects that previously existed on the bus. When such a
target is started again, the proxy will no longer receive property
change signals from systemd.

This commit tries to implement the TargetStartupMonitor in yet another
way, which is to listen to systemd's "job-removed" signal again. In
response to receiving "job-removed" signals, we now create a SystemdUnit
for the affected unit and query that for its current "active-state"
value. Perhaps this will work.

11 years agoAvoid a segmentation fault by fixing a GVariant format string
Francisco Redondo Marchena [Tue, 31 Jul 2012 15:17:07 +0000 (16:17 +0100)]
Avoid a segmentation fault by fixing a GVariant format string

11 years agoRetrieve invalidated properties before emitting "g-properties-changed"
Francisco Redondo Marchena [Tue, 31 Jul 2012 14:55:51 +0000 (15:55 +0100)]
Retrieve invalidated properties before emitting "g-properties-changed"

It seems like the "active-state" property might be part of the
invalidated properties, not the changed ones. By passing
G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES to the proxy constructor
we force GDBusProxy to retrieve the new "active-state" value before
calling "g-properties-changed".

Hopefully this will fix TargetStartupMonitor for real.

11 years agoTry the units' "g-properties-changed" signal to monitor the active state
Francisco Redondo Marchena [Tue, 31 Jul 2012 14:34:23 +0000 (15:34 +0100)]
Try the units' "g-properties-changed" signal to monitor the active state

For some reason the cached "active-state" property of the SystemdUnit
objects was NULL even when the "notify::active-state" signal had been
emitted.

11 years agoRemove the assertion for an unused parameter
Francisco Redondo Marchena [Tue, 31 Jul 2012 13:55:35 +0000 (14:55 +0100)]
Remove the assertion for an unused parameter

Apparently the callback for g_dbus_proxy_new() does not receive a
GDBusConnection as the first parameter, so this assertion fails.
However, since we don't need the parameter, we can just drop the
assertion.

11 years agoRework small bits of the legacy-app-handler documentation
Jannis Pohlmann [Tue, 31 Jul 2012 15:12:24 +0000 (16:12 +0100)]
Rework small bits of the legacy-app-handler documentation

11 years agoDocument the legacy app handler API
Jonathan Maw [Tue, 31 Jul 2012 14:57:40 +0000 (15:57 +0100)]
Document the legacy app handler API

11 years agoRewrite TargetStartupMonitor to monitor ActiveState properties of units
Jannis Pohlmann [Tue, 31 Jul 2012 12:20:06 +0000 (13:20 +0100)]
Rewrite TargetStartupMonitor to monitor ActiveState properties of units

11 years agoTry to query systemd jobs synchronously in the "job-removed" handler
Francisco Redondo Marchena [Tue, 31 Jul 2012 10:17:05 +0000 (11:17 +0100)]
Try to query systemd jobs synchronously in the "job-removed" handler

When we query the jobs asynchronously, systemd might have removed the
job we are looking for, and it will not be in the list of jobs it
returns. Perhaps querying jobs synchronously in the "job-removed"
handler helps to work around that.

11 years agoRevert "Indicate the system manager that the job remove callback finished."
Francisco Redondo Marchena [Tue, 31 Jul 2012 10:03:05 +0000 (11:03 +0100)]
Revert "Indicate the system manager that the job remove callback finished."

This reverts commit 97e53e2458589c5a7f7ad65b5af45626fa4d1ea1.

The "job-removed" signal doesn't expect signal handlers to return a
boolean value, so adding such a return value to our handlers will not
have any effect.

11 years agoFix built sources not always being built in common/Makefile.am
Jannis Pohlmann [Tue, 31 Jul 2012 09:59:17 +0000 (10:59 +0100)]
Fix built sources not always being built in common/Makefile.am

11 years agoAdd missing parentheses in macro definitions
Jannis Pohlmann [Tue, 31 Jul 2012 09:52:06 +0000 (10:52 +0100)]
Add missing parentheses in macro definitions

These are difficult to spot but shouldn't have caused any problems
so far because we never use the affected macros in our code.

11 years agoRemove LUC registration debug output
Jannis Pohlmann [Tue, 31 Jul 2012 09:45:28 +0000 (10:45 +0100)]
Remove LUC registration debug output

11 years agoIndicate the system manager that the job remove callback finished.
Francisco Redondo Marchena [Tue, 31 Jul 2012 07:15:28 +0000 (08:15 +0100)]
Indicate the system manager that the job remove callback finished.

Return a boolean to indicate is the job remove callback was
successful or failure.

11 years agoAdd even more debug output to TargetStartupMonitor
Francisco Redondo Marchena [Mon, 30 Jul 2012 17:04:31 +0000 (18:04 +0100)]
Add even more debug output to TargetStartupMonitor

11 years agoAdd more debugging output to TargetStartupMonitor
Francisco Redondo Marchena [Mon, 30 Jul 2012 16:31:55 +0000 (17:31 +0100)]
Add more debugging output to TargetStartupMonitor

11 years agoFix missing build rules for .c files of generated D-Bus sources
Francisco Redondo Marchena [Mon, 30 Jul 2012 16:09:33 +0000 (17:09 +0100)]
Fix missing build rules for .c files of generated D-Bus sources

The order in which make processes the source files can be random. So
sometimes it will pick the -dbus.c file before the -dbus.h file. This
commit makes sure that we have a rule to build both in the Makefile.am
instead of just having a rule for the -dbus.h file.

11 years agoRemove unused org.freedesktop.systemd1.Manager D-Bus methods
Jannis Pohlmann [Mon, 30 Jul 2012 14:51:04 +0000 (15:51 +0100)]
Remove unused org.freedesktop.systemd1.Manager D-Bus methods

We don't need to generate code for these methods unless we actually
intend to use them.

11 years agoSet the node state only in response to start jobs
Francisco Redondo Marchena [Mon, 30 Jul 2012 13:21:23 +0000 (14:21 +0100)]
Set the node state only in response to start jobs

The node state only should be set it for systemd start jobs.
To avoid setting the node state for other types of jobs like kill,
stop etc. we query systemd for a list of all jobs and check if
the type of the removed job is "start". Only then do we change
the node state.

11 years agoApply a few changes to fix make distcheck and regular builds
Jannis Pohlmann [Mon, 30 Jul 2012 14:43:14 +0000 (15:43 +0100)]
Apply a few changes to fix make distcheck and regular builds

11 years agoAdd initial version of the reference manual templates
Jannis Pohlmann [Mon, 30 Jul 2012 13:45:54 +0000 (14:45 +0100)]
Add initial version of the reference manual templates

Most of the chapters in this manual still need to be written but this
is a start.

11 years agoAdd rudimentary gtk-doc support to the project
Jannis Pohlmann [Fri, 20 Jul 2012 14:24:52 +0000 (15:24 +0100)]
Add rudimentary gtk-doc support to the project

This includes adjusting the configure script to check for gtk-doc as
well as creating the necessary directories and Makefile.am files.

At the moment, no documentation is generated. We'll have to add initial
templates that include the docbook XML generated for the D-Bus API.

11 years agoAdd option to gdbus-codegen to generate DocBook for the public interface
Francisco Redondo Marchena [Fri, 20 Jul 2012 11:41:29 +0000 (12:41 +0100)]
Add option to gdbus-codegen to generate DocBook for the public interface

Add --generate-docbook to gdbus-codegen in Makefile.am in order to
get the documentation for org.genivi.BootManager1.BootManager
interface. It makes a .xml file called
boot-manager-dbus-doc-org.genivi.BootManager1.BootManager.xml

11 years agoAdd build dependencies to the README file
Jannis Pohlmann [Mon, 30 Jul 2012 12:18:38 +0000 (13:18 +0100)]
Add build dependencies to the README file

11 years agoAdd licensing/build/testing instructions to the README file
Jannis Pohlmann [Mon, 30 Jul 2012 12:12:41 +0000 (13:12 +0100)]
Add licensing/build/testing instructions to the README file

11 years agoFix make distcheck, rework tests, reorganise files
Jannis Pohlmann [Fri, 27 Jul 2012 15:50:22 +0000 (16:50 +0100)]
Fix make distcheck, rework tests, reorganise files

This commit fixes make distcheck by making the LUC handler test part of
"make installcheck" and by disabling the legacy app tests in "make
check".

For the LUC handler test to not interfere with the LUC on the system,
the boot-manager binary is now aware of a LUC_PATH environment variable
that overrides the LUC_PATH string defined at build-time. This way we
can use a different LUC file for the test.

This commit also drops the nsm-dummy/dbus/ and nsm-dummy/systemd/
directories and moves the corresponding files to nsm-dummy/.

11 years agoFix a crash caused by using the old JobRemoved signature in JobManager
Jannis Pohlmann [Sat, 28 Jul 2012 15:27:08 +0000 (16:27 +0100)]
Fix a crash caused by using the old JobRemoved signature in JobManager

The signature of the JobRemoved signal recently changed in systemd, when
a new "unit" parameter was added. This commit changes the JobManager to
include this parameter in its JobRemoved handler and thereby avoids
segmentation faults caused by assuming fourth parameter is a JobManager
object.

11 years agoLog more information when completing lifecycle requests
Jannis Pohlmann [Sat, 28 Jul 2012 14:41:47 +0000 (15:41 +0100)]
Log more information when completing lifecycle requests

11 years agoUse $(sysconfdir) and $(libdir) in NSM dummy Makefiles
Jannis Pohlmann [Fri, 27 Jul 2012 16:43:15 +0000 (17:43 +0100)]
Use $(sysconfdir) and $(libdir) in NSM dummy Makefiles

11 years agoSet node state in the TargetStartupMonitor when certain targets started
Francisco Redondo Marchena [Fri, 27 Jul 2012 12:55:18 +0000 (13:55 +0100)]
Set node state in the TargetStartupMonitor when certain targets started

Set the node state from the TargetStartupMonitor when certain targets
have been started (focussed, unfocussed, lazy).

Also, add a NSMNodeState enum type to nsm-enum-types.{c,h}.

11 years agoUse the WATCHDOG_USEC env variable to define the watchdog timeout
Jannis Pohlmann [Fri, 27 Jul 2012 13:27:15 +0000 (14:27 +0100)]
Use the WATCHDOG_USEC env variable to define the watchdog timeout

Also, set WatchdogSec to 5 seconds in boot-manager.service.in and
nsm-dummy.service.in.

The way this works is that systemd will take the WatchdogSec value,
convert it to micro-seconds and set the WATCHDOG_USEC environment
variable for the boot manager or nsm-dummy process. The boot manager
or NSM dummy then halves that value and creates the WatchdogClient
so that it calls sd_notify(0, WATCHDOG=1) twice in each
WATCHDOG_USEC interval. If WATCHDOG_USEC can't be parsed into a
number or if it is not set, the systemd watchdog timestamp is
never updated.

This is what systemd's requires services to do in order to support its
watchdog feature properly.

11 years agoAdd 'luc-groups-started' signal to send sd_notify(READY=1) to systemd
Jannis Pohlmann [Fri, 27 Jul 2012 11:29:43 +0000 (12:29 +0100)]
Add 'luc-groups-started' signal to send sd_notify(READY=1) to systemd

We need to notify systemd when the boot manager process has finished
starting the LUC. What we did so far was to call sd_notify() while
constructing the BootManagerApplication. This commit adds a
'luc-groups-started' signal to LUCStarter. BootManagerApplication now
connects to that in order to call sd_notify() at the right time.

11 years agoUnregister the boot manager itself as a shutdown client
Francisco Redondo Marchena [Thu, 26 Jul 2012 17:42:44 +0000 (18:42 +0100)]
Unregister the boot manager itself as a shutdown client

Unregister the boot manager as a shutdown client after it has been
shutting down. Handle gracefully the application lifecycle request to
manage the shutting down and the unregistration correctly.

11 years agoAvoid compiler warnings due to casting pointers to uint
Francisco Redondo Marchena [Thu, 26 Jul 2012 17:40:12 +0000 (18:40 +0100)]
Avoid compiler warnings due to casting pointers to uint

11 years agoCheck with NSM whether to load the LUC or not
Francisco Redondo Marchena [Thu, 26 Jul 2012 15:26:40 +0000 (16:26 +0100)]
Check with NSM whether to load the LUC or not

If the NSM is not available or the NSMLifecycleControl proxy cannot be
created, we assume that we should start the LUC anyway.

11 years agoUpon receiving SIGHUP, shut down all clients asynchronously
Jannis Pohlmann [Thu, 26 Jul 2012 16:25:35 +0000 (17:25 +0100)]
Upon receiving SIGHUP, shut down all clients asynchronously

This is done by asynchronously processing the list of registered
shutdown clients once for each shutdown mode. We start with fast and
then continue with normal once all clients registered for fast shutdown
have been shut down.

This commit also implements waiting for pending lifecycle requests using
a timeout and advances to the next client in the queue if the timeout is
triggered before LifecycleRequestComplete is called by the client we are
currently waiting for.

11 years agoMake sure to release the NSMConsumer in LAHandlerService
Jannis Pohlmann [Thu, 26 Jul 2012 15:59:49 +0000 (16:59 +0100)]
Make sure to release the NSMConsumer in LAHandlerService

Otherwise we'd be leaking memory

11 years agoFix LifecycleRequest handler by returning a boolean value
Jannis Pohlmann [Thu, 26 Jul 2012 13:07:59 +0000 (14:07 +0100)]
Fix LifecycleRequest handler by returning a boolean value

This caused a GLib-internal critical warning about g_object_unref being
called with something that wasn't a GObject. It works fine now.

11 years agoRegister boot manager itself as a shutdown consumer asynchronously
Francisco Redondo Marchena [Thu, 26 Jul 2012 11:12:31 +0000 (12:12 +0100)]
Register boot manager itself as a shutdown consumer asynchronously

Replace the synchronous registration by an asynchronous
registration for the boot manager. Gracefully handle/ignore any
errors in the finish callback apart from logging them using the DLT
framework.

11 years agoRemove debugging output we no longer need
Jannis Pohlmann [Thu, 26 Jul 2012 12:43:15 +0000 (13:43 +0100)]
Remove debugging output we no longer need

11 years agoMake NSMShutdownType a flags type rather than an enum type
Jannis Pohlmann [Thu, 26 Jul 2012 12:41:33 +0000 (13:41 +0100)]
Make NSMShutdownType a flags type rather than an enum type

This makes more sense because enums are not supposed to be combined
using bitwise operators. Flags, however, exist exactly for this
purpose.

11 years agoMove deregistration of shutdown consumers into LAHandlerService
Jannis Pohlmann [Thu, 26 Jul 2012 12:39:11 +0000 (13:39 +0100)]
Move deregistration of shutdown consumers into LAHandlerService

LAHandlerService is a better place for this functionalit than
BootManagerApplication. Apart from this deregistration, anything related
to legacy app shutdown consumers is already handled solely by the
LAHandlerService anyway, so it makes sense to move the deregistration
there as well.

11 years agoAllow shutdown consumers for legacy apps to be re-registered
Jannis Pohlmann [Thu, 26 Jul 2012 12:36:52 +0000 (13:36 +0100)]
Allow shutdown consumers for legacy apps to be re-registered

Until now we always ignored re-registrations of legacy apps. In order
to allow the shutdown mode or timeout of a shutdown consumer for a
legacy app to be updated, however, this commit now forwards legacy app
re-registrations to the NSM.

11 years agoUse an int for the --shutdown-mode/-m option of legacy-app-handler
Jannis Pohlmann [Thu, 26 Jul 2012 10:51:35 +0000 (11:51 +0100)]
Use an int for the --shutdown-mode/-m option of legacy-app-handler

This allows to register for multiple modes at the same time, e.g. by
passing in 3 for normal and fast.

11 years agoHandle re-registration of shutdown clients by updating the mode/timeout
Jannis Pohlmann [Thu, 26 Jul 2012 10:10:16 +0000 (11:10 +0100)]
Handle re-registration of shutdown clients by updating the mode/timeout

Whenever a shutdown client (now identified only by the bus name and
object path instead of bus name, object path and shutdown mode) is
registered a second or third time, we simply update the shutdown mode
by combining the old and new one with a bitwise OR. The shutdown
timeout is also replaced with the new one.

11 years agoDeregister shutdown consumer when shutting down boot manager
Francisco Redondo Marchena [Wed, 25 Jul 2012 14:05:52 +0000 (15:05 +0100)]
Deregister shutdown consumer when shutting down boot manager

Implement deregister shutdown consumer when boot manager is
shutting down. Change the shutdown tables replacing shutdown
consumers by shutdown clients. Modify in the same terms the
boot manager registration (from shutdown consumer registration
to shutdown client registration).

11 years agoFix the previous commit, forgot to rename the SIGINT handler
Jannis Pohlmann [Wed, 25 Jul 2012 14:20:51 +0000 (15:20 +0100)]
Fix the previous commit, forgot to rename the SIGINT handler

11 years agoUse SIGHUP instead of SIGINT for simulating an NSM shutdown
Jannis Pohlmann [Wed, 25 Jul 2012 13:55:27 +0000 (14:55 +0100)]
Use SIGHUP instead of SIGINT for simulating an NSM shutdown

In the SIGHUP handler, we no longer shut down the NSM process so that we
can keep it around for debugging purposes.

11 years agoFix corrupted list after reverse shutdown client traversal
Jannis Pohlmann [Wed, 25 Jul 2012 13:52:06 +0000 (14:52 +0100)]
Fix corrupted list after reverse shutdown client traversal

The problem is that g_list_reverse() modifies the list in place, so in
order to not corrupt the shutdown client list of the NSMConsumerService,
we would have to copy the list. What this commit does instead is to not
call g_list_reverse() and instead traverse the list in reverse order
directly.

This commit also improves the shutdown logging a bit.

11 years agoImplement the LifecycleRequestComplete by logging request ID and status
Jannis Pohlmann [Wed, 25 Jul 2012 13:49:33 +0000 (14:49 +0100)]
Implement the LifecycleRequestComplete by logging request ID and status

11 years agoStart the boot manager D-Bus services in main()
Jannis Pohlmann [Wed, 25 Jul 2012 13:45:44 +0000 (14:45 +0100)]
Start the boot manager D-Bus services in main()

Before we started them in boot_manager_application_constructed() but
that meant that we could not react to errors properly. We now log a
fatal error using the DLT framework and exit if we can't bring up the
D-Bus services.

11 years agoImprove shutdown handling, keep shutdown clients around afterwards
Jannis Pohlmann [Tue, 24 Jul 2012 15:51:11 +0000 (16:51 +0100)]
Improve shutdown handling, keep shutdown clients around afterwards

Use the new ShutdownClient class to bundle information about registered
shutdown clients and their units, modes and timeouts.

Do not remove shutdown clients from the registered clients list after
shutting them down. Instead, wait for a separate unregister request.

Shut clients down mode by mode when receiving SIGINT. Start with clients
registered for fast, then continue with clients registered for normal.

Improve logging output a little bit.

11 years agoAdd new ShutdownClient class to bundle information about consumers
Jannis Pohlmann [Tue, 24 Jul 2012 16:18:14 +0000 (17:18 +0100)]
Add new ShutdownClient class to bundle information about consumers

Objects of this class store the bus name, the object path, the shutdown
mode, the shutdown timeout and a ShutdownConsumer proxy or skeleton for
a shutdown consumer.

11 years agoImplement a shutdown consumer for the boot manager itself
Francisco Redondo Marchena [Tue, 24 Jul 2012 12:16:04 +0000 (13:16 +0100)]
Implement a shutdown consumer for the boot manager itself

Create a ShutdownConsumer skeleton in BootManagerApplication and
implement its "handle-lifecycle-request" signal to shutdown the
process.

In addition to that, the "handle-lifecycle-request" implementation also
cancels the LUC startup. It replaces the SIGINT handler, which is
removed with this commit.

11 years agoFix the systemd unit associated with the boot manager D-Bus service
Jannis Pohlmann [Tue, 24 Jul 2012 13:19:32 +0000 (14:19 +0100)]
Fix the systemd unit associated with the boot manager D-Bus service

11 years agoRename gvariant_writer.c to gvariant-writer.c
Jannis Pohlmann [Tue, 24 Jul 2012 13:18:50 +0000 (14:18 +0100)]
Rename gvariant_writer.c to gvariant-writer.c

We don't use underscores in filenames anywhere else so why would we do
that here?

11 years agoAdd a stand-alone legacy-app-handler helper, work on tests
Jannis Pohlmann [Mon, 23 Jul 2012 16:41:17 +0000 (17:41 +0100)]
Add a stand-alone legacy-app-handler helper, work on tests

The new legacy-app-helper binary translates the shutdown mode strings
into NSMShutdownType enum values and passes them on to the legacy app
handler D-Bus service. Thus, this commit also updates the
org.genivi.BootManager1.LegacyAppHandler interface to use an int for the
shutdown mode.

This commit furthermore drops the old command-line handling code in
the boot manager and reworks the legacy-app-handler tests a little
bit.

11 years agoDefine enums for shutdown mode, error and status code.
Francisco Redondo Marchena [Mon, 23 Jul 2012 15:18:43 +0000 (16:18 +0100)]
Define enums for shutdown mode, error and status code.

Define enums for shutdown mode, error and status code.

11 years agoDrop GApplication, fix D-Bus activation, further NSM integration work
Jannis Pohlmann [Fri, 20 Jul 2012 16:06:42 +0000 (17:06 +0100)]
Drop GApplication, fix D-Bus activation, further NSM integration work

We no longer want GApplication because (a) D-Bus already guarantees that
there is only one unique instance that provides a certain service, (b)
we no longer use the GApplication command-line forwarding anyway and (c)
there might be no session bus anyway. We want to own the bus names on
the system bus and GApplication doesn't help with that.

The D-Bus activation did not work for various reasons: (a) the systemd
.service files had the type set to "notify" instead of "dbus" and also
had BusName set to "foo.bar.baz.service" where it should be just
"foo.bar.baz", (b) the NSM dummy .service files for D-Bus were pointing
to the wrong systemd .service files and were installed under the wrong
name (I think there needs to be one .service file per interface, but
this may not be 100% true).

The rest of this commit is changes necessary for the integration of
the Node State Manager.

11 years agoUpdate NSM-related D-Bus interfaces and codegen
Jonathan Maw [Fri, 20 Jul 2012 10:14:02 +0000 (11:14 +0100)]
Update NSM-related D-Bus interfaces and codegen

Change all instances of conti to contiautomotive in bus names, object
paths and interfaces.

Change shutdown consumers' interface to
com.contiautomotive.NodeStateManager.LifeCycleConsumer and replace the
Shutdown() method with a LifecycleRequest() method which takes arguments
"Request", "RequestId" and returns "ErrorCode".

In addition, this commit removes the ShutdownConsumerService object and
handles all shutdown consumers directly in the legacy app handler.

11 years agoInstall boot-manager.service to $(libdir) rather than /lib
Francisco Redondo Marchena [Mon, 23 Jul 2012 10:28:18 +0000 (11:28 +0100)]
Install boot-manager.service to $(libdir) rather than /lib

Installing to /lib causes troubly when building the boot manager as part
of the Yocto-based GENIVI Excalibur baseline.

12 years agoImprove use of GError and writing to the LUC
Jannis Pohlmann [Thu, 19 Jul 2012 15:24:08 +0000 (16:24 +0100)]
Improve use of GError and writing to the LUC

Make use of convenience functions for clearing and propagating GErrors.
Drop g_file_create() because g_file_replace_contents() handles the
on-demand file creation for us.

12 years agoFix/finish implementation of integer-based LUC types
Jannis Pohlmann [Thu, 19 Jul 2012 14:53:53 +0000 (15:53 +0100)]
Fix/finish implementation of integer-based LUC types

This commit fixes the use of integers as keys for GHashTable. It also
parses the prioritised LUC types into integer values and stores them
in a GArray. The code for computing the start order is updated to also
use integers for the startup groups.

This change also fixes luc_starter_compare_luc_types(), which (a) didn't
work at all and (b) had to be converted to comparing integers, not
strings.

12 years agoUse $(sysconfdir)/boot-manager/last-user-context to store the LUC file
Jannis Pohlmann [Thu, 19 Jul 2012 12:46:11 +0000 (13:46 +0100)]
Use $(sysconfdir)/boot-manager/last-user-context to store the LUC file

$(sysconfdir) is where system-wide configuration files belong.

12 years agoImprove the initial construction of the GVariant for the new LUC
Jannis Pohlmann [Thu, 19 Jul 2012 12:28:58 +0000 (13:28 +0100)]
Improve the initial construction of the GVariant for the new LUC

The GVariantBuilder is now statically allocated on the stack to avoid
memory allocations at run-time. Using g_variant_builder_end() is used
to obtain the new GVariant rather than allocating a new one from the
contents of the builder separately.

12 years agoAdd a dummy-implementation of the Node State Manager and use it
Francisco Redondo Marchena [Mon, 25 Jun 2012 17:15:00 +0000 (18:15 +0100)]
Add a dummy-implementation of the Node State Manager and use it

The Node State Manager (NSM) dummy has all the interfaces relevant
to the Boot Manager, and can be instructed to shut down all its
shutdown consumers when a SIGINT signal is sent.

The Legacy App Handler will connect to the NSM dummy and register
shutdown consumers to it.

12 years agoMove service files back to source directory, rename systemd service file
Jannis Pohlmann [Thu, 19 Jul 2012 11:01:57 +0000 (12:01 +0100)]
Move service files back to source directory, rename systemd service file

12 years agoApply a few coding style fixes and adjust a few debug messages
Jannis Pohlmann [Wed, 18 Jul 2012 13:27:49 +0000 (14:27 +0100)]
Apply a few coding style fixes and adjust a few debug messages

12 years agoInclude org.genivi.BootManager1.conf in EXTRA_DIST
Jannis Pohlmann [Wed, 18 Jul 2012 10:08:43 +0000 (11:08 +0100)]
Include org.genivi.BootManager1.conf in EXTRA_DIST

This is needed for "make dist" and "make distcheck" to work. However,
"make distcheck" currently doesn't work, most likely because the tests
cannot be executed automatically without test files being installed to
the system first.

12 years agoMerge branch 'franred/drop-rebase' of roadtrain.codethink.co.uk:genivi/boot-manager
Ben Brewer [Tue, 17 Jul 2012 14:53:04 +0000 (15:53 +0100)]
Merge branch 'franred/drop-rebase' of roadtrain.codethink.co.uk:genivi/boot-manager

Merge into one process, change D-Bus interfaces and write LUC to file

The following changes were made:
- Restructure the D-Bus interfaces:
--  The old boot manager interface is removed, we are no longer
    interested in being a remote controller of systemd.
--  The LUC Handler has been rewritten and renamed to
    org.genivi.BootManager1.BootManager. It has the following
    methods:
---   BeginLUCRegistration() initializes the LUC registration
      sequence at shutdown.
---   RegisterWithLUC(a{ias}) registers one or more apps with
      different LUC types.
---   FinishLUCRegistration() finishes the LUC registration
      sequence and atomically replaces the previous LUC.
--  The legacy application handler has been renamed to
    org.genivi.BootManager1.LegacyAppHandler. This interface
    is not for external use. It is meant only for the command-
    line interface to communicate with the boot manager.
--  The LastUserContext property has been removed.
- The last user context is now stored in a file rather than with
  GSettings. This was requested after the Gothenburg F2F, but is
  included because it is easier to make the change now than modify
  GSettings only to remove it later.
- All services run as part of the same process (i.e. boot-manager).
- All services run on the system bus. Because of this, the boot
  manager's command-line interface is handled differently, as the
  previous implementation, using GApplication, does not work on the
  system bus. The command-line interface now works by making a D-Bus
  call to the boot manager service, instead of using GApplication's
  remote command-line functionality.
- The LUC Handler tests have been renamed to the boot manager
  tests, and are changed in line with the new interface methods.

12 years agoMerge into one process, change D-Bus interfaces and write LUC to file
Jonathan Maw [Mon, 9 Jul 2012 11:53:25 +0000 (12:53 +0100)]
Merge into one process, change D-Bus interfaces and write LUC to file

The following changes were made:
- Restructure the D-Bus interfaces:
--  The old boot manager interface is removed, we are no longer
    interested in being a remote controller of systemd.
--  The LUC Handler has been rewritten and renamed to
    org.genivi.BootManager1.BootManager. It has the following
    methods:
---   BeginLUCRegistration() initializes the LUC registration
      sequence at shutdown.
---   RegisterWithLUC(a{ias}) registers one or more apps with
      different LUC types.
---   FinishLUCRegistration() finishes the LUC registration
      sequence and atomically replaces the previous LUC.
--  The legacy application handler has been renamed to
    org.genivi.BootManager1.LegacyAppHandler. This interface
    is not for external use. It is meant only for the command-
    line interface to communicate with the boot manager.
--  The LastUserContext property has been removed.
- The last user context is now stored in a file rather than with
  GSettings. This was requested after the Gothenburg F2F, but is
  included because it is easier to make the change now than modify
  GSettings only to remove it later.
- All services run as part of the same process (i.e. boot-manager).
- All services run on the system bus. Because of this, the boot
  manager's command-line interface is handled differently, as the
  previous implementation, using GApplication, does not work on the
  system bus. The command-line interface now works by making a D-Bus
  call to the boot manager service, instead of using GApplication's
  remote command-line functionality.
- The LUC Handler tests have been renamed to the boot manager
  tests, and are changed in line with the new interface methods.

Note: The legacy app handler tests have not yet been modified to work
      with these changes.

12 years agoMake the legacy app handler work on the system bus
Ben Brewer [Tue, 10 Jul 2012 14:53:05 +0000 (15:53 +0100)]
Make the legacy app handler work on the system bus

This patch in its entirety makes the legacy app handler start on the
system bus, instead of the session bus, along with giving it fully-
functional command-line registration. It will start automatically if a
process tries to call one of its D-Bus methods.

Merge branch 'jonathanmaw/legacy-app-handler-system-bus' of roadtrain:genivi/boot-manager

12 years agoThree ExecStartPost systemd unit files
Ben Brewer [Tue, 10 Jul 2012 14:31:39 +0000 (15:31 +0100)]
Three ExecStartPost systemd unit files

Having some services to test on is important. These three will acquire
a bus name and use the CLI to register themselves with the legacy app
handler.

Merge branch 'jonathanmaw/legacy-app-handler-test' of roadtrain:genivi/boot-manager

12 years agoRewrite legacy app handler's command-line to use D-Bus
Jonathan Maw [Mon, 9 Jul 2012 15:15:07 +0000 (16:15 +0100)]
Rewrite legacy app handler's command-line to use D-Bus

The GApplication object's command-line method does not work when the
application is running on the system bus. The solution is to use D-Bus
calls to communicate with the primary instance instead.

If the executable is called with command-line arguments, instead of
starting a GApplication it calls the Register() and Deregister()
methods instead.

This commit also adds all the necessary changes so that the legacy app
handler can be D-Bus activated on the system bus and started with
systemd.

12 years agoChange legacy app handler to register on the system bus
Jonathan Maw [Fri, 6 Jul 2012 12:51:03 +0000 (13:51 +0100)]
Change legacy app handler to register on the system bus

Makes the legacy app handler connect to the system bus instead of the
session bus.

This commit also changes bus names to consistently use LegacyAppHandler1
instead of LAHandler1.

This commit does not allow communication with the legacy app handler by
command-line. The following commit will provide this.

This commit does not provide a way to start the legacy app handler
through systemd. The following commit also provides this.

12 years agoAdd shutdown consumers
Ben Brewer [Mon, 9 Jul 2012 14:51:40 +0000 (15:51 +0100)]
Add shutdown consumers

Significant changes:
- Getters were made to return const strings.
- The object_path property of the legacy app handler was made const.
- DLT log levels changed in some places.
- in la_handler_service_handle_consumer_shutdown_finish, logic has been
  changed to not compare the value of "result" unless there were no
  errors, because boot_manager_call_stop_finish does not necessarily
  always give a valid pointer.

12 years agoDefine three systemd service unit files with ExecStartPost set
Jonathan Maw [Thu, 28 Jun 2012 14:06:42 +0000 (15:06 +0100)]
Define three systemd service unit files with ExecStartPost set

Files org.genivi.LegacyAppHandler1.test{1,2,3}.service.in will build
into appropriate *.service files.

Each one will run legacy-app-handler with --register as an
ExecStartPost.

Each one is installed to /lib/systemd/system and has an ExecStart
process which is to acquire a Bus Name.

A .conf file has rules to allow processes to own
org.genivi.LegacyAppHandler1.test{1,2,3}, and appears to work as
planned.

12 years agoCreate a shutdown consumer object for every --register activation
Jonathan Maw [Wed, 27 Jun 2012 16:46:51 +0000 (17:46 +0100)]
Create a shutdown consumer object for every --register activation

On receiving a --register command line, or a call to the Register()
method, the legacy app handler will create a shutdown consumer object
(although it will not register it with the NSM yet). When something
(e.g. the NSM) tells the shutdown consumer to shut down, it emits the
signal "shutdown-requested", which the Legacy App Handler listens for.
The Legacy App Handler responds to the "shutdown-requested" signal by
calling the boot manager's Stop() method.

12 years agoRelease 0.1.0! boot-manager-0.1.0
Jannis Pohlmann [Fri, 29 Jun 2012 14:35:05 +0000 (15:35 +0100)]
Release 0.1.0!

12 years agoDefine D-Bus interface for Shutdown Consumers
Jonathan Maw [Wed, 27 Jun 2012 10:07:47 +0000 (11:07 +0100)]
Define D-Bus interface for Shutdown Consumers

Shutdown Consumers are D-Bus objects that exist for every application
that does not have a Shutdown() method, and are registered with the Node
State Manager (NSM).

When the NSM shuts down, it calls Shutdown() to all Shutdown Consumers
in reverse order to their registration. For legacy applications, a
Shutdown Consumer is created and registered with the NSM.

When the Shutdown Consumer is told to shut down, it shuts down the
legacy application by signalling the Boot Manager.