diff options
author | Agata Olender <agata.olender@intel.com> | 2020-02-04 16:09:40 +0300 |
---|---|---|
committer | Olender, Agata <agata.olender@intel.com> | 2020-02-20 13:51:20 +0300 |
commit | 4396a404eaee7e13e01cfbf5467a1d5831c72809 (patch) | |
tree | d4403b4ac905e5ca95eccd7893faed2e9d021f20 | |
parent | d5381e11641afad62c5b310fa0a7e3accba7ced8 (diff) | |
download | virtual-media-4396a404eaee7e13e01cfbf5467a1d5831c72809.tar.xz |
Add handling of exit code property.
Property returns exit code value from nbd-client process for
proxy mode and from nbdkit process for legacy mode.
The initial value for this property is -1 and will be returned
before starting the process and in the process execution time.
Tested manually for proxy and legacy mode:
- initial value before process first run
- initial value in process execution time
- 0 value for successful exit
- specific value for forced process termination
Change-Id: I4cefa423bade522fc2fac0cab620cbba0b66cce2
Signed-off-by: Agata Olender <agata.olender@intel.com>
-rw-r--r-- | src/state_machine.hpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/state_machine.hpp b/src/state_machine.hpp index a788043..6711401 100644 --- a/src/state_machine.hpp +++ b/src/state_machine.hpp @@ -120,6 +120,9 @@ struct MountPointStateMachine virtual void onEnter() { + // Reset previous exit code + machine.exitCode = -1; + machine.emitActivationStartedEvent(); } }; @@ -337,11 +340,10 @@ struct MountPointStateMachine } }); processIface->register_property( - "ExitCode", uint8_t(0), - [](const uint8_t& req, uint8_t& property) { return 0; }, - [& machine = state.machine](const uint8_t& property) { - // TODO: indicate real value instead of success - return uint8_t(255); + "ExitCode", int32_t(0), + [](const int32_t& req, int32_t& property) { return 0; }, + [& machine = state.machine](const int32_t& property) { + return machine.exitCode; }); processIface->initialize(); } @@ -649,6 +651,7 @@ struct MountPointStateMachine Configuration::MountPoint::toArgs(state.machine.config), [& machine = state.machine](int exitCode, bool isReady) { LogMsg(Logger::Info, machine.name, " process ended."); + machine.exitCode = exitCode; machine.emitSubprocessStoppedEvent(); })) { @@ -799,6 +802,7 @@ struct MountPointStateMachine args, [& machine = machine, secret = std::move(secret)]( int exitCode, bool isReady) { LogMsg(Logger::Info, machine.name, " process ended."); + machine.exitCode = exitCode; machine.emitSubprocessStoppedEvent(); })) { @@ -1002,7 +1006,7 @@ struct MountPointStateMachine DeviceMonitor& devMonitor, const std::string& name, const Configuration::MountPoint& config) : ioc{ioc}, - name{name}, config{config}, state{InitialState(*this)} + name{name}, config{config}, state{InitialState(*this)}, exitCode{-1} { devMonitor.addDevice(config.nbdDevice); } @@ -1085,4 +1089,5 @@ struct MountPointStateMachine std::optional<Target> target; State state; + int exitCode; }; |