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

12 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().

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

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

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

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

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

12 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

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

12 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

12 years agoAdd LUCHandler class skeleton and "luc-handler" property in the app
Jannis Pohlmann [Fri, 15 Jun 2012 15:42:00 +0000 (16:42 +0100)]
Add LUCHandler class skeleton and "luc-handler" property in the app

12 years agoAdd --with-prioritised-luc-types=foo,bar configure option
Jannis Pohlmann [Fri, 15 Jun 2012 15:29:09 +0000 (16:29 +0100)]
Add --with-prioritised-luc-types=foo,bar configure option

This option results in a PRIORITISED_LUC_TYPES define in config.h. The
LUCStarter can then parse that to find out in which order to start the
applications in the LUC.

12 years agoAdd Isolate() method handler
Jonathan Maw [Tue, 19 Jun 2012 11:31:22 +0000 (12:31 +0100)]
Add Isolate() method handler

Isolate() is different from Start() and Stop() in that it does not have
its own method. Instead, it is done by calling StartUnit() with the
special mode "isolate".

12 years agoAdd Restart() handler
Jonathan Maw [Tue, 19 Jun 2012 10:41:56 +0000 (11:41 +0100)]
Add Restart() handler

Restart() functions almost identically to Start() and Stop(), with the
same input and output arguments.

12 years agoAdd boot-manager Kill() method
Jonathan Maw [Mon, 18 Jun 2012 10:01:48 +0000 (11:01 +0100)]
Add boot-manager Kill() method

The Kill() method differs from Start() and Stop() in the following ways:
- Systemd does not create jobs for KillUnit() operations, so it doesn't
  send a "job-removed" signal.
- The systemd method KillUnit() has different arguments. As well as the
  name and the mode, it also takes 'who' and 'signal' number.
  The 'who', 'mode' and 'signal' arguments currently use the default
  parameters of "all", "control-group" and SIGKILL, respectively.

12 years agoRemove shadow warning from compiling
Jonathan Maw [Mon, 18 Jun 2012 11:07:07 +0000 (12:07 +0100)]
Remove shadow warning from compiling

Removed because shadowing was caused by an automatically-generated file
(luc-handler-dbus.c), as generated with gdbus-codegen.
When using --enable-debug=yes in ./configure, compiling will fail on
warnings.

12 years agoRemove unused variable from boot_manager_application_startup
Jonathan Maw [Mon, 18 Jun 2012 10:37:13 +0000 (11:37 +0100)]
Remove unused variable from boot_manager_application_startup

12 years agoAdd Jannis Pohlmann to the AUTHORS file
Jannis Pohlmann [Mon, 18 Jun 2012 09:40:24 +0000 (10:40 +0100)]
Add Jannis Pohlmann to the AUTHORS file

12 years agoApply a small amount of coding style fixes
Jannis Pohlmann [Mon, 18 Jun 2012 09:18:54 +0000 (10:18 +0100)]
Apply a small amount of coding style fixes

12 years agoAdd skeleton for the legacy-app-handler service application
Jonathan Maw [Fri, 15 Jun 2012 09:57:08 +0000 (10:57 +0100)]
Add skeleton for the legacy-app-handler service application

This is analogue to the boot-manager and luc-handler skeletons and
involves a GApplication subclass (LAHandlerApplication), an (empty)
implementation of the org.genivi.LegacyAppHandler1 D-Bus interface
(LAHandlerService) and an org.genivi.LegacyAppHandler1.service
file to allow D-Bus to activate the service on demand.

12 years agoFix compiler warnings and add --enable-debug=no to make distcheck
Jannis Pohlmann [Fri, 15 Jun 2012 16:09:16 +0000 (17:09 +0100)]
Fix compiler warnings and add --enable-debug=no to make distcheck

12 years agoAdd --enable-debug={yes,no} configure option
Jannis Pohlmann [Fri, 15 Jun 2012 16:06:21 +0000 (17:06 +0100)]
Add --enable-debug={yes,no} configure option

Building with --enable-debug=yes will help catch a lot of programming
mistakes. It enables -Werror -Wall and a lot of other useful compiler
flags.

12 years agoImplement org.genivi.BootManager1.Start/Stop
Jannis Pohlmann [Thu, 14 Jun 2012 09:28:00 +0000 (10:28 +0100)]
Implement org.genivi.BootManager1.Start/Stop

This commit introduces a fully functional implementation of the
org.genivi.BootManager.Start() and org.genivi.BootManager.Stop()
methods.

It drops the BootManagerJob class and the BootManagerJobType enum type
in favor of a more simple BootManagerServiceJob struct typedef used
internally in BootManagerService.

BootManagerService now has two public methods called
boot_manager_service_start() and boot_manager_service_stop() that
call systemd to start/stop a unit. Both methods create
BootManagerServiceJobs and link them to the name of the corresponding
job created by systemd. Both methods also take callback and user data to
allow the result to be reported back to the caller.

The implementations of "handle-start" and "handle-stop" use the above
methods and report the results back to the GDBusMethodInvocation in
a callback.

Most other methods (e.g. Kill() or Isolate()) can be implemented in
pretty much the same way.

NOTE: systemd-manager-dbus.xml was changed to support an older signature
for the JobRemoved() signal. We will have to change this once we develop
using systemd 183 (where JobRemoved() has an additional unit name
argument).

12 years agoAdd stub for implementing BootManager1.Start()
Jannis Pohlmann [Thu, 14 Jun 2012 09:26:55 +0000 (10:26 +0100)]
Add stub for implementing BootManager1.Start()

This will soon be filled with life, erm, code.

12 years agoCreate the watchdog client in the application init method
Jannis Pohlmann [Thu, 14 Jun 2012 09:23:35 +0000 (10:23 +0100)]
Create the watchdog client in the application init method

This way it is always created and systemd's watchdog timestamp is
updated as early as possible and not later in the app's startup method.

12 years agoInclude test-luc-handler in the tarballs generated by make distcheck
Jannis Pohlmann [Thu, 14 Jun 2012 16:12:34 +0000 (17:12 +0100)]
Include test-luc-handler in the tarballs generated by make distcheck

12 years agoAdd tests for LUC handler register/deregister
Jonathan Maw [Thu, 14 Jun 2012 16:05:53 +0000 (17:05 +0100)]
Add tests for LUC handler register/deregister

The testing suite makes register/deregister calls to the LUC handler,
and compares the LastUserContext after the request to what is expected.

12 years agoImplement org.genivi.LUCHandler1.Deregister()
Jonathan Maw [Thu, 14 Jun 2012 09:29:20 +0000 (10:29 +0100)]
Implement org.genivi.LUCHandler1.Deregister()

This commit implements the "handle-deregister" signal handler of the
LUCHandler interface skeleton. It essentially copies the current last
user context and drops all the apps that are part of the Deregister()
call. It then updates the org.genivi.LUCHandler1:LastUserContext
property.

The deregistration algorithm makes sure that LUC types for which no apps
are registered anymore are dropped from the LUC entirely.

12 years agoImplement org.genivi.LUCHandler1.Register()
Jonathan Maw [Wed, 13 Jun 2012 14:13:55 +0000 (15:13 +0100)]
Implement org.genivi.LUCHandler1.Register()

This commit implements the "handle-register" signal handler of the
LUCHandler interface skeleton by merging the current LUC and the
newly registered LUC types/apps and updating the
org.genivi.LUCHandler1:LastUserContext property.

It makes sure that the order in which LUC types are added to the final
GVariant as dictionary keys is always the same (alphabetical order).
This makes testing easier as D-Bus and GVariant both preserve the order
of dictionary keys (unlike with a GHashTable).

This commit also introduces common/glib-extensions.{c,h} where we can
dump functions that extend GLib in simple ways. The first helper
function is g_variant_string_array_has_string() which we use to check if
a string is included in a string array GVariant.

12 years agoAdd XML spec and code generation for org.fd.systemd1.Manager
Jannis Pohlmann [Wed, 13 Jun 2012 13:09:15 +0000 (14:09 +0100)]
Add XML spec and code generation for org.fd.systemd1.Manager

This will cause the SystemdManagerProxy class to be generated that
we can use to communicate with the systemd manager to start/stop units
etc.

12 years agoFix coding style, parameter alignments and an unused variable
Jannis Pohlmann [Wed, 13 Jun 2012 12:38:46 +0000 (13:38 +0100)]
Fix coding style, parameter alignments and an unused variable

12 years agoAdd initial classes for the boot manager service implementation
Jannis Pohlmann [Wed, 13 Jun 2012 12:37:06 +0000 (13:37 +0100)]
Add initial classes for the boot manager service implementation

This includes BootManagerApplication, BootManagerService (which at this
point does not implement any of the D-Bus method handlers yet) and the
classes generated by gdbus-codegen from the XML interface specification.

This commit also introduces the .service file for the boot manager.

12 years agoAdd rudimentary test suite with a LUC Handler test script
Jannis Pohlmann [Wed, 13 Jun 2012 10:46:08 +0000 (11:46 +0100)]
Add rudimentary test suite with a LUC Handler test script

For now the LUC Handler test only does the following:

  1. reset the LUC to be empty
  2. attempt to register one foreground app

In the future we have to add more tests to it.

12 years agoUse GApplication to gain bus ownership of org.genivi.LUCHandler1
Jannis Pohlmann [Wed, 13 Jun 2012 11:18:37 +0000 (12:18 +0100)]
Use GApplication to gain bus ownership of org.genivi.LUCHandler1

In order for the service to respond to client requests properly, we
need to own the org.genivi.LUCHandler1 name on the bus. GApplication
transparently handles this for us. This commit adds a new
LUCHandlerApplication class and uses that for managing the daemon's
lifecycle, including bus ownership, main loop and shutdown after a
period of inactivity.