Support to set watchdog timer value
diff --git a/bin/ipmi_debug.py b/bin/ipmi_debug.py
index 43dbcbd..300756c 100755
--- a/bin/ipmi_debug.py
+++ b/bin/ipmi_debug.py
@@ -69,7 +69,7 @@
def main():
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = dbus.SystemBus()
name = dbus.service.BusName(DBUS_NAME, bus)
obj = IpmiDebug(bus, OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index bc506fa..965332c 100755
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -104,11 +104,14 @@
for i in status:
print i+" = "+status[i]
elif (cmd == "pokewatchdog"):
- intf = self.getWatchdog()
+ intf = getWatchdog()
intf.poke()
elif (cmd == "statewatchdog"):
- intf = self.getWatchdog()
+ intf = getWatchdog()
intf.start()
+ elif (cmd == "setwatchdog"):
+ count = int(sys.argv[2])
+ intf.set(count)
else:
print "Unsupported command"
diff --git a/interfaces/openbmc_intf.c b/interfaces/openbmc_intf.c
index 6bd5d91..1e163d5 100644
--- a/interfaces/openbmc_intf.c
+++ b/interfaces/openbmc_intf.c
@@ -1,5 +1,5 @@
/*
- * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ * Generated by gdbus-codegen 2.44.1. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
@@ -1553,6 +1553,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _occ_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _occ_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -3423,6 +3424,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _fan_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _fan_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -5558,6 +5560,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_value_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _sensor_value_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -7375,6 +7378,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_threshold_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _sensor_threshold_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -8561,6 +8565,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_i2c_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _sensor_i2c_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -9777,6 +9782,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_match_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _sensor_match_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -12283,6 +12289,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _shared_resource_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _shared_resource_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -13722,6 +13729,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _control_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _control_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -17481,6 +17489,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _control_power_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _control_power_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -17661,11 +17670,42 @@
FALSE
};
+static const _ExtendedGDBusArgInfo _watchdog_method_info_set_IN_ARG_interval =
+{
+ {
+ -1,
+ (gchar *) "interval",
+ (gchar *) "i",
+ NULL
+ },
+ FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _watchdog_method_info_set_IN_ARG_pointers[] =
+{
+ &_watchdog_method_info_set_IN_ARG_interval,
+ NULL
+};
+
+static const _ExtendedGDBusMethodInfo _watchdog_method_info_set =
+{
+ {
+ -1,
+ (gchar *) "set",
+ (GDBusArgInfo **) &_watchdog_method_info_set_IN_ARG_pointers,
+ NULL,
+ NULL
+ },
+ "handle-set",
+ FALSE
+};
+
static const _ExtendedGDBusMethodInfo * const _watchdog_method_info_pointers[] =
{
&_watchdog_method_info_start,
&_watchdog_method_info_poke,
&_watchdog_method_info_stop,
+ &_watchdog_method_info_set,
NULL
};
@@ -17776,6 +17816,7 @@
* WatchdogIface:
* @parent_iface: The parent interface.
* @handle_poke: Handler for the #Watchdog::handle-poke signal.
+ * @handle_set: Handler for the #Watchdog::handle-set signal.
* @handle_start: Handler for the #Watchdog::handle-start signal.
* @handle_stop: Handler for the #Watchdog::handle-stop signal.
* @get_poll_interval: Getter for the #Watchdog:poll-interval property.
@@ -17858,6 +17899,29 @@
1,
G_TYPE_DBUS_METHOD_INVOCATION);
+ /**
+ * Watchdog::handle-set:
+ * @object: A #Watchdog.
+ * @invocation: A #GDBusMethodInvocation.
+ * @arg_interval: Argument passed by remote caller.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-Watchdog.set">set()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call watchdog_complete_set() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-set",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (WatchdogIface, handle_set),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 2,
+ G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT);
+
/* GObject signals for received D-Bus signals: */
/**
* Watchdog::watchdog-error:
@@ -18250,6 +18314,104 @@
}
/**
+ * watchdog_call_set:
+ * @proxy: A #WatchdogProxy.
+ * @arg_interval: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-Watchdog.set">set()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call watchdog_call_set_finish() to get the result of the operation.
+ *
+ * See watchdog_call_set_sync() for the synchronous, blocking version of this method.
+ */
+void
+watchdog_call_set (
+ Watchdog *proxy,
+ gint arg_interval,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "set",
+ g_variant_new ("(i)",
+ arg_interval),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * watchdog_call_set_finish:
+ * @proxy: A #WatchdogProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to watchdog_call_set().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with watchdog_call_set().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+watchdog_call_set_finish (
+ Watchdog *proxy,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * watchdog_call_set_sync:
+ * @proxy: A #WatchdogProxy.
+ * @arg_interval: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-Watchdog.set">set()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See watchdog_call_set() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+watchdog_call_set_sync (
+ Watchdog *proxy,
+ gint arg_interval,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "set",
+ g_variant_new ("(i)",
+ arg_interval),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
* watchdog_complete_start:
* @object: A #Watchdog.
* @invocation: (transfer full): A #GDBusMethodInvocation.
@@ -18303,6 +18465,24 @@
g_variant_new ("()"));
}
+/**
+ * watchdog_complete_set:
+ * @object: A #Watchdog.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-Watchdog.set">set()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+watchdog_complete_set (
+ Watchdog *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("()"));
+}
+
/* ------------------------------------------------------------------------ */
/**
@@ -19119,6 +19299,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _watchdog_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _watchdog_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -22157,6 +22338,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _flash_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _flash_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -23812,6 +23994,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _flash_control_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _flash_control_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -25524,6 +25707,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _button_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _button_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
@@ -27232,6 +27416,7 @@
skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (skeleton->priv->changed_properties_idle_source, _led_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+ g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _led_emit_changed");
g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
g_source_unref (skeleton->priv->changed_properties_idle_source);
}
diff --git a/interfaces/openbmc_intf.h b/interfaces/openbmc_intf.h
index ae6ee88..db435fd 100644
--- a/interfaces/openbmc_intf.h
+++ b/interfaces/openbmc_intf.h
@@ -1,5 +1,5 @@
/*
- * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ * Generated by gdbus-codegen 2.44.1. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
@@ -2345,6 +2345,11 @@
Watchdog *object,
GDBusMethodInvocation *invocation);
+ gboolean (*handle_set) (
+ Watchdog *object,
+ GDBusMethodInvocation *invocation,
+ gint arg_interval);
+
gboolean (*handle_start) (
Watchdog *object,
GDBusMethodInvocation *invocation);
@@ -2381,6 +2386,10 @@
Watchdog *object,
GDBusMethodInvocation *invocation);
+void watchdog_complete_set (
+ Watchdog *object,
+ GDBusMethodInvocation *invocation);
+
/* D-Bus signal emissions functions: */
@@ -2438,6 +2447,24 @@
GCancellable *cancellable,
GError **error);
+void watchdog_call_set (
+ Watchdog *proxy,
+ gint arg_interval,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean watchdog_call_set_finish (
+ Watchdog *proxy,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean watchdog_call_set_sync (
+ Watchdog *proxy,
+ gint arg_interval,
+ GCancellable *cancellable,
+ GError **error);
+
/* D-Bus property accessors: */
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index 65c5fa4..e4e4bab 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -31,12 +31,24 @@
}
static gboolean
+set_poll_interval (Watchdog *wd,
+ GDBusMethodInvocation *invocation,
+ guint interval,
+ gpointer user_data)
+{
+ g_print("Setting watchdog poll interval to: %d\n", interval);
+ watchdog_set_poll_interval(wd, interval);
+ watchdog_complete_set(wd,invocation);
+}
+
+static gboolean
on_start (Watchdog *wd,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
watchdog_set_watchdog(wd,1);
guint poll_interval = watchdog_get_poll_interval(wd);
+ g_print("Starting watchdog with poll interval: %d\n", poll_interval);
g_timeout_add(poll_interval, poll_watchdog, user_data);
watchdog_complete_start(wd,invocation);
return TRUE;
@@ -94,6 +106,10 @@
G_CALLBACK (on_poke),
object); /* user_data */
+ g_signal_connect (wd,
+ "handle-set",
+ G_CALLBACK (set_poll_interval),
+ object); /* user_data */
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
diff --git a/xml/openbmc_intf.xml b/xml/openbmc_intf.xml
index 9f544ce..7d5094e 100644
--- a/xml/openbmc_intf.xml
+++ b/xml/openbmc_intf.xml
@@ -130,6 +130,9 @@
<method name="start"/>
<method name="poke"/>
<method name="stop"/>
+ <method name="set"/>
+ <arg direction="in" type="i" name="interval" />
+ </method>
<property name="watchdog" type="i" access="readwrite"/>
<property name="poll_interval" type="i" access="readwrite"/>
<signal name="WatchdogError"/>