src/listeners/startup.c \
src/listeners/vconf.c \
src/database/sqlite.c \
+ src/decision_makers/vconf_dm.c \
src/decision_makers/vip_fault_dm.c \
src/decision_makers/rv_dm.c \
src/decision_makers/standard_fault_dm.c \
startup_listener.la \
vconf_listener.la \
sqlite_dbadapter.la \
+ vconf_eh.la \
vip_fault_eh.la \
resource_violation_eh.la \
standard_fault_eh.la \
sqlite_dbadapter_la_SOURCES = src/database/sqlite.c
sqlite_dbadapter_la_LIBADD = $(SQLITE3_LIBS)
vip_fault_eh_la_SOURCES = src/decision_makers/vip_fault_dm.c
+vconf_eh_la_SOURCES = src/decision_makers/vconf_dm.c
resource_violation_eh_la_SOURCES = src/decision_makers/rv_dm.c
standard_fault_eh_la_SOURCES = src/decision_makers/standard_fault_dm.c
standard_fault_eh_config_DATA = modules.conf.d/standard_fault_eh.conf.d/50-default.conf
--- /dev/null
+/*
+ * This file is part of faultd.
+ *
+ * Copyright © 2017 Samsung Electronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <malloc.h>
+#include <errno.h>
+
+#include "decision_made_event.h"
+#include "vconf_key_changed_event.h"
+#include "action.h"
+#include "event_processor.h"
+#include "log.h"
+
+#define MODULE_NAME "vconf_decision_maker"
+
+static int vkc_event_match(struct faultd_event_handler *handler,
+ struct faultd_event *ev)
+{
+ struct vconf_key_changed_event *vkc_ev =
+ to_vconf_key_changed_event(ev);
+
+ if (faultd_event_is_of_type(ev, VCONF_KEY_CHANGED_EVENT_ID) &&
+ vkc_ev->newval.type == VKC_STRING &&
+ !strncmp(vkc_ev->newval.value.s, "reboot", 6))
+ return true;
+
+ return false;
+}
+
+static int vkc_make_decision(struct faultd_event_handler *handler)
+{
+ struct faultd_event *ev = pop_faultd_event(&handler->event_queue);
+ struct faultd_event *new_ev;
+ struct dm_event_data ev_data = {
+ .reason = ev,
+ .who_made = MODULE_NAME,
+ .action = FAULTD_ACTION_REBOOT_ID,
+ };
+ int ret;
+
+ ret = faultd_object_new(&ev_data.action_data);
+ if (ret < 0) {
+ log_error("Unable to create faultd object");
+ goto unref_ev;
+ }
+
+ ret = faultd_fill_for_reboot(ev_data.action_data);
+ if (ret) {
+ log_error("Unable to create action data");
+ faultd_object_unref(ev_data.action_data);
+ goto unref_ev;
+ }
+
+ ret = faultd_event_create(DECISION_MADE_EVENT_ID, &ev_data, &new_ev);
+ faultd_object_unref(ev_data.action_data);
+ if (ret) {
+ log_error("Unable to create event");
+ goto unref_ev;
+ }
+
+ ret = event_processor_report_event(new_ev);
+ faultd_event_unref(new_ev);
+ if (ret) {
+ log_error("Unable to report event");
+ goto unref_ev;
+ }
+
+unref_ev:
+ faultd_event_unref(ev);
+ return 0;
+}
+
+static struct faultd_event_handler vconf_key_changed_event_handler = {
+ .name = MODULE_NAME,
+ .event_match = vkc_event_match,
+ .handle_event = vkc_make_decision,
+
+ .node = LIST_HEAD_INIT(vconf_key_changed_event_handler),
+};
+
+FAULTD_EVENT_HANDLER_REGISTER(vconf_key_changed_event_handler,
+ vconf_key_changed_eh,
+ FAULTD_MODULE_TYPE_DECISION_MAKER)