From Wikipedia, the free encyclopedia
  (Redirected from D-BUS)
Jump to: navigation, search
"DBus" redirects here. For the Tibetan province, see Dbus.
Developer(s) Red Hat and the community
Stable release 1.10.0[1] / August 25, 2015; 3 months ago (2015-08-25)
Written in C
Operating system Cross-platform
License GNU GPL version 2 or later, or AFL 2.1[2]
Website www.freedesktop.org/wiki/Software/dbus

In computing, D-Bus or DBus is an inter-process communication (IPC) and remote procedure call (RPC) mechanism that allows communication between multiple computer programs (that is, processes) concurrently running on the same machine.[3][4] D-Bus was developed as part of the freedesktop.org project, initiated by Havoc Pennington from Red Hat to standardize services provided by Linux desktop environments such as GNOME and KDE.[5][6]

The freedesktop.org project also developed a free and open-source software library called libdbus, as a reference implementation of the specification. This library is often confused with the D-Bus itself. Other implementations of D-Bus also exist, such as GDBus (GNOME),[7] QtDBus (Qt/KDE),[8] dbus-java[9] and sd-bus (part of systemd).[10]


D-Bus is an IPC mechanism initially designed to replace the software component communications systems used by GNOME and KDE Linux desktop environments (CORBA and DCOP respectively).[11][12] The components of these desktop environments are normally distributed in many processes, each one providing only a few —usually one— service. These services may be used by regular client applications or by other components of the desktop environment to perform their tasks.

Processes without D-Bus
Processes without D-Bus
Processes with D-Bus
Same processes with D-Bus
Large groups of cooperating processes demand a dense mesh of individual communication channels (using one-to-one IPC methods) between them. D-Bus simplifies the IPC requirements with one single shared channel.

Due to the large number of processes involved —adding up processes providing the services and clients accessing them— establishing one-to-one IPC communications between all of them is an inefficient and quite unreliable approach. Instead, D-Bus provides an abstraction called bus that gathers all the communications between a group of processes over a single shared virtual channel.[4] Processes connected to a bus don't know how it is internally implemented, but D-Bus specification guarantees that every process connected to the bus is able to communicate with each other through it.

Linux desktop environments take advantage of the D-Bus facilities by instancing not one bus but many[13][4][14]:

  • a single system bus, available to all users and processes of the system, that provides access to system services (i.e. services provided by the operating system and also by any system daemons).
  • a session bus for each user login session, that provides desktop services to user applications in the same desktop session, and allows the integration of the desktop session as a whole.

A process can connect to any number of buses, provided that it has granted access to them. In practice, this means that any user process can connect to the system bus and to its current session bus, but not to another users' session buses, or even to a different session bus owned by the same user. The latter restriction may change in the future if all user sessions are combined into a single one user bus.[15]

D-Bus provides additional or simplifies existing functionality to the applications, including information sharing, modularity and privilege separation. For example, information on an incoming voice call received through Bluetooth or Skype can be propagated and interpreted by any currently running music player, which can react by muting the volume or pausing playback until the call is finished.[16]

D-Bus can also be used as a framework to integrate different components of an user application. For instance, an office suite can communicate through the session bus to share data between the word processor and the spreadsheet.

D-Bus Specification[edit]

Bus model[edit]

Every connection to a bus is identified in the context of D-Bus by what is called a bus name.[3] A bus name consists of two or more dot-separated strings of letters, digits, dashes, and underscores. An example of a valid bus name is org.freedesktop.NetworkManager.[4]

When a process sets up a connection to a bus, the bus assigns to the connection a special bus name called unique connection name.[14][4] This type of bus names are immutable —it's guaranteed they won't change as long as the connection exists— and, more importantly, they can't be reused during the bus lifetime.[3][14][4] This means that no other connection to that bus will ever have assigned such unique connection name, even if the same process closes down the connection to the bus and creates a new one. Unique connection names are easily recognizable because they start with the —otherwise forbidden— colon character.[14][4] An example of a unique connection name is :1.1553 (the characters after the colon have no particular meaning[14]).

A process can ask for additional bus names for its connection,[14] provided that any requested name is not already being used by another connection to the bus. In D-Bus parlance, when a bus name is assigned to a connection, it is said the connection owns the bus name.[3][14] In that sense, a bus name can't be owned by two connections at the same time, but, unlike unique connection names, these names can be reused if they are available: a process may reclaim a bus name released —purposely or not— by another process.[3][4]

The idea behind these additional bus names, commonly called well-known names, is to provide a way to refer to a service using a prearranged bus name.[14][4] For instance, the service that reports the current time and date in the system bus lies in the process whose connection owns the org.freedesktop.timedate1 bus name, regardless of which process it is.

Bus names can be used as a simple way to implement single instance applications (second instances detect that the bus name is already taken).[14] It can also be used to track a service process lifecycle, since the bus sends a notification when a bus name is released due to a process termination.[14]

Object model[edit]

Because its original conception as a replacement of several component oriented communications systems, D-Bus shares with its predecessors an object model in which to express the semantics of the communications between clients and services. The terms used in the D-Bus object model mimics those used by some object oriented programming languages. That doesn't mean that D-Bus is somehow limited to OOP languages —in fact, the most used implementation is written in C, a procedural programming language.

Browsing the existing bus names, objects, interfaces, methods and signals in a D-Bus bus using D-Feet

In D-Bus, a process offers its services exposing objects. These objects have methods that can be invoked, and signals that the object can emit.[14] Methods and signals are collectively referred as the members of the object.[3] Any client connected to the bus can interact with an object by using its methods, making requests or commanding the object to perform actions.[14] For instance, an object representing a time service can be queried by a client using a method that returns the current date and time. A client can also listen to signals that an object emits when its state changes due to certain events, usually related to the underlying service. An example would be when a service that manages hardware devices —such as USB or network drives— signals a "new hardware device added" event. Clients should instruct the bus that they are interested in receiving certain signals from a particular object, since a D-Bus bus only passes signals to those processes with a registered interest in them.[4]

A process connected to a D-Bus bus can request it to export as many D-Bus objects as it wants. Each object is identified by an object path, a string of numbers, letters and underscores separated and prefixed by the slash character, called that because of their resemblance to Unix filesystem paths.[3][14] The object path is selected by the requesting process, and must be unique in the context of that bus connection. An example of a valid object path is /org/kde/kspread/sheets/3/cells/4/5.[14] However, it's not enforced —but also not discouraged— to form hierarchies within object paths.[4] The particular naming convention for the objects of a service is entirely up to the developers of such service, but many developers choose to namespace them using the reserved domain name of the project as a prefix (e.g. /org/kde).[14]

Every object is inextricably associated to the particular bus connection where it was exported, and, from the D-Bus point of view, only lives in the context of such connection. Therefore, in order to be able to use a certain service, a client must indicate not only the object path providing the desired service, but also the bus name under which the service process is connected to the bus.[3] This in turn allows that several processes connected to the bus can export different objects with identical object paths unambiguously.

Members —methods and signals— that can be used with an object are specified by an interface.[14] An interface is a set of declarations of methods (including its passing and returning parameters) and signals (including its parameters) identified by a dot-separated name resembling the Java language interfaces notation.[14][4] An example of a valid interface name is org.freedesktop.Introspectable.[4] Despite their similarity, interface names and bus names should not be mistaken. A D-Bus object can implement several interfaces, but at least must implement one, providing support for every method and signal defined by it. The combination of all interfaces implemented by an object is called the object type.[3][14]

When using an object, it's a good practice for the client process to provide the member's interface name besides the member's name, but is only mandatory when there is an ambiguity caused by duplicated member names available from different interfaces implemented by the object[3][14] —otherwise, the selected member is undefined or erroneous. An emitted signal, on the other hand, must always indicate to which interface it belongs.

The D-Bus specification also defines several standard interfaces that objects may want to implement in addition to its own interfaces.[13] Although technically optional, most D-Bus service developers choose to support them in their exported objects since they offer important additional features to D-Bus clients, such as introspection.[4] These standard interfaces are:[13][4]

  • org.freedesktop.DBus.Peer: provides a way to test if a D-Bus connection is alive.[4]
  • org.freedesktop.DBus.Introspectable: provides an introspection mechanism by which a client process can get in run-time a description (in XML format) of the interfaces, methods and signals that the object implements.[14][13]
  • org.freedesktop.DBus.Properties: allows a D-Bus object to expose the underlying native object properties or attributes, or simulate them if it doesn't exist.[13]
  • org.freedesktop.DBus.ObjectManager: : when a D-Bus service arranges its objects hierarchically, this interface provides a way to query an object about all sub-objects under its path, as well as their interfaces and properties, using a single method call.[13]

The D-Bus specification defines a number of administrative bus operations (called "bus services") to be performed using the /org/freedesktop/DBus object that resides in the org.freedesktop.DBus bus name.[13] Each bus reserves this special bus name for itself, and manages any requests made specifically to this combination of bus name and object path. The administrative operations provided by the bus are those defined by the object's interface org.freedesktop.DBus. These operations are used for example to provide information about the status of the bus,[3] or to manage the request and release of additional well-known bus names.[13][4]

Communications model[edit]

D-Bus was conceived as a generic, high-level inter-process communication system. To accomplish such goals, D-Bus communications are based on the exchange of messages between processes instead of "raw bytes".[3][14] D-Bus messages are high-level discrete items that a process can send through the bus to another connected process. Messages have a well-defined structure (even the types of the data carried in their payload are defined), allowing the bus to validate them and to reject any ill-formed message. In this regard, D-Bus is closer to an RPC mechanism than to a classic IPC mechanism, with its own type definition system and its own marshaling.[3]

Example of one-to-one request-response message exchange to invoke a method over D-Bus.

The bus supports two modes of interchanging messages between a client and a service process[3]:

  • One-to-one request-response: This is the way for a client to invoke an object's method. The client sends a message to the service process exporting the object, and the service in turn replies with a message back to the client process.[14] The message sent by the client must contain the object path, the name of the invoked method (and optionally the name of its interface), and the values of the input parameters (if any) as defined by the object's selected interface. The reply message carries the result of the request, including the values of the output parameters returned by the object's method invocation, or exception information if there was an error.[3][14]
  • Publish/subscribe: This is the way for an object to announce the occurrence of a signal to the interested parties. The object's service process broadcasts a message that the bus passes only to the connected clients subscribed to the object's signal.[14] The message carries the object path, the name of the signal, the interface to which the signal belongs, and also the values of the signal's parameters (if any). The communication is one-way: there are no response messages to the original message from any client process, since the sender knows neither the identities nor the number of the recipients.[3][14]

Every D-Bus message consists of a header and a body.[14] The header is formed by several fields that identifies the type of message, the sender, as well as information required to deliver the message to its recipient (destination bus name, object path, method or signal name, interface name, etc).[14][13] The body contains the data payload that the receiver process interprets —for instance the input or output arguments. All the data is encoded in a well known binary format called the wire format which supports the serialization of various types, such as integers and floating-point numbers, strings, compound types, and so on.[13]

The D-Bus specification defines the wire protocol: how to build the D-Bus messages to be exchanged between processes within a D-Bus connection. However, it does not define the underlying transport method for delivering these messages.


Most existing D-Bus implementations follow the architecture of the reference implementation. This architecture consists of two main components:[3]

  • a point-to-point communications library that implements the D-Bus wire protocol in order to exchange messages between two processes. In the reference implementation this library is libdbus. In other implementations libdbus may be wrapped by another higher-lever library, language binding, or entirely replaced by a different standalone implementation that serves the same purpose.[17] This library only supports one-to-one communications between two processes.[14]
  • A dbus-daemon process acting as a D-Bus message bus daemon. Every process connected to the bus keeps one D-Bus connection with it.
    a special daemon process that plays the bus role and to which the rest of the processes connect using any D-Bus point-to-point communications library. This process is also known as the message bus daemon,[16] since it is responsible for routing messages from any process connected to the bus to another. In the reference implementation this role is performed by dbus-daemon, and so it is in all other implementations since no one has developed an alternative. dbus-daemon itself is built on top of libdbus.
Process A and B have an one-to-one D-Bus connection between them over an Unix domain socket
Process A and B have an one-to-one D-Bus connection using libdbus over an Unix domain socket. The can use it to exchange messages directly.[18] In this case bus names are not used.[14]
Process A and B have both an one-to-one D-Bus connection with a dbus-daemon process over an Unix domain socket
Process A and B both connected to a dbus-daemon using libdbus over an Unix domain socket. They can exchange messages routing them through the message bus process.

The libdbus library (or its equivalent) internally uses a native lower-level IPC mechanism to transport the required D-Bus messages between the two processes in both ends of the D-Bus connection. D-Bus specification doesn't mandate which particular IPC transport mechanisms should be available to use, it's the communications library the one that decides what transport methods it supports. For instance, in Linux and Unix-like operating systems libdbus typically uses Unix domain sockets as the underlying transport method, but it also supports TCP sockets.[3][14]

The communications libraries of both processes must agree on the selected transport method and also on the particular channel used for their communication. This information is defined by what D-Bus calls an address.[4][14] Unix-domain socket are filesystem objects, and therefore they can be identified by a filename, so a valid address would be unix:path=/tmp/.hiddensocket.[3][13] Both processes must pass the same address to their respective communications libraries to establish the D-Bus connection between them. An address can also provide additional data to the communications library in the form of comma-separated key=value pairs.[4][13] This way, for example, it can provide authentication information to a specific type of connection that supports it.

When a message bus daemon like dbus-daemon is used to implement a D-Bus bus, all processes that want to connect to the bus must know the bus address, the address by which a process can establish a D-Bus connection to the central message bus process.[3][14] In this scenario, the message bus daemon selects the bus address and the remainder processes must pass that value to their corresponding libdbus or equivalent libraries. dbus-daemon defines a different bus address for every bus instance it provides. These addresses are defined in the daemon's configuration files.

Two processes can use a D-Bus connection to exchange messages directly between them[18], but this is not the way in which D-Bus is normally intended to use. The usual way is to always use a message bus daemon (i.e. dbus-daemon) as a communications central point to which each process should establish its point-to-point D-Bus connection. When a process —client or service— sends a D-Bus message, the message bus process receives it in the first instance and delivers it to the appropriate recipient. The message bus daemon may be seen as a hub or router in charge of getting each message to its destination by repeating it through the D-Bus connection to the recipient process.[14] The recipient process is determined by the destination bus name in the message's header field,[13] or by the subscription information to signals maintained by the message bus daemon in the case of signal propagation messages.[4] The message bus daemon can also produce its own messages as a response to certain conditions, such as a error message to a process that sent a message to a nonexistent bus name.[14]

dbus-daemon improves the feature set already provided by D-Bus itself with additional functionality. For example, service activation allows to automatically start services only when they are needed —when the first request to any bus name of such service arrives to the message bus daemon.[3] This way, service processes neither need to be launched during the system initialization or user initialization stage nor they consume memory or another resources if they are not actually used.

History and adoption[edit]

D-Bus was started in 2002 by Havoc Pennington and Alex Larsson (Red Hat) and Anders Carlsson.[6] The version 1.0 —considered API stable— was released in November 2006.[19][20]

The dbus-daemon plays a significant role in modern Linux graphical desktop environments. Binder, also depicted above, is its counterpart used on Android.

Heavily influenced by the DCOP system used by versions 2 and 3 of KDE, D-Bus has replaced DCOP in the KDE 4 release.[20][21] An implementation of D-Bus supports most POSIX operating systems, and a port for Windows exists. It is used by Qt 4 and GNOME. In GNOME it has gradually replaced most parts of the earlier Bonobo mechanism. It is also used by Xfce.

One of the earlier adopters was the (nowadays deprecated) Hardware Abstraction Layer. HAL used D-Bus to export information about hardware that has been added to or removed from the computer.[6]

The usage of D-Bus is steadily expanding beyond the initial scope of desktop environments to cover an increasing amount of system services. For instance, NetworkManager network daemon, BlueZ bluetooth stack and Pulseaudio sound server use D-Bus to provide part or all of its services, and systemd is promoting traditional system daemons to D-Bus services, such as logind.[22] Another heavy user of D-Bus is Polkit, whose policy authority daemon is implemented as a service connected to the system bus.[23]

It is also used as the Wire protocol for the AllJoyn protocol for home automation, to this end AllJoyn adds discovery, session management, security, header compression, embedded device support and makes it transport agnostic.[24]


Although there are several implementations of D-Bus, the most widely used is the reference implementation libdbus, developed by the same freedesktop.org project that designed the specification. However, libdbus is a low-level implementation that was never meant to be used directly by application developers, but as a reference guide for other reimplementations of D-Bus (such as those included in standard libraries of desktop environments, or in programming language bindings). The freedesktop.org project itself recommends applications authors to "use one of the higher level bindings or implementations" instead.[25]
The predominance of libdbus as the most used D-Bus implementation caused the terms "D-Bus" and "libdbus" to be often used interchangeably, leading to confusion.
GDBus[7] is an implementation of D-Bus based on GIO streams included in GLib, aiming to be used by GTK+ and GNOME. GDBus is not a wrapper of libdbus, but a complete and independent reimplementation of the D-Bus specification and protocol.[26]
QtDBus[8] is an implementation of D-Bus included in the Qt library since its version 4.2. This component is used by KDE applications, libraries and components to access the D-Bus services available in a system.
In 2013, the systemd project rewrote libdbus in an effort to simplify the code,[27] but it also resulted in a significant increase of the overall D-Bus performance. In preliminary benchmarks, BMW found that the systemd's D-Bus library increased performance by 360%.[28] As of version 221 of systemd, the sd-bus API has been declared stable.[29]
There is an ongoing development project called kdbus that aims to reimplement D-Bus as a kernel-mediated peer-to-peer inter-process communication mechanism. Beside performance improvements, kdbus would have advantages arising from already existing Linux kernel features such as namespaces and auditing,[28][30] security from the kernel mediating, closing race conditions, and allowing D-Bus to be used during boot and shutdown (as needed by systemd).[31] kdbus inclusion in the Linux kernel has proven controversial,[32] and as of November 2015 has not been merged yet.
Language bindings
Several programming language bindings for D-Bus has been developed,[33] such as those for Java, C# and Ruby.

See also[edit]


  1. ^ "Announcing D-Bus 1.10.0 (new stable branch)". 2015-08-25. Retrieved 2015-08-25. 
  2. ^ Havoc's Blog July, 2007
  3. ^ a b c d e f g h i j k l m n o p q r s t u Vermeulen, Jeroen (14 Jul 2013). "Introduction to D-Bus". FreeDesktop.org. Retrieved 22 October 2015. 
  4. ^ a b c d e f g h i j k l m n o p q r s t Cocagne, Tom (August 2012). "DBus Overview". pythonhosted.org. Retrieved 22 October 2015. 
  5. ^ Vermeulen, Jeroen (14 Jul 2013). "Introduction to D-Bus". FreeDesktop.org. Retrieved 3 October 2015. D-Bus [...] is designed for use as a unified middleware layer underneath the main free desktop environments. 
  6. ^ a b c Palmieri, John (January 2005). "Get on D-BUS". Red Hat Magazine. Retrieved 3 November 2015. 
  7. ^ a b "gdbus". GNOME developer. Retrieved 4 January 2015. 
  8. ^ a b "QtDBus module". Qt Project. Retrieved 1 June 2015. 
  9. ^ "DBus-Java Documentation". FreeDesktop.org. Retrieved 4 January 2015. 
  10. ^ Poettering, Lennart (19 June 2015). "The new sd-bus API of systemd". Retrieved 21 October 2015. 
  11. ^ Pennington, Havoc; Wheeler, David; Walters, Colin. "D-Bus Tutorial". Retrieved 21 October 2015. For the within-desktop-session use case, the GNOME and KDE desktops have significant previous experience with different IPC solutions such as CORBA and DCOP. D-Bus is built on that experience and carefully tailored to meet the needs of these desktop projects in particular. 
  12. ^ Vermeulen, Jeroen (14 Jul 2013). "Introduction to D-Bus". FreeDesktop.org. Retrieved 3 October 2015. D-Bus was first built to replace the CORBA-like component model underlying the GNOME desktop environment. Similar to DCOP (which is used by KDE), D-Bus is set to become a standard component of the major free desktop environments for GNU/Linux and other platforms. 
  13. ^ a b c d e f g h i j k l m Pennington, Havoc; Carlsson, Anders; Larsson, Alexander; Herzberg, Sven; McVittie, Simon; Zeuthen, David. "D-Bus Specification". Freedesktop.org. Retrieved 22 October 2015. 
  14. ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah Pennington, Havoc; Wheeler, David; Walters, Colin. "D-Bus Tutorial". Retrieved 21 October 2015. 
  15. ^ Poettering, Lennart (19 June 2015). "The new sd-bus API of systemd". Retrieved 21 October 2015. we are working on moving things to a true user bus, of which there is only one per user on a system, regardless how many times that user happens to log in 
  16. ^ a b Love, Robert (5 January 2005). "Get on the D-BUS". Linux Journal. Retrieved 14 October 2014. 
  17. ^ "What is D-Bus?". FreeDesktop.org. Retrieved 29 October 2015. There are also some reimplementations of the D-Bus protocol for languages such as C#, Java, and Ruby. These do not use the libdbus reference implementation 
  18. ^ a b "What is D-Bus?". FreeDesktop.org. Retrieved 29 October 2015. is built on top of a general one-to-one message passing framework, which can be used by any two apps to communicate directly (without going through the message bus daemon) 
  19. ^ Palmieri, John (9 Nov 2006). "[announce] D-Bus 1.0.0 "Blue Bird" released". dbus (Mailing list). 
  20. ^ a b Molkentin, Daniel (12 November 2006). "D-Bus 1.0 "Blue Bird" Released". KDE News. Retrieved 3 November 2015. 
  21. ^ Seigo, Aaron. "Introduction To D-BUS". KDE TechBase. Retrieved 3 November 2015. 
  22. ^ Poettering, Lennart (19 June 2015). "The new sd-bus API of systemd". Retrieved 21 October 2015. Since systemd's inception it has been the IPC system it exposes its interfaces on. 
  23. ^ "Polkit reference manual". FreeDesktop.org. Retrieved 3 November 2015. 
  24. ^ https://allseenalliance.org/developer-resources/forum/developers/difference-d-bus
  25. ^ "What is D-Bus?". FreeDesktop.org. Retrieved 5 January 2015. It should be noted that the low-level implementation is not primarily designed for application authors to use. Rather, it is a basis for binding authors and a reference for reimplementations. If you are able to do so it is recommended that you use one of the higher level bindings or implementations. 
  26. ^ "Migrating to GDBus". GNOME Developer. Retrieved 21 October 2015. dbus-glib uses the libdbus reference implementation, GDBus doesn't. Instead, it relies on GIO streams as transport layer, and has its own implementation for the D-Bus connection setup and authentication. 
  27. ^ Poettering, Lennart (20 Mar 2013). "[HEADSUP] libsystemd-bus + kdbus plans". systemd-devel (Mailing list). 
  28. ^ a b Edge, Jake (30 May 2013). "ALS: Linux inter-process communication and kdbus". LWN.net. Retrieved 21 October 2015. 
  29. ^ Poettering, Lennart (19 Jun 2015). "[ANNOUNCE] systemd v221". systemd-devel (Mailing list). 
  30. ^ Corbet, Jonathan (13 January 2014). "The unveiling of kdbus". LWN.net. Retrieved 11 April 2014. 
  31. ^ Kroah-Hartman, Greg (13 Apr 2015). "[GIT PULL] kdbus for 4.1-rc1". linux kernel (Mailing list). 
  32. ^ Corbet, Jonathan (22 April 2015). "The kdbuswreck". LWN.net. Retrieved 29 June 2015. 
  33. ^ "D-Bus Bindings". FreeDesktop.org. Retrieved 5 January 2015. 

External links[edit]