summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Emit adding/removing interfaces for object serverHEADmasterLei YU2020-02-137-7/+235
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix an issue found by cppcheckLei YU2020-02-111-1/+1
| | | | | | | | | | | | | | cppcheck finds an issue: [sdbusplus/asio/object_server.hpp:46] -> [sdbusplus/asio/object_server.hpp:315]: (style) The function 'set' overrides a function in a base class but is not marked with a 'override' specifier. Fix it by adding the override keyword correctly. Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Ie032229874bb416f7c6ec142d9bf38f8ffcff877
* sdbus++: interface: fix indent of enum-string fnPatrick Williams2020-02-111-6/+6
| | | | | | | | 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
* MAINTAINERS: add Patrick WilliamsPatrick Williams2020-02-111-0/+1
| | | | | | | | | Large portions of the codebase were originally written by me before maintainers existed. I am returning to the project and plan to do significant enhancements and cleanups to sdbusplus. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I3ac6f6597c78041785ded272d1e6ce8974d5b49a
* Catch async errors so they do not throwVernon Mauery2020-02-101-27/+52
| | | | | | | | | | | | | | | When running an async operation, it is not a good idea to throw because the current running context is not the context that it was originally registered from, it is the io run-loop context. So any methods that *would* throw, must run in a try/catch and then set the error code properly so that the handler will be notified of the error. This was caught when a process (bmcweb) was used to invoke a call that had a bad path. That was not caught and it caused bmcweb to abort because of an unhandled exception. Change-Id: Ie66a029066a3f463759089b44368b7518d0de8ce Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Make interface string publicLei YU2020-02-042-2/+3
| | | | | | | | | | | | | 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
* maintainers: Add Lei YU as maintainerLei YU2020-01-151-0/+1
| | | | | | | | | | | Lei has been an active reviewer for sdbusplus, and fixed the CI issue that has been there for quite a while. He is willing to become one of the maintainers for sdbusplus, which is good for speed up the review progress, and for redundancy. Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I39ec5a1adc0d34c4ce2919a92bd7df463818b9d6
* maintainers: Fix dkodihal's email addressLei YU2020-01-151-1/+1
| | | | | | | | | The email address of Deepak is incorrect that does match the one in gerrit. Fix it to use the correct one. Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I0f2cc9bd89f0c2cf232d41018071aeea237cc1fe
* Add valgrind suppressionLei YU2020-01-152-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On latest OpenBMC, sdbusplus CI fails due to valgrind check like below on ppc64le systems: ==5290== Syscall param epoll_ctl(event) points to uninitialised byte(s) ==5290== at 0x4F2FB08: epoll_ctl (syscall-template.S:79) ==5290== by 0x493A8F7: UnknownInlinedFun (sd-event.c:961) ==5290== by 0x493A8F7: sd_event_add_time (sd-event.c:1019) ==5290== by 0x190BB3: phosphor::Timer::Timer(sd_event*, std::function<void ()>) (timer.hpp:62) ==5290== by 0x192B93: TimerTest::TimerTest() (timer.cpp:25) ==5290== by 0x193A13: TimerTest_timerExpiresAfter2seconds_Test::TimerTest_timerExpiresAfter2seconds_Test() (timer.cpp:85) ==5290== by 0x19E11F: testing::internal::TestFactoryImpl<TimerTest_timerExpiresAfter2seconds_Test>::CreateTest() (gtest-internal.h:472) ==5290== by 0x4A52D3B: HandleSehExceptionsInMethodIfSupported<testing::internal::TestFactoryBase, testing::Test*> (gtest.cc:2447) ==5290== by 0x4A52D3B: testing::Test* testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::TestFactoryBase, testing::Test*>(testing::internal::TestFactoryBase*, testing::Test * (testing::internal::TestFactoryBase::*)(), char const*) (gtest.cc:2483) ==5290== by 0x4A40BCB: Run (gtest.cc:2693) ==5290== by 0x4A40BCB: testing::TestInfo::Run() (gtest.cc:2676) ==5290== by 0x4A40DC3: Run (gtest.cc:2825) ==5290== by 0x4A40DC3: testing::TestCase::Run() (gtest.cc:2810) ==5290== by 0x4A414AF: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5216) ==5290== by 0x4A5329B: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc:2447) ==5290== by 0x4A5329B: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl:: *)(), char const*) (gtest.cc:2483) ==5290== by 0x4A416AF: testing::UnitTest::Run() (gtest.cc:4824) ==5290== by 0x4A90917: RUN_ALL_TESTS (gtest.h:2370) ==5290== by 0x4A90917: main (gmock_main.cc:69) ==5290== Address 0x1fff00eafc is on thread 1's stack ==5290== in frame #0, created by epoll_ctl (syscall-template.S:78) ==5290== The root cause is: 1. GCC has a bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77992, that the padding bytes are not initialized. 2. In systemd, the code in [libsystemd/sd-event/sd-event.c][1] using epoll_event hit the above bug: typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t; struct epoll_event { uint32_t events; /* Epoll events */ epoll_data_t data; /* User data variable */ } __EPOLL_PACKED; In glibc, on x86, `__EPOLL_PACKED` is defined as `__attribute__ ((__packed__))`[2], so it's packed and there are no internal padding bytes; On other architectures (e.g. ppc64le), __EPOLL_PACKED is not defined and thus there are 4 internal padding bytes between `events` and `data`, that are not initialized. 3. When epoll_ctl() is invoked, in [Linux kernel][3], it does a copy_from_user() to copy the whole struct into kernel space. That's why Valgrind reports "epoll_ctl(event) points to uninitialised byte(s)", only for non-x86 platforms. 4. The timer test in this repo invokes sd_event_add_time() and eventually hit the above code. The GCC bug is not resolved from 2016. The systemd code is actually correct. There is a [PR][4] sent to systemd trying to workaround the issue, and it is being discussed. Before GCC bug is resolved or systemd PR is accepted, suppress the valgrind error to make it pass the CI. [1]: https://github.com/systemd/systemd/blob/v242/src/libsystemd/sd-event/sd-event.c#L961 [2]: https://github.com/bminor/glibc/blob/f1a0eb5b6762b315517469da47735c51bde6f4ad/sysdeps/unix/sysv/linux/x86/bits/epoll.h#L29 [3]: https://github.com/torvalds/linux/blob/d1eef1c619749b2a57e514a3fa67d9a516ffa919/fs/eventpoll.c#L2095 [4]: https://github.com/systemd/systemd/pull/14353 Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I3a29fd0e28e5c7b69037a7ef2ef9571f93d80df7
* Fix vtable CI errorLei YU2020-01-153-72/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CI reports failure in VtableTest.SameContent, where the case is comparing the binary of example vtables constructed from sdbusplus and macros defined in systemd. The root cause has two parts. Part I: When systemd is updated, the members in struct sd_bus_vtable is updated, e.g. * From v239 to v242, sd_bus_vtable.x.start is updated from struct { size_t element_size; } start; to: struct { size_t element_size; uint64_t features; } start; and sd_bus_vtable.x.method is updated from struct { const char *member; const char *signature; const char *result; sd_bus_message_handler_t handler; size_t offset; } method; to: struct { const char *member; const char *signature; const char *result; sd_bus_message_handler_t handler; size_t offset; const char *names; } method; * From v242 to v243, sd_bus_vtable.x.start is updated to struct { size_t element_size; uint64_t features; const unsigned *vtable_format_reference; } start; The code in vtable.hpp only assign the members in v239, the new members are intialized with 0, so it differs from the vtable constructed from macros defined by systemd. The fix is to use macros from systemd in vtable.hpp as well, which is suggested by systemd: > Please do not initialize this structure directly, use the > macros below instead Part II: The `const char *names` in struct method and signal introduced between systemd v239 and v242 is a pointer to const strings. By default they are "empty" strings, but there is no guarantee that the compiler will use the same pointer for the same string. So the test case can not assume the binaries are the same for two vtables even they are constructed with the same parameters. Update the test case to use real `const char*` and handler/get/set functions and check each member of the struct instead of comparing the binary data by memcmp. Tested: Verify the CI passes. Change-Id: I9e94ff16075dd3f12d73e96438c0d864203bdcf4 Signed-off-by: Lei YU <mine260309@gmail.com>
* Allow async_method_call to provide opt messageRichard Marian Thomaiyar2019-07-101-5/+28
| | | | | | | | | | | | | | | Real D-Bus error message will not be known through boost::system::error_code and hence requires message::message to be forwarded to the caller, through which any D-Bus error message can be read from the sd_bus_error of the message::message. Tested: Added the template for the same, and cross verified with async_method_call, of which handler will accept both error_code & message::message as argument Change-Id: I7ecace1fb880a303dd487fa9de85c043db3413f8 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
* native_types: Fix string_wrapper overloadsWilliam A. Kennington III2019-06-142-7/+22
| | | | | | | | | | We should only coalesce to an r-value reference to our internal string if our object is a move reference. This fixes ambiguous overloads with gcc9. This also ensures that const references cannot be ambiguous with move references by requiring a const volatile reference. Change-Id: I31ed529c015cc311c9933acbc0f0a4aa50fed3a6 Signed-off-by: William A. Kennington III <wak@google.com>
* message: Add get_error()Lei YU2019-06-113-0/+17
| | | | | | | | | | | Add message::get_error() to get sd_bus_error from a message. Tested: Verify the function is added, the build passes, and the user of sdbusplus is able to call message::get_error() to get the const sd_bus_error* pointer. Change-Id: If4c413316ff7654448e9da19adcd3dab2c33675e Signed-off-by: Lei YU <mine260309@gmail.com>
* asio: Allow mutable lambdas + small cleanupJames Feist2019-06-043-12/+16
| | | | | | | | | | | | | | | | There are many cases in which we want to have a mutable capture so that the lambda takes over the parameter and we can modify it after the async callback. By making the top level lambda mutable, the users callback can be mutable. Also remove a couple references to experimental and a copy that I saw when I was fixing this issue. Tested: Added test and made sure that refish which uses many async_method_calls still worked fine Change-Id: Ifb1f9d8b9217187799e2defe429e76a937297ca1 Signed-off-by: James Feist <james.feist@linux.intel.com>
* sdbus++: Fix construction of objects with flagsWilliam A. Kennington III2019-05-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* message: Fix passing of sd_bus interface to new messagesWilliam A. Kennington III2019-05-171-2/+2
| | | | | | | | | This breaks unit testing if we try and mock out the creation of method replies and errors since it will try and use the default implementation instead of the one provided to the initial message or bus. Change-Id: I700bef0bae9a8a371ec0121f8115acd30aee5220 Signed-off-by: William A. Kennington III <wak@google.com>
* Change async_method_call to be no-throwVernon Mauery2019-05-162-11/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The async_method_call() would throw despite the inferred promise that it would not, because the handler would be passed an error_code object. But that would only protect from the dbus method call itself. When it came time to unpack the response, the read_into_tuple(...) method call would throw if the received types did not match the expected types. And because this throw would happen in a separate boost::asio context, the throw would always be fatal. Now, any exception during the D-Bus call or unpacking of parameters will result in an error_code getting passed into the handler so it can take appropriate action. This also updates the example to remove try/catch statements around the async_method_call and yield_method_call examples and shows what happens if the method calls fail because of different types of errors (api/function does not exist vs. incorrect unpack types). Tested-by: run asio-example to see that it works as expected: # /tmp/asio-example voidBar() -> 42 fooYield(yield, 41)... async_send callback error with async_send ipmiInterface:execute(61) async_method_call callback /org/openbmc/control/bmc0 /org/openbmc/control/flash/bmc fooYield(yield, 41)... ipmi call returns OK! foo(41) -> 42 async_method_call callback async_method_call expected failure: generic:foo(41) -> 42 yielding call to foo OK! (-> 42) 22 async call to Properties.Get serialized via yield OK! TestYieldFunction return 42 yielding call to foo OK! (-> 42) yielding call to TestYieldFunction serialized via yield OK! fooYield(yield, 41)... foo(41) -> 42 async call to Properties.Get serialized via yield OK! yielding call to foo OK! (-> 42) TestYieldFunction expected error: generic:22 TestYieldFunctionNotExits expected error: generic:53 *** tick *** *** tock *** *** tick *** *** tick *** *** tick *** Change-Id: I53c91484ed496556342b3ed0a58b690872a2d676 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com> stuff Change-Id: I48da27be7ba8c63f44c12a8b79fffb8f3e085648 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* MAINTAINERS file had the incorrect email addressVernon Mauery2019-05-161-1/+1
| | | | | | | | | I added the incorrect email address to the MAINTAINERS file which causes script errors because that email is not part of any github groups. This updates it to use the correct email. Change-Id: I63393b0d96fdf9c73f0038c0776e0db691cb0fd8 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Change yield_method_call to be no-throwVernon Mauery2019-05-102-14/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The yield_method_call() would throw despite the inferred promise that it would not, because the caller could attach an error_code to the yield object. But that would only protect from the dbus method call itself. When it came time to unpack the response, the read(...) method call would throw if the received types did not match the expected types. Now, the method forces you to pass in an error_code and it will always return the appropriate error instead of throw. Tested-by: run asio-example to see that it works as expected: # /tmp/asio-example voidBar() -> 42 async_send callback error with async_send async_method_call callback /org/openbmc/control/bmc0 /org/openbmc/control/flash/bmc fooYield(yield, 41)... ipmiInterface:execute(61) ipmi call returns OK! fooYield(yield, 41)... foo(41) -> 42 async call to Properties.Get serialized via yield OK! foo(41) -> 42 yielding call to foo OK! (-> 42) TestYieldFunction return 42 yielding call to foo OK! (-> 42) yielding call to TestYieldFunction serialized via yield OK! async call to Properties.Get serialized via yield OK! *** tick *** *** tock *** *** tick *** *** tick *** *** tick *** *** tick *** *** tick *** Change-Id: Iea43acd432107b4149f8e549310cfce2518cbc1d Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Add vmauery to the sdbusplus maintainer listVernon Mauery2019-04-251-0/+1
| | | | | | | | | | Vernon has been an active reviewer gerrit for sdbusplus commits as well as submitting a small pile of commits himself. Also, having more than one maintainer for a project is good for redundancy. Vernon threw his hat in the ring and William OK'd it. Change-Id: I4ee8612493c394ad8cdec68e73e9a3d9bf9d4b45 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* std::variant: Remove uses of the variant_nsWilliam A. Kennington III2019-04-059-42/+50
| | | | | | | | | | | 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>
* sdbus++: Generate includes for enum referencesWilliam A. Kennington III2019-04-034-0/+32
| | | | | | | | | 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>
* sdbus++: Allow server.hpp files to have extra generated includesWilliam A. Kennington III2019-04-031-0/+3
| | | | | | | | 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>
* sdbus++: Fix mako include substitution for signalsWilliam A. Kennington III2019-04-031-4/+1
| | | | | | | This allows the signal generator to emit include directives Change-Id: I47a13102491116772c31b57ca58824fda3612938 Signed-off-by: William A. Kennington III <wak@google.com>
* Fix warnings in forward declarationsEd Tanous2019-03-222-2/+2
| | | | | | | | | | | | | | | | When compiled with clang (or possibly gcc with the right warnings enabled) sdbusplus throws warnings on bus and slot, because the forward declaration declares them as class, when they are in fact struct when they're finally defined. This commit resolves the declarations to match their actual definitions, and resolves the warning. Tested By: Compiled bmcweb with clang, -Wall and -Werror, and compile succeeded Change-Id: Id594669d21a296c65ee2b96f3502e692e451da4c Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* Move to modern asio interfacesEd Tanous2019-03-221-3/+3
| | | | | | | | | | | | async_result is required to be able to support boost 1.70. This commit moves us to it. Tested: Compiled. Changes are non-functional, and simply renamed in newer versions of asio. Change-Id: I46728dc146c4c49eff7907c6aa8bc1525eca5cc2 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* sdbusplus: Provide option to skip signal propertyRichard Marian Thomaiyar2019-03-191-3/+6
| | | | | | | | | | | | | | | | | | InterfacesAdded signal itself will send out all propety details and it's values during start-up of a D-Bus daemon service. Sending properties changed signal confuses the signal handler as it can't differentiate between service restart or real property change event. Exposing a way to skip sending properties changed signal during initialize (to avoid breaking any old one). Tested-by: 1. Verified that when initialize(true) is called, properties changed signal are not sent out from D-Bus daemon 2. Still old method works fine. Change-Id: Ib436ea9313b08623d931c58b11a770081511ab72 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
* autotools: Fix for autoconf-archive 2019.01.19William A. Kennington III2019-03-154-3/+18
| | | | | | | | | The code coverage macros from the archive changed in a backward incompatible way. This adds a workaround to autodetect either version and do the right thing. Change-Id: Ibb95188264f3fece4a18dbcb98f3e90f8350ff21 Signed-off-by: William A. Kennington III <wak@google.com>
* bus: Add chrono types for timeoutsWilliam A. Kennington III2019-03-152-4/+30
| | | | | | | | | | Tested: Builds and runs unit tests as expected. Additionally ran against all of the package in openbmc/* and produced no fallout as expected. Change-Id: Id9e9a33c789666869dd0a47c065d113acb2ceea5 Signed-off-by: William A. Kennington III <wak@google.com>
* sd_event_wrapper must not close descriptorVernon Mauery2019-03-071-0/+3
| | | | | | | | | | The underlying sd_event checks to see that the file descriptor is good before calling close, so if the sd_event_wrapper closes the descriptor first, sd_event calls assert(). The release() mechanism allows the sd_event to close out the descriptor on its own. Change-Id: Icb8ca5ba909478361a90253713a425256556d140 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* message: Add constructor with an int parameter for unix_fdWaqar Hameed2019-03-021-0/+5
| | | | | | | | | This allows implicit conversions from int to unix_fd. This is for instance useful in functions where one wants to return an unix_fd by just supplying the actual int file descriptor. Change-Id: I118b8ec6b5a3d1533f5b05177127c28ad2539f3d Signed-off-by: Waqar Hameed <waqarh@axis.com>
* Add method to check if an interface has been initializedJason M. Bills2019-02-201-0/+5
| | | | | | | | | | | | | | | | Different capabilities are supported depending on if an interface has been initialized (e.g. register_property is only available before initialization and set_property is only available after). This change adds a method to check if an interface has been initialized to help determine which capabilities are currently supported. Tested: Ran a module that uses register_property and set_property based on this return value and confirmed that the properties are set accordingly. Change-Id: Iac39887f5d92981a316d1046f2f3d3ab71d15878 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
* Support default string valuesMatthew Barth2019-02-071-5/+9
| | | | | | | | | | | | | | | | 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>
* Fix: ObjectManager path for asioRichard Marian Thomaiyar2019-02-021-4/+8
| | | | | | | | | | | | | | | | | | | | | | For asio based registration, ObjectManager's are created under "/" folder. This makes dynamic detection difficult based on the service root object path. Updated library to skip ObjectManager creation, which can be created separately by the needed daemon under the root object base path This is needed, as dynamic detection of service name can be performed on org.freedeskop.DBus.ObjectManager interface when the root object doesn't have any interfaces. Unit-test: 1. Verified it is compiling, and compatibile with existing code 2. Verified that ObjectManager is under the needed base path when argument passed from service daemon. 3. Able to find service name using GetObject under objectMapper, when service daemon, doens't have any other interface in root base path other than org.freedesktop.DBus.Manager Change-Id: Ie1ddf62df0df3849fc761995813c97872d96eb33 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
* Revert "Revert "Fix incorrect defaultValue in generated server.hpp""Lei YU2019-01-172-1/+7
| | | | | | | | | | | | | 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>
* bus: Only close connections we ownWilliam A. Kennington III2019-01-142-12/+26
| | | | | | | | | | | | | | | | | | | If we have multiple code segments in the same thread acquiring the default bus, we end up with the potential for one of those handles to be destroyed, calling sd_event_flush_close_unref(). This terminates the bus for all users of the same reference. Any of the reference which still exist after the first destroy will then return ENOTCONN for all bus operations since it is now closed. This behavior is undesirable as we expect to be able to have transient bus references. However, we do want to make sure we clean up any buses created by sd_bus_open(). See openbmc/phosphor-time-manager@4e84539349dac086ce2a58e5b9900ed4e40a2eaf for a specific example of this behavior being unwanted. Change-Id: I8aad7e282e9d66993b63e85532dce37c179ad5dc Signed-off-by: William A. Kennington III <wak@google.com>
* bus: Add missing sd_bus_open() equivalentWilliam A. Kennington III2019-01-141-0/+7
| | | | | Change-Id: I8181dc8932353e8f37da9fab168f34f214d222c0 Signed-off-by: William A. Kennington III <wak@google.com>
* Move asio interfaces away from deprecated namesEd Tanous2019-01-124-14/+14
| | | | | | | | | | | | | | | The intent of this commit is to allow building asio based event loops in applications with BOOST_ASIO_NO_DEPRECATED flag set. This change is largely a sed replace of io_service with io_context. This will allow us to move to the networking TS at such time that it is mature. Details on depreated interfaces are available here for reference: https://www.boost.org/doc/libs/1_69_0/doc/html/boost_asio/net_ts.html Change-Id: Ie3cc699effcf855a649dee5bfce2f6616109429b Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* Add support for Unix file descriptorsWaqar Hameed2019-01-106-0/+59
| | | | | Change-Id: I2d1402c38b7b8b39cee42f959a0421b24a80e45d Signed-off-by: Waqar Hameed <waqarh@axis.com>
* Revert "Fix incorrect defaultValue in generated server.hpp"Andrew Geissler2019-01-082-7/+1
| | | | | | | | | | | | | | | | | 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>
* Fix incorrect defaultValue in generated server.hppLei YU2019-01-082-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* bus: Add explicit flush and close operationsWilliam A. Kennington III2018-12-193-0/+31
| | | | | | | | | This change exposes explicit flush and close operations on the bus for users who require bus termination at a specific checkpoint instead of program termination. Change-Id: I0e2edce8586956ab286d75d1eb13eeca4309e370 Signed-off-by: William A. Kennington III <wak@google.com>
* update asio set property to signal properlyRichard Marian Thomaiyar2018-12-151-18/+49
| | | | | | | | | | | | | | | | Set property has to send out signal only when there is change in the property and skipped when there is no change but still must return true for the set method accordingly Unit test: Using busctl monitor match rule, monitored the properties changed of sensors (which uses asio logic) and verified by updating the value with same & different one, and observed both the return (success) and the properties changed signal generated only when there is changed in the property value as expected. Change-Id: I79be5b29f496109c19e415cdcfff89af76693de5 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
* asio: Update variant usageYong Li2018-12-131-4/+8
| | | | | | | | | | | | | After the below change in sdbusplus, the variant usage needs to be switched to std::variant https://github.com/openbmc/sdbusplus/commit/90778b430290c9ec8c33fb77b03e2552d9dd6905 Tested: ./configure --enable-boost make Change-Id: Ic1d156ad379eb56822f75e8046f83fa45f4ad56d Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
* bus: route bus deleter to implementationBrad Bishop2018-12-131-9/+17
| | | | | | | | | | | | | | Allow the bus deleter to be routed to a real or mock implementation. Also prevents link errors such as: sysroots/i586-openbmc-linux/usr/include/sdbusplus/bus.hpp:68: undefined reference to `sd_bus_unref' when libsystemd is not linked in. Unit tests still pass and a Witherspoon system QEMU instance still boots to a shell. Change-Id: If498076ddc28acf166c9dab0502f7e209d6e1f2d Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* bus: Add mock and interface for flush_close_unrefBrad Bishop2018-12-132-0/+7
| | | | | | | | | | There are currently direct calls to this - add an interface, impl and mock - so calls can be routed accordingly. Unit tests still pass with this patch applied. Change-Id: I881fedf62d957f6a87b11ab1e35cacbb9402ffa4 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* style: run clang-format on bus/server.hpp.inBrad Bishop2018-12-132-32/+35
| | | | | Change-Id: Iadd0601a9d621fcf27c12112af7d38f5e35e593b Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sdbusplus::asio: Use the default busVernon Mauery2018-12-111-1/+1
| | | | | | | | The documentation says that the default bus calls are the ones to use instead of the open bus calls to reduce resources. Change-Id: I719494adf2e97e94bb5a9925064cda6cfdd28047 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* sdbusplus: better mirror bus aquisition methodsVernon Mauery2018-12-113-3/+21
| | | | | | | | | | | | | | | This adds new functions: * new_default_user() -> return default user bus connection * new_default_system() -> returns default system connection And changes new_default() to return the default type of connection for the user as per the man page: https://www.freedesktop.org/software/systemd/man/sd_bus_default.html Also, update the example and the README to use the default bus calls. Change-Id: I13cd77dda847c4f6018da38e0019816da07710d1 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* asio: Don't allow signaling uninitialized propertiesJames Feist2018-11-301-1/+7
| | | | | | | | | | Signaling a property in an non-initialized interface causes a segfault. Testedy-by: Verified segfault went away. Change-Id: Ib48510e761fb69667040351056853a470c5a9a9f Signed-off-by: James Feist <james.feist@linux.intel.com>
OpenPOWER on IntegriCloud