summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Orzel <michalx.orzel@intel.com>2022-02-07 18:13:02 +0300
committerGitHub <noreply@github.com>2022-02-07 18:13:02 +0300
commit6df74a76eeacc5240d36fa7e62717cd1cdd238a7 (patch)
tree368ee833f27129104f415b4a90441aa7bc40bbca
parent8542fa62c13306e8e8cc623183f105a868a36b6c (diff)
downloadvirtual-media-6df74a76eeacc5240d36fa7e62717cd1cdd238a7.tar.xz
Force udev change event on init (#6)
* Force udev change event on init This change provides temporary workaround for HSD HSD18020136609 ("Can not mount image using Virtual media and CIFS protocol"). When in initial state, additional udev change event is triggered for all NBD devices, which prevents from disconnection on first mount attempt after reboot. The actual issue is a regression, introduced after kernel update from 5.10.67 to 5.14.11. The exact source in kernel is yet to be located; after that an actual fix shall be provided and this change will be reverted. Abstracts echoToFile to a separate class, that may be used by other classes through inheritance. This way, writing to udev files can be handled by different object than UsbGadget. Tested: Successful mounts after reboot for all supported methods (Proxy, Legacy HTTPS, Legacy CIFS). Change-Id: I2ceb826c73b6e46938397060877d35a9fa1c0e03 Signed-off-by: MichalX Orzel <michalx.orzel@intel.com>
-rw-r--r--src/state/initial_state.hpp3
-rw-r--r--src/system.hpp28
2 files changed, 29 insertions, 2 deletions
diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp
index 0529d9f..a1efeef 100644
--- a/src/state/initial_state.hpp
+++ b/src/state/initial_state.hpp
@@ -35,6 +35,9 @@ struct InitialState : public BasicStateT<InitialState>
addProcessInterface(event);
addServiceInterface(event, isLegacy);
+ // Workaround for HSD18020136609. Details in system.hpp.
+ UdevGadget::forceUdevChange();
+
return std::make_unique<ReadyState>(machine);
}
diff --git a/src/system.hpp b/src/system.hpp
index cd16802..22f9717 100644
--- a/src/system.hpp
+++ b/src/system.hpp
@@ -476,9 +476,9 @@ class Process : public std::enable_shared_from_this<Process>
const NBDDevice& dev;
};
-struct UsbGadget
+class FsHelper
{
- private:
+ protected:
static bool echoToFile(const fs::path& fname, const std::string& content)
{
std::ofstream fileWriter;
@@ -489,7 +489,11 @@ struct UsbGadget
LogMsg(Logger::Debug, "echo ", content, " > ", fname);
return true;
}
+};
+struct UsbGadget : private FsHelper
+{
+ private:
static const std::string getGadgetDirPrefix()
{
const std::string gadgetDirPrefix =
@@ -627,3 +631,23 @@ struct UsbGadget
return true;
}
};
+
+class UdevGadget : private FsHelper
+{
+ public:
+ // Workaround for HSD18020136609: Can not mount image using Virtual media
+ // and CIFS protocol
+ // This force-triggers udev change events for nbd[0-3] devices, which
+ // prevents from disconnection on first mount event after reboot. The actual
+ // rootcause is related with kernel changes that occured between 5.10.67 and
+ // 5.14.11. This lead will continue to be investigated in order to provide
+ // proper fix.
+ static void forceUdevChange()
+ {
+ std::string changeStr = "change";
+ echoToFile("/sys/block/nbd0/uevent", changeStr);
+ echoToFile("/sys/block/nbd1/uevent", changeStr);
+ echoToFile("/sys/block/nbd2/uevent", changeStr);
+ echoToFile("/sys/block/nbd3/uevent", changeStr);
+ }
+};