summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvmd/apps/kvmd/api/msd.py1
-rw-r--r--kvmd/plugins/msd/__init__.py15
-rw-r--r--kvmd/plugins/msd/disabled.py9
-rw-r--r--kvmd/plugins/msd/otg/__init__.py13
-rw-r--r--kvmd/plugins/msd/relay/__init__.py12
5 files changed, 45 insertions, 5 deletions
diff --git a/kvmd/apps/kvmd/api/msd.py b/kvmd/apps/kvmd/api/msd.py
index 111aafab..7347bd8c 100644
--- a/kvmd/apps/kvmd/api/msd.py
+++ b/kvmd/apps/kvmd/api/msd.py
@@ -70,6 +70,7 @@ class MsdApi:
for (param, key, validator) in [
("image", "name", (lambda arg: str(arg).strip() and valid_msd_image_name(arg))),
("cdrom", "cdrom", valid_bool),
+ ("rw", "rw", valid_bool),
]
if request.query.get(param) is not None
}
diff --git a/kvmd/plugins/msd/__init__.py b/kvmd/plugins/msd/__init__.py
index 31095f3c..ac285f7b 100644
--- a/kvmd/plugins/msd/__init__.py
+++ b/kvmd/plugins/msd/__init__.py
@@ -93,7 +93,12 @@ class MsdMultiNotSupported(MsdOperationError):
class MsdCdromNotSupported(MsdOperationError):
def __init__(self) -> None:
- super().__init__("This MSD does not support CD-ROM emulation")
+ super().__init__("This MSD does not support CD-ROM switching")
+
+
+class MsdRwNotSupported(MsdOperationError):
+ def __init__(self) -> None:
+ super().__init__("This MSD does not support RW switching")
# =====
@@ -114,7 +119,13 @@ class BaseMsd(BasePlugin):
# =====
- async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
+ async def set_params(
+ self,
+ name: Optional[str]=None,
+ cdrom: Optional[bool]=None,
+ rw: Optional[bool]=None,
+ ) -> None:
+
raise NotImplementedError()
async def set_connected(self, connected: bool) -> None:
diff --git a/kvmd/plugins/msd/disabled.py b/kvmd/plugins/msd/disabled.py
index 0545b86b..13def45e 100644
--- a/kvmd/plugins/msd/disabled.py
+++ b/kvmd/plugins/msd/disabled.py
@@ -50,6 +50,7 @@ class Plugin(BaseMsd):
"features": {
"multi": False,
"cdrom": False,
+ "rw": False,
},
}
@@ -63,7 +64,13 @@ class Plugin(BaseMsd):
# =====
- async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
+ async def set_params(
+ self,
+ name: Optional[str]=None,
+ cdrom: Optional[bool]=None,
+ rw: Optional[bool]=None,
+ ) -> None:
+
raise MsdDisabledError()
async def set_connected(self, connected: bool) -> None:
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 409b899a..8aea3d34 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -56,6 +56,7 @@ from .. import MsdDisconnectedError
from .. import MsdImageNotSelected
from .. import MsdUnknownImageError
from .. import MsdImageExistsError
+from .. import MsdRwNotSupported
from .. import BaseMsd
from .. import MsdImageWriter
@@ -222,6 +223,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
"features": {
"multi": True,
"cdrom": True,
+ "rw": False,
},
}
@@ -254,8 +256,17 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
# =====
@aiotools.atomic
- async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
+ async def set_params(
+ self,
+ name: Optional[str]=None,
+ cdrom: Optional[bool]=None,
+ rw: Optional[bool]=None,
+ ) -> None:
+
async with self.__state.busy():
+ if rw is not None:
+ raise MsdRwNotSupported()
+
assert self.__state.storage
assert self.__state.vd
diff --git a/kvmd/plugins/msd/relay/__init__.py b/kvmd/plugins/msd/relay/__init__.py
index 3c17a1ff..125f5fb9 100644
--- a/kvmd/plugins/msd/relay/__init__.py
+++ b/kvmd/plugins/msd/relay/__init__.py
@@ -49,6 +49,7 @@ from .. import MsdConnectedError
from .. import MsdDisconnectedError
from .. import MsdMultiNotSupported
from .. import MsdCdromNotSupported
+from .. import MsdRwNotSupported
from .. import BaseMsd
from .. import MsdImageWriter
@@ -141,6 +142,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
"features": {
"multi": False,
"cdrom": False,
+ "rw": False,
},
}
@@ -178,12 +180,20 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
# =====
@aiotools.atomic
- async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
+ async def set_params(
+ self,
+ name: Optional[str]=None,
+ cdrom: Optional[bool]=None,
+ rw: Optional[bool]=None,
+ ) -> None:
+
async with self.__working():
if name is not None:
raise MsdMultiNotSupported()
if cdrom is not None:
raise MsdCdromNotSupported()
+ if rw is not None:
+ raise MsdRwNotSupported()
@aiotools.atomic
async def set_connected(self, connected: bool) -> None: