profile/ivi/node-startup-controller.git
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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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

11 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

11 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.

11 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.

11 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.

11 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

11 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

11 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.

11 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.

11 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.

11 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.

11 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.

11 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!

11 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.

11 years agoAdd convenience library 'libcommon.la'
Jonathan Maw [Thu, 28 Jun 2012 08:54:01 +0000 (09:54 +0100)]
Add convenience library 'libcommon.la'

Reference to individual components of the 'common' directory in
components' respective makefiles are replaced with reference to the
convenience library 'libcommon.la'

11 years agoAdd --register command-line option to LegacyAppHandler
Jonathan Maw [Tue, 26 Jun 2012 14:44:00 +0000 (15:44 +0100)]
Add --register command-line option to LegacyAppHandler

When legacy-app-handler is called without arguments, it starts as a
service, and as the primary instance of the LegacyAppHandler
GApplication.

When legacy-app-handler is called with arguments, it is started as a
remote instance of the LegacyAppHandler GApplication, which passes its
command-line arguments to the primary instance.

On receiving command-line arguments from a remote instance, the Primary
instance will parse those arguments, expecting a command like the
following:
  legacy-app-handler --register --unit="foo" --timeout=120 \
  --shutdown-mode="normal"

Timeout and shutdown-mode are optional, and if omitted will default to
0, and "normal", respectively.

Because interaction with the Node State Manager is not yet implemented,
the Legacy App Handler will print the arguments to DLT, instead of
registering the app as a shutdown consumer.

11 years agoRemove generated file from source tree
Jonathan Maw [Wed, 27 Jun 2012 10:22:59 +0000 (11:22 +0100)]
Remove generated file from source tree

org.genivi.LAHandler1.service is generated by
org.genivi.LAHandler1.service.in, so should not be tracked in the source
tree.

11 years agoImplement TargetStartupMonitor class
Jonathan Maw [Mon, 25 Jun 2012 11:54:34 +0000 (12:54 +0100)]
Implement TargetStartupMonitor class

This class listens to systemd's JobRemoved signal, and should respond if
it recognises one of the following units finishing:
- focussed.target
- unfocussed.target
- lazy.target

With the currently-used version of systemd, the unit name is not given.
At the current state of the project, the Node State Manager is not
available to communicate with.

11 years agoLog failure for the LUCStarter to start applications in DLT
Jonathan Maw [Fri, 22 Jun 2012 13:56:09 +0000 (14:56 +0100)]
Log failure for the LUCStarter to start applications in DLT

If the LUCStarter fails to start an application, it will log it as a
DLT_LOG_ERROR in DLT, instead of as a g_warning through GLib.

11 years agoInitialize/deinitialize DLT in boot-manager
Jonathan Maw [Fri, 22 Jun 2012 12:41:02 +0000 (13:41 +0100)]
Initialize/deinitialize DLT in boot-manager

The BootManager application (BMGR) is registered with the boot manager
context (MGR) in the main loop for the boot-manager programme.

11 years agoAdd dependency on DLT to the boot manager
Jonathan Maw [Fri, 22 Jun 2012 12:23:26 +0000 (13:23 +0100)]
Add dependency on DLT to the boot manager

11 years agoAllow SIGINT to cancel BootManagerService jobs
Jonathan Maw [Thu, 21 Jun 2012 14:41:25 +0000 (15:41 +0100)]
Allow SIGINT to cancel BootManagerService jobs

The function boot_manager_service_cancel() allows any part of the boot
manager to cancel every job being started by the BootManagerService.
The SIGINT handler in the BootManagerApplication includes a call to
boot_manager_service_cancel().

11 years agoMake BootManagerService handlers cancellable
Jonathan Maw [Thu, 21 Jun 2012 13:58:41 +0000 (14:58 +0100)]
Make BootManagerService handlers cancellable

All handlers get a cancellable which is associated with its invocation
in a GHashTable in the BootManagerService object.

11 years agoCancel all LUC app start operations when receiving SIGINT
Jonathan Maw [Wed, 20 Jun 2012 16:08:03 +0000 (17:08 +0100)]
Cancel all LUC app start operations when receiving SIGINT

We add a signal handler for SIGINT which calls the luc_starter_cancel()
method. luc_starter_cancel(), in turn, cancels every D-Bus call to
create a start unit job.
Unfortunately, once a start unit job has been created, cancelling will
not cancel the job to start a unit.

11 years agoAdd GCancellable handling to LUCStarter
Jonathan Maw [Wed, 20 Jun 2012 15:40:55 +0000 (16:40 +0100)]
Add GCancellable handling to LUCStarter

When systemd is told to start an app, it is passed a GCancellable object
so that the LUCStarter can cancel the start call.

Internally, the LUCStarter has a GHashTable associating each app with
its GCancellable.

Because start_app_finish requires the LUCStarter to start the next group
of apps, the LUCStarter must persist until all start jobs have finished.
For this reason, the start_app method increases the reference count to
the LUCStarter, and the start_app_finish method decreases the reference
count.

11 years agoAdd signal handler for List() method
Jonathan Maw [Tue, 19 Jun 2012 14:40:57 +0000 (15:40 +0100)]
Add signal handler for List() method

Boot-manager calls the systemd method ListUnits, and replies with only the unit
names.

11 years agoRemove accidentally second implementation of --enable-debug
Jannis Pohlmann [Tue, 19 Jun 2012 14:52:59 +0000 (15:52 +0100)]
Remove accidentally second implementation of --enable-debug

Something must have gone wrong while rebasing a feature branch
against master.

11 years agoMake sure to release starter order/groups when destroying LUCStarter
Jannis Pohlmann [Tue, 19 Jun 2012 09:07:00 +0000 (10:07 +0100)]
Make sure to release starter order/groups when destroying LUCStarter

11 years agoImplement basic asynchronous LUC startup without error handling
Jannis Pohlmann [Tue, 19 Jun 2012 08:57:30 +0000 (09:57 +0100)]
Implement basic asynchronous LUC startup without error handling

This commit adds support for LUC startup to LUCStarter. It first
creates the parallel startup groups, then sorts their names according
to PRIORITISED_LUC_TYPES and then asynchronously processes group by
group, starting all apps in a group in parallel.

The implementation does not support cancellation nor error handling
at this point.

11 years agoLink LUCHandler and LUCStarter. Parse prioritised LUC types
Jannis Pohlmann [Mon, 18 Jun 2012 10:04:44 +0000 (11:04 +0100)]
Link LUCHandler and LUCStarter. Parse prioritised LUC types