summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>2020-04-03 14:20:58 +0300
committerAdrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>2020-04-03 16:00:04 +0300
commitbe44219f15d0dee68edb5fd9370f8bb76c71c71d (patch)
treee2fa277bb1dfeaa33b4657edd40409be2159ddb4
parent12dd8d9623726c6272f88b56a7dccf76e1304514 (diff)
downloadvirtual-media-be44219f15d0dee68edb5fd9370f8bb76c71c71d.tar.xz
Make 'Legacy mode' (mounting through HTTPS or SMB) configurable at compile time.
This change modifies the default configuration and removes ability to configure endpoints in such mode. Tests performed: Tested on WilsonCity for regression. Proxy mode works. Manual configuration injection (modifying virtual-media.json) didn't enable Legacy endpoints - they are ignored. Change-Id: Idb63f1cf0f391dc428d6ad3d8e3684017d509369 Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
-rw-r--r--CMakeLists.txt5
-rw-r--r--src/configuration.hpp2
-rw-r--r--src/state_machine.hpp9
-rw-r--r--virtual-media.json18
4 files changed, 17 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9fd7bd..d5e59f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,9 @@ option(VM_USE_VALGRIND "Build VirtualMedia to work with valgrind" OFF)
option(VM_VERBOSE_NBDKIT_LOGS "Include detailed logs from nbdkit" OFF)
+option(LEGACY_MODE_ENABLED
+ "Enable 'legacy mode' - mounting remote shares using nbdkit" OFF)
+
if(NOT ${YOCTO_DEPENDENCIES})
include(ExternalProject)
@@ -137,6 +140,8 @@ target_compile_definitions(virtual-media
-DBOOST_USE_VALGRIND>
$<$<BOOL:${VM_VERBOSE_NBDKIT_LOGS}>:
-DVM_VERBOSE_NBDKIT_LOGS>
+ $<$<BOOL:${LEGACY_MODE_ENABLED}>:
+ -DLEGACY_MODE_ENABLED>
$<$<BOOL:${CUSTOM_DBUS_PATH}>:
-DCUSTOM_DBUS_PATH="${CUSTOM_DBUS_PATH}">)
diff --git a/src/configuration.hpp b/src/configuration.hpp
index 89c9d02..99dbec1 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -209,10 +209,12 @@ class Configuration
{
mp.mode = Configuration::Mode::proxy;
}
+#if LEGACY_MODE_ENABLED
else if (*value == 1)
{
mp.mode = Configuration::Mode::legacy;
}
+#endif
else
{
LogMsg(Logger::Error,
diff --git a/src/state_machine.hpp b/src/state_machine.hpp
index 388b79a..c0f331f 100644
--- a/src/state_machine.hpp
+++ b/src/state_machine.hpp
@@ -282,6 +282,15 @@ struct MountPointStateMachine
{
const bool isLegacy =
(state.machine.config.mode == Configuration::Mode::legacy);
+
+#if !LEGACY_MODE_ENABLED
+ if (isLegacy)
+ {
+ return ReadyState(state, std::errc::invalid_argument,
+ "Legacy mode is not supported");
+ }
+#endif
+
addMountPointInterface(state);
addProcessInterface(state);
addServiceInterface(state, isLegacy);
diff --git a/virtual-media.json b/virtual-media.json
index 3b63df3..d3bfc51 100644
--- a/virtual-media.json
+++ b/virtual-media.json
@@ -16,22 +16,6 @@
"UnixSocket": "/tmp/nbd1.sock",
"Timeout": 30,
"BlockSize": 512
- },
- "USB1": {
- "EndpointId": "",
- "Mode": 1,
- "NBDDevice": "nbd2",
- "UnixSocket": "/tmp/nbd2.sock",
- "Timeout": 30,
- "BlockSize": 512
- },
- "USB2": {
- "EndpointId": "",
- "Mode": 1,
- "NBDDevice": "nbd3",
- "UnixSocket": "/tmp/nbd3.sock",
- "Timeout": 30,
- "BlockSize": 512
}
}
-}
+} \ No newline at end of file