return ret;
}
+static int deserialize_rv_event(struct faultd_event_type *type,
+ bson *data, struct faultd_event **ev)
+{
+ int ret = -EINVAL;
+ struct rv_event_data rv_ev_data;
+ bson_type bt;
+ bson_iterator it;
+
+ memset(&rv_ev_data, 0, sizeof(rv_ev_data));
+ BSON_ITERATOR_INIT(&it, data);
+
+ while ((bt = bson_iterator_next(&it)) != BSON_EOO) {
+
+ if ((bt == BSON_OBJECT) &&
+ (strcmp(SYSD_SERVICE, bson_iterator_key(&it)) == 0)) {
+ bson svc;
+
+ bson_init_finished_data(&svc, bson_iterator_value(&it));
+ ret = systemd_service_deserialize(&svc, &rv_ev_data.service);
+ if (ret < 0)
+ goto finish;
+
+ } else if ((bt == BSON_TIMESTAMP) &&
+ (strcmp(RV_EV_DTIME, bson_iterator_key(&it)))) {
+
+ rv_ev_data.detection_time = bson_iterator_time_t(&it);
+
+ } else if ((bt == BSON_INT) &&
+ (strcmp(RV_EV_RES_TYPE, bson_iterator_key(&it)))) {
+
+ rv_ev_data.resource_type = bson_iterator_int(&it);
+
+ } else if ((bt == BSON_INT) &&
+ (strcmp(RV_EV_PID, bson_iterator_key(&it)))) {
+
+ rv_ev_data.pid = bson_iterator_int(&it);
+
+ }
+ }
+
+ ret = allocate_rv_event(type, &rv_ev_data, ev);
+ if (ret < 0) {
+ free(rv_ev_data.service.dbus_path);
+ goto finish;
+ }
+
+ ret = faultd_event_deserialize_internal(data, *ev);
+ if (ret < 0) {
+ struct resource_violation_event *rv_ev =
+ to_resource_violation_event(*ev);
+ free(rv_ev_data.service.dbus_path);
+ rv_ev_data.service.dbus_path = NULL;
+ free(rv_ev);
+ goto finish;
+ }
+
+ ret = 0;
+finish:
+ return ret;
+}
+
static void rv_event_release(struct faultd_event *ev)
{
struct resource_violation_event *rv_ev =
systemd_service_serialize(&rv_ev->service, out);
bson_append_time_t(out, RV_EV_DTIME, rv_ev->detection_time);
bson_append_int(out, RV_EV_PID, rv_ev->pid);
+ bson_append_int(out, RV_EV_RES_TYPE, rv_ev->resource_type);
}
static struct faultd_event_type resource_violation_event_type = {
.to_string = rv_event_to_string,
},
.allocate_event = allocate_rv_event,
+ .deserialize_event = deserialize_rv_event,
.node = LIST_HEAD_INIT(resource_violation_event_type.node),
};