From 2fc6f721d834534e750764d753b666768b66cfe5 Mon Sep 17 00:00:00 2001 From: Karol Wachowski Date: Fri, 10 Jul 2020 12:37:52 +0000 Subject: 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 --- src/state/activating_state.cpp | 17 ++++------------- 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 if (event.devState == StateChange::inserted) { gadget = std::make_unique(machine, event.devState); - - if (gadget) - { - return std::make_unique(machine, std::move(process), - std::move(gadget)); - } - - return std::make_unique(machine, - std::errc::device_or_resource_busy, - "Unable to configure gadget"); + return std::make_unique(machine, std::move(process), + std::move(gadget)); } - return std::make_unique( - machine, std::errc::operation_not_supported, - "Unexpected udev event: " + static_cast(event.devState)); + return std::make_unique(machine, std::move(process), + std::move(gadget), event); } std::unique_ptr 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 @@ -90,6 +90,9 @@ struct InitialState : public BasicStateT machine.getConfig().nbdDevice.to_string()); 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) { @@ -101,7 +104,6 @@ struct InitialState : public BasicStateT [& config = machine.getConfig()](const int& property) -> int { return config.remainingInactivityTimeout.count(); }); - iface->initialize(); } @@ -132,6 +134,7 @@ struct InitialState : public BasicStateT 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 } 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 } LogMsg(Logger::Error, "[App] timedout when waiting for ActiveState"); + throw sdbusplus::exception::SdBusError(EBUSY, + "Resource is busy"); return false; }; -- cgit v1.2.3