| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The object server currently either creats the objects and interfaces, or
defer the signal by not adding objects.
In practice, we have situations that the code would like to add
interfaces to an existing object, and it's not supported, or needs
tricky code to workaround.
Exmaples:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-bmc-code-mgmt/+/5820
https://gerrit.openbmc-project.xyz/c/openbmc/openpower-pnor-code-mgmt/+/5346
This commit adds the support by:
1. Adding emit_added() in interface.hpp and the generated server.hpp
2. Adding a enum class in object's constructor to indicate which action
to do, to create the object, or adding the interface, or defer signal
as before.
So the user of object<> could pass `action::emit_interface_added` to the
constructor to tell the object server *only* emit interface added to
DBus, without emitting object added.
The previous code stays the same behavior:
* If `true` is passed in object's constructor, it defers emitting object
added signal;
* If no extra parameter is passed in object's constructor, it emits
object added signal as before.
Tested: 1. Make sure the openbmc builds fine with
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-logging/+/25089
because phosphor-logging uses its own server.hpp for interface, the
above patch removes that.
2. Manually write a small service to verify the interfaces are
added and removed by using the `emit_interface_added` action.
3. Added the unit test cases for object.hpp to check the
ctor/dtor with different actions.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I178c5bed3c9ff39ee2ac8d143fbe9131b0753dfa
|
| |
|
|
|
|
|
|
| |
The convert<enum>FromString functions were indented incorrectly
relative to the rest of the class.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iabe9d30c33c8707bf2bf4c6a697e3d27d0a3000b
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The interface string was private, and the users of sdbusplus have to
define their own strings for the D-Bus interfaces.
By making the interface string public, users do not have to define their
own and the generated string could be used instead.
E.g. one could directly use "Calculator::interface" instead of
"net.poettering.Calculator" in the example.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I0846d4e0609c8588d81e8a19bdd69fd79df83848
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Objects don't take kwargs for their constructors so don't call the
object constructor with kwargs
```
| Traceback (most recent call last):
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/bin/sdbus++", line 50, in <module>
| main()
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/bin/sdbus++", line 45, in main
| instance = valid_types[args.typeName].load(args.item, args.rootdir)
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/lib/python2.7/site-packages/sdbusplus/interface.py", line 21, in load
| return Interface(**y)
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/lib/python2.7/site-packages/sdbusplus/interface.py", line 25, in __init__
| [Property(**p) for p in kwargs.pop('properties', [])]
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/lib/python2.7/site-packages/sdbusplus/property.py", line 12, in __init__
| super(Property, self).__init__(**kwargs)
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/lib/python2.7/site-packages/sdbusplus/namedelement.py", line 8, in __init__
| super(NamedElement, self).__init__(**kwargs)
| File "/home/spirit/src/vesnin/openbmc-alternate/build/tmp/work/armv5e-openbmc-linux-gnueabi/phosphor-dbus-interfaces/1.0-r1/recipe-sysroot-native/usr/lib/python2.7/site-packages/sdbusplus/renderer.py", line 3, in __init__
| super(Renderer, self).__init__(**kwargs)
| TypeError: object.__init__() takes no parameters
```
Fixes openbmc/sdbusplus#30
Tested:
Ran with some locally modified properties marked as const. Verified
that the generated code marks those as const and removes their
setter
Change-Id: I94965add8588a8a3168662e00ef2502276440ee5
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Now that we are using std::variant we should reference it directly
instead of using our own namespace alias.
Tested:
Built and ran through unit tests.
Change-Id: Ic3fd62ea74cf808b85ad7b7ffcce8c0a0bfb125d
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
|
| |
It is common for enums to be shared across different dbus definitions.
This change adds the functionality to automatically generate the correct
includes for the server.hpp files.
Change-Id: Ic5b8df55b58479d18dd4aee20ead9c05b867b968
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
| |
This allows for a future change that adds includes to the generated
server.hpp file that it needs for enum definitions.
Change-Id: Id8ecd03a8cc1155cc9032840f38bf5ccb28d40c0
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
| |
This allows the signal generator to emit include directives
Change-Id: I47a13102491116772c31b57ca58824fda3612938
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For properties of type string, allow a default value to be set for the
property on the interface. This provides the ability to have a default
value to an intended free-form string instead of using enumerated
values.
Tested:
Verified generated interface object initializes a string property
to a default value
Only properties of type string with a default defined are initialized
with the given default value as a string
Change-Id: I1e75dff1c26a4a872e9e3e7959106470c32c9be7
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 8192be92b9bf50450eb309a8798b3895bfdae471.
The commit "Fix incorrect defaultValue in generated server.hpp" revealed
an issue in phosphor-dbus-interfaces that causes the build error, and it
was reverted temporarily.
The issue is fixed in phosphor-dbus-interface, so we could add it back.
Change-Id: I1700ff1ede5f0eedc11fc324f649ea4f2e76edf5
Signed-off-by: Lei YU <mine260309@gmail.com>
|
| |
|
|
|
| |
Change-Id: I2d1402c38b7b8b39cee42f959a0421b24a80e45d
Signed-off-by: Waqar Hameed <waqarh@axis.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 14269fbcc15fd0e764f672de144d44e8ee26dd78.
This caused the following compile failure in phosphor-dbus-interfaces:
16:52:02 make[1]: Entering directory '/phosphor-dbus-interfaces-99b5aaa499c2f1a71a031051136744ad1e7df869'
16:52:02 CXX libphosphor_dbus_la-libphosphor_dbus.lo
16:52:05 In file included from libphosphor_dbus.cpp:16151:0:
16:52:05 ./xyz/openbmc_project/User/Ldap/Config/server.hpp:195:53: error: expected unqualified-id before numeric constant
16:52:05 SearchScope _lDAPSearchScope = SearchScope::0;
16:52:05 ^
16:52:05 make[1]: *** [libphosphor_dbus_la-libphosphor_dbus.lo] Error 1
16:52:08 make: *** [all] Error 2
Change-Id: Ie4c2f99d08b96845da86634ad73b9c8af56b656c
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In property.py, the defaultValue is got from yaml and it could be
string, bool, or numeric.
In case of bool, the value becomes True/False, and when it is rendered
in C++ code, the code will not compile due to C++ expects true/false
instead.
And in server.hpp template, it checks "if p.defaultValue", and if the
default value is "false" or 0, p.defaultValue becomes False, so the
generated C++ code will not have default value.
For example, a var defined in yaml has below default value:
default: true
default: false
default: 0
will be rendered in C++ code as:
var = True;
var{};
var{};
This commit fixes the issue by converting defaultValue from True/False
to true/false string, and check if by "if p.defaultValue is not None".
Tested: Verify the above exmaple will generate valid C++ code as below:
var = true;
var = false;
var = 0;
Change-Id: I65c9f5222aa2d7b53299a53ff63d33bd6d073b95
Signed-off-by: Lei YU <mine260309@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
The return value from sd_bus_error_set is always a negative error value
mapping to the provided name. We should use this value instead of always
returning -EINVAL.
Change-Id: I102c7a0b306db873d44e9c1b7cbd9cc146ffe29c
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sd_bus_error_set_const takes pointers to c-style strings as arguments
which populate its name and message. This function does not take any
ownership of the name or message, requiring the to live beyond the
lifetime of the error. Since we are destroying the error object as soon
as we leave the catch blocks, we are destroying the strings passed to
the sd_bus_error. This violates the lifetime guarantee.
Instead, use the sd_bus_error_set method which copies the strings. We
know that the callers of these callbacks free the errors by inspecting
the libsystemd code.
Tested:
Run through unit tests which still pass
Change-Id: Ifa1533fc4c41db070f5bf2901581e9f5680cabfc
Signed-off-by: William A. Kennington III <wak@google.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function convertForMessage() takes an enum class as input, and it
assume the enum value is valid and does not check the return value of
std::find_if().
If user deliberately passes an invalid enum value, it causes undefined
behavior.
Handle this case by checking the return value and throw
std::invalid_argument if the input argument is invalid.
Tested: Verify the unit test in phosphor-time-manager passed; without
the fix, the test fails when -flto is enabled.
Change-Id: I3874eaeb44b8e89469690a21090005d299d0f4b1
Signed-off-by: Lei YU <mine260309@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is already support for setting a property as const
(see vtable.hpp and corresponding test cases).
Implement this in the generated code by adding support
for a new yaml flag.
Closes openbmc/openbmc#2028
Tested: Added the const flag to the Software Priority property,
and changing the value via REST and busctl would fail with
"org.freedesktop.DBus.Error.PropertyReadOnly", but the code
update app was able to set its value.
Change-Id: I8534753233080366503fd4f1a0c224c2946e8764
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
|
|
|
|
|
| |
PropertyChanged signals are sent out, even before
InterfacesAdded signals (if deferSignal is set to true in
Object) are sent. This patch provides an option, to skip sending out
PropertiesChanged signal for proper initialization sequence.
Change-Id: I1678d80cc382fce420dda9f0dd9413d43c1c711d
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Add errors support for properties.
Closes openbmc/openbmc#1641
Tested: Verified that when an interface threw a defined property
error, the generated code caught it and returned an error to
the REST call.
Change-Id: I8cb8c77995026f12e373291822e4e0a623a84d81
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Move the template that generates the property-related code
to its own file out of the interface.mako file so that it's
easier/cleaner to add additional features to the property
template such as error handling.
Tested: Verified the generated code for the example
Calculator remained the same.
Change-Id: Idee37d4b1db6701ffc22de84a7a7ea07a2006d61
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
|
|
|
|
| |
The generated dbus-interface server objects now pass their
sd-bus library calls through whatever interface was provided
in the sdbusplus::bus::bus they received.
Change-Id: Ib57a0f7c87c3cad9920cb4427b833cc66932afa2
Signed-off-by: Patrick Venture <venture@google.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Currently if a property named 'name' is added, it collides
with the parameter name. Rename the parameter to _name so
this won't happen.
Tested: Added a property named name to interface and
bitbake phosphor-dbus-interfaces
Change-Id: Iee685612276e1bf2515bcb32c41e21487f344471
Signed-off-by: James Feist <james.feist@linux.intel.com>
|
| |
|
|
|
| |
Change-Id: I5a69ad0e55e3907d3764d0398738902f167b976f
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
|
| |
|
|
|
|
|
|
|
| |
With example moved to the root directory and there being an explicit
makefile for the example calculator application, there is no need to
have sdbus++ default to 'example'.
Change-Id: I2a20883d7ea88b56e1bd073ef395c236215a4132
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: Icb6a6ca266181e9b401eec64dbbada8b7e334229
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: I884ed42a53e30c9209b45e74f6317ec19bb344b4
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The python setup script looks for the needed mako templates in
source directory (srcdir). But if the sdbusplus repository is
built through bitbake, the mako templates that are auto-generated
are created in the build directory (builddir).
Copy all the needed files to the builddir, specify update=1
to preserve any built file from being overwritten.
This allows for support of out of tree builds.
Change-Id: Icb6090df5ea083b4b5f1bc1c5b320d40f57596e0
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
| |
Change-Id: I83d51e9aaa165e646ce711cc8bc551f010edc448
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
| |
Allow the transaction id support to be enabled via
configure options.
In the code, ifdef the code based if transaction support
is desired.
Change-Id: I98695268397f437b6fe14621f820fbcaecb45b7a
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
|
|
|
|
| |
Add a method to the server bindings that gets properties
by looking up the name from a string.
Change-Id: I304504ba20d6747afba27cd08f79bcc564c34a46
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
|
| |
|
|
|
|
|
|
|
|
| |
Add a constructor that takes a map of property-names to
values and initializes all properties in the map with those
values.
Change-Id: Id0eaa2ec43aed490719d12537e75c1278d290013
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
|
| |
|
|
|
|
|
|
|
| |
Add a method to the server bindings that sets properties
by looking up the name from a string.
Change-Id: I7e9081b66dfeffd394155a574c2178a7cd039e2a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Initialize the transaction id in the code generated by the sdbusplus tool.
Generate a unique value if the transaction id has not been
initialized and a caller requests it. This is the scenario for
clients that have not made a dbus call yet and create journal
entries.
Change-Id: Ia7b926fd3f83963fac01fbd1ce4cdd59d2224008
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are cases of calling the message constructor where the
ownership of the raw pointer is transfered and others where it
is duplicated. The ownership-transfer use-cases are likely all
embedded within sdbusplus itself and the ownership-duplicate
cases tend to be done by external users. This causes the current
API to be bug-prone as it requires something like:
sdbusplus::message::message(sd_bus_message_ref(m));
Change the conversion constructor to not require the external _ref
call and instead add a new constructor that bypasses the ref.
Thus, the calling conventions now look like this:
Ownership-duplicate:
sdbusplus::message::message(m); // calls _ref.
Ownership-transfer:
sdbusplus::message::message(m, std::false_type()); // no _ref.
Resolves openbmc/openbmc#950.
Change-Id: Ia1ae527c4d1235b1625368cfffeb4ed495457768
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: I6075a6a52553d0dc7dca6abc3442282f91fb5d44
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: I3efcfb0575cdfecb86f72368f34d4d33d9e00318
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Some words are reserved in C++, so they cannot be used as function
or variable names. If a YAML file specifies these we must come up
with an alternative name for the generated C++ function. Do this
by adding underscore characters to the generated name.
Fixes openbmc/sdbusplus#10.
Change-Id: I992caafb02fe71ea6ac2cf3c555a9956e4ba616a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: Ib353e19793bda85815826f7b835fd6f3c5d8e908
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The fix to openbmc/sdbusplus#4 broke the generation of enums, because
enums are currently not directly parsed by the cpp type conversion.
This also means that there is additional work required to support enums
nested into containers.
Fixes openbmc/sdbusplus#8
Change-Id: I4f206fa899d84128bc7463d54c5b83e40e28d61f
Signed-off-by: Christian Andersen <c.andersen@kostal.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
The type array contructed by YAML is difficult to process recursively.
So the type array gets preprocessed and converted to a recursive data
structure.
Fixes openbmc/sdbusplus#4
Change-Id: Ife8a47d9b6babd75835f496702ca5899ac6e18c3
Signed-off-by: Christian Andersen <c.andersen@kostal.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
The generated server bindings register 'this' with sdbus, so
if a move is allowed then the object pointer left with sdbus
no longer exists. Disallow 'move' operations to prevent this.
Fixes openbmc/sdbusplus#6.
Change-Id: I470b1372042d21ce14ad0cd9bc1af68e7394bcb9
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
|
| |
A method with 0 returns could result in incorrectly generated
code due to a mistake that looked at the param-count instead
of the return-count.
Fixes openbmc/sdbusplus#3.
Change-Id: Ifbbd89ab8c8dcfee60c18446f30446b052992f3f
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
| |
Removed leading spaces that were leaving trailing spaces in generated
files.
Change-Id: I99927e7b8fe3762cf0cc28d113e02eae2fcd4db3
Signed-off-by: Abhishek Pandit <abhishekpandit@google.com>
|
| |
|
|
|
| |
Change-Id: I4230d5ebc7d2a470d9ae2d3bb03a9918a29ba919
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
| |
Perform final type conversion using 'convert*' functions to change
between dbus strings and C++ enumerations for methods, properties,
and signals.
Change-Id: I22e8fd424eeecac176c64fcc3e7a5d3caf05804a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: Ied31a6c11188fe3d0c909edb5c4bde3e337d96b3
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
| |
Current generation emits for enumerations:
Enum property = EnumValue
Fix this to be:
Enum property = Enum::EnumValue
Change-Id: Iae1e8e4ad73bf8623ed9f3b2d3ec57803c7f18bd
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When an enumeration is used in the bindings, the type of
it depends on the context. We use 'string' types to send
the enumeration across the dbus, so we need to use 'string'
types when doing message operations. We use the real enum
type when calling binding functions, so we need to specify
that in prototypes.
Change-Id: I31ab137b0c751d8a2bdec1c417a60455690ce103
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: I6d02574942b38adbe2dc537f5279721cde2c8bc7
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
| |
|
|
|
| |
Change-Id: Iafdf4c30e312b0ef7faeea3e3a7379f1868a61dc
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|