diff options
author | Karol Wachowski <karol.wachowski@intel.com> | 2020-07-10 15:37:52 +0300 |
---|---|---|
committer | Wachowski, Karol <karol.wachowski@intel.com> | 2020-07-21 09:37:23 +0300 |
commit | 2fc6f721d834534e750764d753b666768b66cfe5 (patch) | |
tree | 2180aa30911ca62485244b192eebe6ffc220a557 | |
parent | 0d65aa179dea3670b9fe46000abc705a1447ffe9 (diff) | |
download | virtual-media-2fc6f721d834534e750764d753b666768b66cfe5.tar.xz |
VirtualMedia add Mount/Unmount timeout handling
Added Timeout dbus property for block devices in VirtualMedia.
Added throwing EBUSY exception when Mount/Unmount operation times out.
Added transition from ActivatingState to DeactivatingState.
Tested: Verified that after mounting non-existing HTTPS resource
in proxy mode, VirtualMedia recovers restoring ready state
and throws EBUSY during that transition.
Verfied that resources can be mounter/unmounted in both legacy
and proxy mode.
Change-Id: I3768af13663046cc55976ad59062f8bc1d6396ba
Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
-rw-r--r-- | src/state/activating_state.cpp | 17 | ||||
-rw-r--r-- | src/state/initial_state.hpp | 9 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/state/activating_state.cpp b/src/state/activating_state.cpp index 3f852c7..bc9a30b 100644 --- a/src/state/activating_state.cpp +++ b/src/state/activating_state.cpp @@ -39,21 +39,12 @@ std::unique_ptr<BasicState> if (event.devState == StateChange::inserted) { gadget = std::make_unique<resource::Gadget>(machine, event.devState); - - if (gadget) - { - return std::make_unique<ActiveState>(machine, std::move(process), - std::move(gadget)); - } - - return std::make_unique<ReadyState>(machine, - std::errc::device_or_resource_busy, - "Unable to configure gadget"); + return std::make_unique<ActiveState>(machine, std::move(process), + std::move(gadget)); } - return std::make_unique<ReadyState>( - machine, std::errc::operation_not_supported, - "Unexpected udev event: " + static_cast<int>(event.devState)); + return std::make_unique<DeactivatingState>(machine, std::move(process), + std::move(gadget), event); } std::unique_ptr<BasicState> diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp index f624d7e..fecf2b6 100644 --- a/src/state/initial_state.hpp +++ b/src/state/initial_state.hpp @@ -91,6 +91,9 @@ struct InitialState : public BasicStateT<InitialState> iface->register_property("EndpointId", machine.getConfig().endPointId); iface->register_property("Socket", machine.getConfig().unixSocket); iface->register_property( + "Timeout", machine.getConfig().timeout.value_or( + Configuration::MountPoint::defaultTimeout)); + iface->register_property( "RemainingInactivityTimeout", 0, [](const int& req, int& property) { throw sdbusplus::exception::SdBusError( @@ -101,7 +104,6 @@ struct InitialState : public BasicStateT<InitialState> [& config = machine.getConfig()](const int& property) -> int { return config.remainingInactivityTimeout.count(); }); - iface->initialize(); } @@ -132,6 +134,7 @@ struct InitialState : public BasicStateT<InitialState> timerPeriod](boost::asio::yield_context yield) { LogMsg(Logger::Info, "[App]: Unmount called on ", machine.getName()); + try { machine.emitUnmountEvent(); @@ -159,6 +162,8 @@ struct InitialState : public BasicStateT<InitialState> } LogMsg(Logger::Error, "[App] timedout when waiting for ReadyState"); + throw sdbusplus::exception::SdBusError(EBUSY, + "Resource is busy"); return false; }); @@ -208,6 +213,8 @@ struct InitialState : public BasicStateT<InitialState> } LogMsg(Logger::Error, "[App] timedout when waiting for ActiveState"); + throw sdbusplus::exception::SdBusError(EBUSY, + "Resource is busy"); return false; }; |