|
|
97e186 |
From 11004aaa98865dd7c0ee28b4af8d6ba6b6f11507 Mon Sep 17 00:00:00 2001
|
|
|
97e186 |
From: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
|
97e186 |
Date: Fri, 31 May 2013 13:54:11 -0300
|
|
|
97e186 |
Subject: [PATCH 06/32] Add support to record AER events
|
|
|
97e186 |
|
|
|
97e186 |
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
|
97e186 |
---
|
|
|
97e186 |
ras-aer-handler.c | 4 ++-
|
|
|
97e186 |
ras-record.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
97e186 |
ras-record.h | 6 +++++
|
|
|
97e186 |
3 files changed, 68 insertions(+), 2 deletions(-)
|
|
|
97e186 |
|
|
|
97e186 |
diff --git a/ras-aer-handler.c b/ras-aer-handler.c
|
|
|
97e186 |
index ec63e2a..e5abaca 100644
|
|
|
97e186 |
--- a/ras-aer-handler.c
|
|
|
97e186 |
+++ b/ras-aer-handler.c
|
|
|
97e186 |
@@ -111,7 +111,9 @@ int ras_aer_event_handler(struct trace_seq *s,
|
|
|
97e186 |
trace_seq_puts(s, ev.error_type);
|
|
|
97e186 |
|
|
|
97e186 |
/* Insert data into the SGBD */
|
|
|
97e186 |
-// ras_store_aer_event(ras, &ev;;
|
|
|
97e186 |
+#ifdef HAVE_SQLITE3
|
|
|
97e186 |
+ ras_store_aer_event(ras, &ev;;
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
}
|
|
|
97e186 |
diff --git a/ras-record.c b/ras-record.c
|
|
|
97e186 |
index 36b3373..cb302ce 100644
|
|
|
97e186 |
--- a/ras-record.c
|
|
|
97e186 |
+++ b/ras-record.c
|
|
|
97e186 |
@@ -26,6 +26,7 @@
|
|
|
97e186 |
#include <unistd.h>
|
|
|
97e186 |
#include "ras-events.h"
|
|
|
97e186 |
#include "ras-mc-handler.h"
|
|
|
97e186 |
+#include "ras-aer-handler.h"
|
|
|
97e186 |
#include "ras-logger.h"
|
|
|
97e186 |
|
|
|
97e186 |
/* #define DEBUG_SQL 1 */
|
|
|
97e186 |
@@ -109,6 +110,56 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
|
|
|
97e186 |
return rc;
|
|
|
97e186 |
}
|
|
|
97e186 |
|
|
|
97e186 |
+/*
|
|
|
97e186 |
+ * Table and functions to handle ras:aer
|
|
|
97e186 |
+ */
|
|
|
97e186 |
+
|
|
|
97e186 |
+#ifdef HAVE_AER
|
|
|
97e186 |
+static const struct db_fields aer_event_fields[] = {
|
|
|
97e186 |
+ { .name="id", .type="INTEGER PRIMARY KEY" },
|
|
|
97e186 |
+ { .name="timestamp", .type="TEXT" },
|
|
|
97e186 |
+ { .name="err_type", .type="TEXT" },
|
|
|
97e186 |
+ { .name="err_msg", .type="TEXT" },
|
|
|
97e186 |
+};
|
|
|
97e186 |
+
|
|
|
97e186 |
+static const struct db_table_descriptor aer_event_tab = {
|
|
|
97e186 |
+ .name = "aer_event",
|
|
|
97e186 |
+ .fields = aer_event_fields,
|
|
|
97e186 |
+ .num_fields = ARRAY_SIZE(aer_event_fields),
|
|
|
97e186 |
+};
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
|
|
|
97e186 |
+{
|
|
|
97e186 |
+ int rc;
|
|
|
97e186 |
+ struct sqlite3_priv *priv = ras->db_priv;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if (!priv || !priv->stmt_aer_event)
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+ log(TERM, LOG_INFO, "mc_event store: %p\n", priv->stmt_aer_event);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_aer_event, 1, ev->timestamp, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_aer_event, 3, ev->error_type, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_aer_event, 4, ev->msg, -1, NULL);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = sqlite3_step(priv->stmt_aer_event);
|
|
|
97e186 |
+ if (rc != SQLITE_OK && rc != SQLITE_DONE)
|
|
|
97e186 |
+ log(TERM, LOG_ERR,
|
|
|
97e186 |
+ "Failed to do aer_event step on sqlite: error = %d\n", rc);
|
|
|
97e186 |
+ rc = sqlite3_reset(priv->stmt_aer_event);
|
|
|
97e186 |
+ if (rc != SQLITE_OK && rc != SQLITE_DONE)
|
|
|
97e186 |
+ log(TERM, LOG_ERR,
|
|
|
97e186 |
+ "Failed reset aer_event on sqlite: error = %d\n",
|
|
|
97e186 |
+ rc);
|
|
|
97e186 |
+ log(TERM, LOG_INFO, "register inserted at db\n");
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return rc;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
+/*
|
|
|
97e186 |
+ * Generic code
|
|
|
97e186 |
+ */
|
|
|
97e186 |
+
|
|
|
97e186 |
static int ras_mc_prepare_stmt(struct sqlite3_priv *priv,
|
|
|
97e186 |
sqlite3_stmt **stmt,
|
|
|
97e186 |
const struct db_table_descriptor *db_tab)
|
|
|
97e186 |
@@ -230,8 +281,15 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
|
|
|
97e186 |
|
|
|
97e186 |
rc = ras_mc_create_table(priv, &mc_event_tab);
|
|
|
97e186 |
if (rc == SQLITE_OK)
|
|
|
97e186 |
- rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event, &mc_event_tab);
|
|
|
97e186 |
+ rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event,
|
|
|
97e186 |
+ &mc_event_tab);
|
|
|
97e186 |
|
|
|
97e186 |
+#ifdef HAVE_AER
|
|
|
97e186 |
+ rc = ras_mc_create_table(priv, &aer_event_tab);
|
|
|
97e186 |
+ if (rc == SQLITE_OK)
|
|
|
97e186 |
+ rc = ras_mc_prepare_stmt(priv, &priv->stmt_aer_event,
|
|
|
97e186 |
+ &aer_event_tab);
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
|
|
|
97e186 |
ras->db_priv = priv;
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
diff --git a/ras-record.h b/ras-record.h
|
|
|
97e186 |
index 9791185..5008906 100644
|
|
|
97e186 |
--- a/ras-record.h
|
|
|
97e186 |
+++ b/ras-record.h
|
|
|
97e186 |
@@ -47,14 +47,20 @@ struct ras_aer_event {
|
|
|
97e186 |
struct sqlite3_priv {
|
|
|
97e186 |
sqlite3 *db;
|
|
|
97e186 |
sqlite3_stmt *stmt_mc_event;
|
|
|
97e186 |
+#ifdef HAVE_AER
|
|
|
97e186 |
+ sqlite3_stmt *stmt_aer_event;
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
};
|
|
|
97e186 |
|
|
|
97e186 |
int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras);
|
|
|
97e186 |
int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
|
|
|
97e186 |
+int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
|
|
|
97e186 |
|
|
|
97e186 |
#else
|
|
|
97e186 |
static inline int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) { return 0; };
|
|
|
97e186 |
static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
|
|
|
97e186 |
+static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
|
|
|
97e186 |
+
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
#endif
|
|
|
97e186 |
--
|
|
|
97e186 |
1.7.1
|
|
|
97e186 |
|