Remove custom org.openbmc.Object.ObjectMapper
Use the standard freedesktop ObjectManager interface.
Moved gdbus OM export calls to the correct place so these
signals are emitted as expected by system_manager.py.
Python apps that use pyobmc are already emitting these
correctly.
Change system_manager.py to watch for the freedesktop
signal rather than the custom one.
Added an sd_bus OM to led_controller.
diff --git a/objects/button_power_obj.c b/objects/button_power_obj.c
index 8c5ebb8..e093a00 100644
--- a/objects/button_power_obj.c
+++ b/objects/button_power_obj.c
@@ -2,7 +2,6 @@
#include "interfaces/openbmc_intf.h"
#include "gpio.h"
#include "openbmc.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/buttons";
@@ -94,10 +93,6 @@
object_skeleton_set_button(object, button);
g_object_unref(button);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
//define method callbacks
g_signal_connect(button,
"handle-is-on",
@@ -110,12 +105,10 @@
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
-
// get gpio device paths
int rc = GPIO_OK;
do {
@@ -128,7 +121,6 @@
{
printf("ERROR PowerButton: GPIO setup (rc=%d)\n",rc);
}
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/button_reset_obj.c b/objects/button_reset_obj.c
index 7fdad40..a9321e3 100644
--- a/objects/button_reset_obj.c
+++ b/objects/button_reset_obj.c
@@ -2,7 +2,6 @@
#include "interfaces/openbmc_intf.h"
#include "gpio.h"
#include "openbmc.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/buttons";
@@ -94,10 +93,6 @@
object_skeleton_set_button(object, button);
g_object_unref(button);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
//define method callbacks
g_signal_connect(button,
"handle-is-on",
@@ -110,12 +105,10 @@
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
-
// get gpio device paths
int rc = GPIO_OK;
do {
@@ -128,7 +121,6 @@
{
printf("ERROR PowerButton: GPIO setup (rc=%d)\n",rc);
}
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/control_host_obj.c b/objects/control_host_obj.c
index e8d1745..9253007 100644
--- a/objects/control_host_obj.c
+++ b/objects/control_host_obj.c
@@ -8,7 +8,6 @@
#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "gpio.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
@@ -197,10 +196,6 @@
object_skeleton_set_control(object, control);
g_object_unref(control);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
//define method callbacks here
g_signal_connect(control_host,
"handle-boot",
@@ -215,18 +210,15 @@
control_host_set_flash_side(control_host,"primary");
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
-
gpio_init(connection,&fsi_data);
gpio_init(connection,&fsi_clk);
gpio_init(connection,&fsi_enable);
gpio_init(connection,&cronus_sel);
gpio_init(connection,&Throttle);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/fan_generic_obj.c b/objects/fan_generic_obj.c
index 72bfb11..61083ae 100644
--- a/objects/fan_generic_obj.c
+++ b/objects/fan_generic_obj.c
@@ -1,6 +1,5 @@
#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
@@ -64,10 +63,6 @@
object_skeleton_set_fan(object, fan);
g_object_unref(fan);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
//define method callbacks here
g_signal_connect(fan,
"handle-get-speed",
@@ -81,13 +76,10 @@
//g_timeout_add(poll_interval, poll_sensor, object);
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
}
-
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index a3f7ac4..f865be1 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -5,7 +5,6 @@
#include <sys/types.h>
#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control/flash";
@@ -275,10 +274,6 @@
object_skeleton_set_shared_resource(object, lock);
g_object_unref(lock);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
shared_resource_set_lock(lock,false);
shared_resource_set_name(lock,"");
@@ -344,13 +339,11 @@
flash_set_filename(flash,"");
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
}
g_free(flasher_file);
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index 2e0ef15..e922dc3 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -1,6 +1,5 @@
#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
@@ -105,10 +104,6 @@
object_skeleton_set_watchdog(object, wd);
g_object_unref(wd);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
// set properties
watchdog_set_watchdog(wd,1);
@@ -134,12 +129,9 @@
object); /* user_data */
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
-
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/hwmons_barreleye.c b/objects/hwmons_barreleye.c
index 0057af4..07717cf 100644
--- a/objects/hwmons_barreleye.c
+++ b/objects/hwmons_barreleye.c
@@ -4,7 +4,6 @@
#include <fcntl.h>
#include "openbmc.h"
#include "gpio.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/sensors";
@@ -149,10 +148,6 @@
object_skeleton_set_sensor_value(object, sensor);
g_object_unref(sensor);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
hwmon_set_sysfs_path(hwmon,hwmons[i].filename);
hwmon_set_scale(hwmon,hwmons[i].scale);
sensor_value_set_units(sensor,hwmons[i].units);
@@ -168,12 +163,10 @@
g_timeout_add(hwmons[i].poll_interval, poll_hwmon, object);
}
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
}
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/hwmons_palmetto.c b/objects/hwmons_palmetto.c
index c627d27..7d76c91 100644
--- a/objects/hwmons_palmetto.c
+++ b/objects/hwmons_palmetto.c
@@ -3,7 +3,6 @@
#include <fcntl.h>
#include "openbmc.h"
#include "gpio.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/sensors";
@@ -144,10 +143,6 @@
object_skeleton_set_sensor_value(object, sensor);
g_object_unref(sensor);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
hwmon_set_sysfs_path(hwmon,hwmons[i].filename);
hwmon_set_scale(hwmon,hwmons[i].scale);
sensor_value_set_units(sensor,hwmons[i].units);
@@ -163,12 +158,10 @@
g_timeout_add(hwmons[i].poll_interval, poll_hwmon, object);
}
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
}
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
- emit_object_added((GDBusObjectManager*)manager);
}
static void
diff --git a/objects/led_controller.c b/objects/led_controller.c
index 96e7ad1..9eda9ee 100644
--- a/objects/led_controller.c
+++ b/objects/led_controller.c
@@ -431,6 +431,8 @@
int
start_led_services()
{
+ static const char *led_dbus_root = "/org/openbmc/control/led";
+
/* Generic error reporter. */
int rc = -1;
int num_leds = 0;
@@ -462,6 +464,17 @@
return rc;
}
+ /* Install a freedesktop object manager */
+ rc = sd_bus_add_object_manager(bus_type, NULL, led_dbus_root);
+ if(rc < 0) {
+ fprintf(stderr, "Failed to add object to dbus: %s\n",
+ strerror(-rc));
+
+ sd_bus_slot_unref(led_slot);
+ sd_bus_unref(bus_type);
+ return rc;
+ }
+
/* Fully qualified Dbus object for a particular LED */
char led_object[128] = {0};
int len = 0;
@@ -471,8 +484,8 @@
{
memset(led_object, 0x0, sizeof(led_object));
- len = snprintf(led_object, sizeof(led_object), "%s%s",
- "/org/openbmc/control/led/", led_list[num_leds]->d_name);
+ len = snprintf(led_object, sizeof(led_object), "%s%s%s",
+ led_dbus_root, "/", led_list[num_leds]->d_name);
if(len >= sizeof(led_object))
{
@@ -494,6 +507,15 @@
fprintf(stderr, "Failed to add object to dbus: %s\n", strerror(-rc));
break;
}
+
+ rc = sd_bus_emit_object_added(bus_type, led_object);
+
+ if(rc < 0)
+ {
+ fprintf(stderr, "Failed to emit InterfacesAdded "
+ "signal: %s\n", strerror(-rc));
+ break;
+ }
}
/* Done with all registration. */
@@ -504,7 +526,7 @@
free(led_list);
/* If we had success in adding the providers, request for a bus name. */
- if(rc == 0)
+ if(rc >= 0)
{
/* Take one in OpenBmc */
rc = sd_bus_request_name(bus_type, "org.openbmc.control.led", 0);
diff --git a/objects/power_control_obj.c b/objects/power_control_obj.c
index da69413..85a8cff 100644
--- a/objects/power_control_obj.c
+++ b/objects/power_control_obj.c
@@ -10,7 +10,6 @@
#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "gpio.h"
-#include "object_mapper.h"
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
@@ -202,10 +201,6 @@
object_skeleton_set_control(object, control);
g_object_unref(control);
- ObjectMapper* mapper = object_mapper_skeleton_new();
- object_skeleton_set_object_mapper(object, mapper);
- g_object_unref(mapper);
-
//define method callbacks here
g_signal_connect(control_power,
"handle-set-power-state",
@@ -224,12 +219,10 @@
/* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_set_connection(manager, connection);
g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
- /* Export all objects */
- g_dbus_object_manager_server_set_connection(manager, connection);
-
// get gpio device paths
int rc = GPIO_OK;
do {
@@ -268,7 +261,6 @@
control_power_set_pgood_timeout(control_power,pgood_timeout);
g_timeout_add(poll_interval, poll_pgood, object);
}
- emit_object_added((GDBusObjectManager*)manager);
}
static void