summaryrefslogtreecommitdiffstats
path: root/bmcctl/control_bmc_obj.c
diff options
context:
space:
mode:
authorNan Li <william.bjlinan@hotmail.com>2016-08-24 17:13:06 +0800
committerPatrick Williams <patrick@stwcx.xyz>2016-11-01 14:59:33 +0000
commit44dd5a6ea7141610ffa922e9557c62552010b8a5 (patch)
tree1b94f3fe2bb3c399f76e14d44fde685c9bea0558 /bmcctl/control_bmc_obj.c
parentda7aad04d03312fe5df7580ec94bf44f0587bb53 (diff)
downloadtalos-skeleton-44dd5a6ea7141610ffa922e9557c62552010b8a5.tar.gz
talos-skeleton-44dd5a6ea7141610ffa922e9557c62552010b8a5.zip
Add IPMI 2.0 ColdReset command support
* Implement reset by reboot command issued in a shell * Work with related changes in phosphor-host-ipmid repo Resolves openbmc/openbmc#437 Change-Id: I8143b1ee9c0d547ee47e5bd3659a5126b6e5af98 Signed-off-by: Nan Li <william.bjlinan@hotmail.com>
Diffstat (limited to 'bmcctl/control_bmc_obj.c')
-rw-r--r--bmcctl/control_bmc_obj.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/bmcctl/control_bmc_obj.c b/bmcctl/control_bmc_obj.c
index c3ef723..c0135c4 100644
--- a/bmcctl/control_bmc_obj.c
+++ b/bmcctl/control_bmc_obj.c
@@ -40,6 +40,27 @@ static gboolean on_warm_reset(ControlBmc *bmc,
return TRUE;
}
+static gboolean on_cold_reset(ControlBmc *bmc,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ GError *err = NULL;
+ /* Wait a while before reboot, so the caller can be responded.
+ * Note that g_spawn_command_line_async() cannot parse ';' as
+ * a command separator. Need to use 'sh -c' to let shell parse it.
+ */
+ gchar *reboot_command = "/bin/sh -c 'sleep 3;reboot'";
+
+ g_spawn_command_line_async(reboot_command, &err);
+ if(err != NULL) {
+ fprintf(stderr, "coldReset() error: %s\n", err->message);
+ g_error_free(err);
+ }
+
+ control_bmc_complete_cold_reset(bmc, invocation);
+ return TRUE;
+}
+
static void on_bus_acquired(GDBusConnection *connection, const gchar *name,
gpointer user_data)
{
@@ -66,6 +87,9 @@ static void on_bus_acquired(GDBusConnection *connection, const gchar *name,
g_signal_connect(control_bmc, "handle-warm-reset",
G_CALLBACK(on_warm_reset), NULL); /* user_data */
+ g_signal_connect(control_bmc, "handle-cold-reset",
+ G_CALLBACK(on_cold_reset), NULL); /* user_data */
+
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export(manager,
G_DBUS_OBJECT_SKELETON(object));
OpenPOWER on IntegriCloud