-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate from dbus-glib to GDBus #426
Conversation
Load dbus introspection to gresource Signed-off-by: Kate Hsuan <hpa@redhat.com>
Fixed it to fit the current GObject definition scheme. Signed-off-by: Kate Hsuan <hpa@redhat.com>
b02bcbc
to
de1ae2e
Compare
This is the GDBus framework for the Dbus API implementation. The corresponding functions are put to the DBus API method. Signed-off-by: Kate Hsuan <hpa@redhat.com>
Convert the gresource definition to C code before compiling. Signed-off-by: Kate Hsuan <hpa@redhat.com>
The GDBus will be the default backend since glib-dbus will be deprecated soon. --disable-gdbus can be set to switch to glib-dbus. Signed-off-by: Kate Hsuan <hpa@redhat.com>
de1ae2e
to
5730c30
Compare
Hi, Could folks review this patch? Thank you :) |
Thanks. I am in process of testing. |
Hi, @smallorange |
Hi, I'll deep dive into lpmd code and reply to this later :) |
Great, really appreciated! @smallorange |
Hi, The structure of lpmd is pretty similar to thermal_daemon. For the original implementation, For GDBus, the first thing is to fix the GObject declaration to fit the current version of Glib. It looks like the GObject fixing commit. and then we can focus on the main commit.. Make sure Look into Moreover, the Dbus introspection file should be set as a gresource. Look in to the commit. That is the minimum requirement for getting GDbus running. If you have question or need help, please let me know :) |
Hi, @smallorange , really appreciate your help on this. |
I get this build error |
This diff was required to build: BUILT_SOURCES = \
thermald_SOURCES = -thd_resources.c: $(top_srcdir)/thermald.gresource.xml CLEANFILES = $(BUILT_SOURCES) |
Hi, Thank you for testing this patch. Sorry for my mistake. I've updated the Makefile and it should work. |
Fix the build issue and applied. |
this PR is incomplete, right? because the project still does not build without dbus-glib, it references the old API in various places and the build system still forces it in |
gpointer user_data) { | ||
guint registration_id; | ||
GDBusProxy *proxy_id = NULL; | ||
GError *error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we set error to NULL?
according to https://docs.gtk.org/gio/func.resources_lookup_data.html,
"
The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be NULL. I'll fix this.
} | ||
|
||
introspection_data = thd_dbus_load_introspection("src/thd_dbus_interface.xml", | ||
&error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case (converting to use GDBus in intel_lpmd), if I don't set it to NULL, the code fails here.
GError *error = NULL; | ||
PrefObject *value_obj; | ||
|
||
if (error != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is redundant, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing it out.
It can be removed. I'll submit a PR to fix :).
I finished all necessary GDbus implementation of it but I have not yet tweaked the dependency (dbus-glib-1) of it. I need to find a way to switch between |
it has to be removed completely for this to make sense (because distros will be dropping dbus-glib) you should not need dbus-binding-tool in the end, just remove the header inclusion and tweak things around it; the other problem is that not all assumptions around dbus-glib are gone yet (e.g. there are still calls to API to set up integration of glib mainloop with dbus in other places here) |
int thd_dbus_server_init(gboolean (*exit_handler)(void)) { | ||
GError *error = NULL; | ||
PrefObject *value_obj; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe need to add this line?
thd_dbus_exit_callback = exit_handler;
@spandruvada , can you check if terminate dbus message still work?
In my case, intel_lpmd fails to terminate via dbus message without setting the proper exit handler.
For this, I hope @spandruvada can answer this or @zhang-rui can help with this. Should the dbus-glib be removed completely or keep it to support the user who use dbus-glib?
Right. Some of the dbus-glib placed in thd_cdev_modem.cpp should be removed but it is a bit complicated for me. I need to find a way to test it since I don't have the appropriate hardware to test it. According to the commit message "Added support for modem throttling on SoFIA-3GR", it seems to support throttling SoFIA-3GR platform. |
Hi,
This work migrated the DBus backend to GDBus. Since dbus-glib will be deprecated, the applications depending on it should be migrated to use GDBus as the DBus backend. Notably, the thermald package, shipped by RHEL for its customers, is currently the only package dependent on glib-dbus. This patch migrates the DBus backend to GDBus and it also resolves the dependency issue of the packages. Furthermore, it brings benefits to various Linux distributions affected by the deprecation of dbus-glib.
Fixes: #348, #416