summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2025-01-24 05:24:40 +0200
committerMaxim Devaev <[email protected]>2025-01-24 05:24:40 +0200
commit2acd613a38556c5796c5d873320865d8f0f56c7a (patch)
tree1fddcc91409606caffa8c36fa6b1b9df81b24f6a
parent0202a3c2d1cafef32123f9d198c279dd26553731 (diff)
dvd support
-rw-r--r--PKGBUILD2
-rw-r--r--kvmd/apps/__init__.py24
-rw-r--r--kvmd/apps/otg/__init__.py32
-rw-r--r--kvmd/apps/otgmsd/__init__.py4
-rw-r--r--kvmd/usb.py8
-rw-r--r--web/kvm/index.html8
-rw-r--r--web/kvm/navbar-msd.pug8
-rw-r--r--web/share/js/kvm/msd.js2
8 files changed, 73 insertions, 15 deletions
diff --git a/PKGBUILD b/PKGBUILD
index bf01120f..9dbe9d3b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -210,7 +210,7 @@ for _variant in "${_variants[@]}"; do
cd \"kvmd-\$pkgver\"
pkgdesc=\"PiKVM platform configs - $_platform for $_board\"
- depends=(kvmd=$pkgver-$pkgrel \"linux-rpi-pikvm>=6.6.45-1\" \"raspberrypi-bootloader-pikvm>=20240818-1\")
+ depends=(kvmd=$pkgver-$pkgrel \"linux-rpi-pikvm>=6.6.45-10\" \"raspberrypi-bootloader-pikvm>=20240818-1\")
backup=(
etc/sysctl.d/99-kvmd.conf
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index 5ad38d90..7c587c3f 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -595,6 +595,18 @@ def _get_config_scheme() -> dict:
"rw": Option(False, type=valid_bool),
"removable": Option(True, type=valid_bool),
"fua": Option(True, type=valid_bool),
+ "inquiry_string": {
+ "cdrom": {
+ "vendor": Option("PiKVM", type=valid_stripped_string),
+ "product": Option("Optical Drive", type=valid_stripped_string),
+ "revision": Option("1.00", type=valid_stripped_string),
+ },
+ "flash": {
+ "vendor": Option("PiKVM", type=valid_stripped_string),
+ "product": Option("Flash Drive", type=valid_stripped_string),
+ "revision": Option("1.00", type=valid_stripped_string),
+ },
+ },
},
},
@@ -626,6 +638,18 @@ def _get_config_scheme() -> dict:
"rw": Option(True, type=valid_bool),
"removable": Option(True, type=valid_bool),
"fua": Option(True, type=valid_bool),
+ "inquiry_string": {
+ "cdrom": {
+ "vendor": Option("PiKVM", type=valid_stripped_string),
+ "product": Option("Optical Drive", type=valid_stripped_string),
+ "revision": Option("1.00", type=valid_stripped_string),
+ },
+ "flash": {
+ "vendor": Option("PiKVM", type=valid_stripped_string),
+ "product": Option("Flash Drive", type=valid_stripped_string),
+ "revision": Option("1.00", type=valid_stripped_string),
+ },
+ },
},
},
},
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index e1e886cb..076fe6b8 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -186,7 +186,19 @@ class _GadgetConfig:
self.__create_meta(func, desc, eps)
self.__hid_instance += 1
- def add_msd(self, start: bool, user: str, stall: bool, cdrom: bool, rw: bool, removable: bool, fua: bool) -> None:
+ def add_msd(
+ self,
+ start: bool,
+ user: str,
+ stall: bool,
+ cdrom: bool,
+ rw: bool,
+ removable: bool,
+ fua: bool,
+ inquiry_string_cdrom: str,
+ inquiry_string_flash: str,
+ ) -> None:
+
# Endpoints number depends on transport_type but we can consider that this is 2
# because transport_type is always USB_PR_BULK by default if CONFIG_USB_FILE_STORAGE_TEST
# is not defined. See drivers/usb/gadget/function/storage_common.c
@@ -198,6 +210,8 @@ class _GadgetConfig:
_write(join(func_path, "lun.0/ro"), int(not rw))
_write(join(func_path, "lun.0/removable"), int(removable))
_write(join(func_path, "lun.0/nofua"), int(not fua))
+ _write(join(func_path, "lun.0/inquiry_string_cdrom"), inquiry_string_cdrom)
+ _write(join(func_path, "lun.0/inquiry_string"), inquiry_string_flash)
if user != "root":
_chown(join(func_path, "lun.0/cdrom"), user)
_chown(join(func_path, "lun.0/ro"), user)
@@ -293,11 +307,23 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements,
if config.kvmd.msd.type == "otg":
logger.info("===== MSD =====")
- gc.add_msd(cod.msd.start, config.otg.user, **cod.msd.default._unpack())
+ gc.add_msd(
+ start=cod.msd.start,
+ user=config.otg.user,
+ inquiry_string_cdrom=usb.make_inquiry_string(**cod.msd.default.inquiry_string.cdrom._unpack()),
+ inquiry_string_flash=usb.make_inquiry_string(**cod.msd.default.inquiry_string.flash._unpack()),
+ **cod.msd.default._unpack(ignore="inquiry_string"),
+ )
if cod.drives.enabled:
for count in range(cod.drives.count):
logger.info("===== MSD Extra: %d =====", count + 1)
- gc.add_msd(cod.drives.start, "root", **cod.drives.default._unpack())
+ gc.add_msd(
+ start=cod.drives.start,
+ user="root",
+ inquiry_string_cdrom=usb.make_inquiry_string(**cod.drives.default.inquiry_string.cdrom._unpack()),
+ inquiry_string_flash=usb.make_inquiry_string(**cod.drives.default.inquiry_string.flash._unpack()),
+ **cod.drives.default._unpack(ignore="inquiry_string"),
+ )
if cod.ethernet.enabled:
logger.info("===== Ethernet =====")
diff --git a/kvmd/apps/otgmsd/__init__.py b/kvmd/apps/otgmsd/__init__.py
index a289307f..3aab3127 100644
--- a/kvmd/apps/otgmsd/__init__.py
+++ b/kvmd/apps/otgmsd/__init__.py
@@ -68,7 +68,7 @@ def main(argv: (list[str] | None)=None) -> None:
parser.add_argument("-i", "--instance", default=0, type=valid_int_f0,
metavar="<N>", help="Drive instance (0 for KVMD drive)")
parser.add_argument("--set-cdrom", default=None, type=valid_bool,
- metavar="<1|0|yes|no>", help="Set CD-ROM flag")
+ metavar="<1|0|yes|no>", help="Set CD/DVD flag")
parser.add_argument("--set-rw", default=None, type=valid_bool,
metavar="<1|0|yes|no>", help="Set RW flag")
parser.add_argument("--set-image", default=None, type=valid_abs_path,
@@ -101,5 +101,5 @@ def main(argv: (list[str] | None)=None) -> None:
set_param("file", options.set_image)
print("Image file: ", (get_param("file") or "<none>"))
- print("CD-ROM flag:", ("yes" if int(get_param("cdrom")) else "no"))
+ print("CD/DVD flag:", ("yes" if int(get_param("cdrom")) else "no"))
print("RW flag: ", ("no" if int(get_param("ro")) else "yes"))
diff --git a/kvmd/usb.py b/kvmd/usb.py
index 54309c2c..34646c3f 100644
--- a/kvmd/usb.py
+++ b/kvmd/usb.py
@@ -55,3 +55,11 @@ G_PROFILE = f"configs/{G_PROFILE_NAME}"
def get_gadget_path(gadget: str, *parts: str) -> str:
return os.path.join(f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", gadget, *parts)
+
+
+# =====
+def make_inquiry_string(vendor: str, product: str, revision: str) -> str:
+ # Vendor: 8 ASCII chars
+ # Product: 16
+ # Revision: 4
+ return "%-8.8s%-16.16s%-4.4s" % (vendor, product, revision)
diff --git a/web/kvm/index.html b/web/kvm/index.html
index 9427e3f8..da762585 100644
--- a/web/kvm/index.html
+++ b/web/kvm/index.html
@@ -525,15 +525,15 @@
</div>
<hr>
</div>
- <div class="hidden" id="msd-message-too-big-for-cdrom">
+ <div class="hidden" id="msd-message-too-big-for-dvd">
<div class="text">
<table>
<tr>
<td rowspan="2"><img class="sign " src="/share/svg/warning.svg"></td>
- <td style="line-height:1.5"><b>Current image is too big for CD-ROM!</b></td>
+ <td style="line-height:1.5"><b>Current image is too big for DVD!</b></td>
</tr>
<tr>
- <td><sup style="line-height:1">The device filesystem will be truncated to 2.2GiB</sup></td>
+ <td><sup style="line-height:1">The maximum is 31.6GiB. Please switch to the Flash mode.</sup></td>
</tr>
</table>
</div>
@@ -603,7 +603,7 @@
<td>
<div class="radio-box">
<input checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1">
- <label for="msd-mode-radio-cdrom">CD-ROM</label>
+ <label for="msd-mode-radio-cdrom">CD/DVD</label>
<input type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0">
<label for="msd-mode-radio-flash">Flash</label>
</div>
diff --git a/web/kvm/navbar-msd.pug b/web/kvm/navbar-msd.pug
index 6f5110fa..6ca4323e 100644
--- a/web/kvm/navbar-msd.pug
+++ b/web/kvm/navbar-msd.pug
@@ -15,9 +15,9 @@ li(id="msd-dropdown" class="right feature-disabled")
+menu_message("warning", "Current image is broken!")
| Perhaps uploading was interrupted#[br]
hr
- div(id="msd-message-too-big-for-cdrom" class="hidden")
- +menu_message("warning", "Current image is too big for CD-ROM!")
- | The device filesystem will be truncated to 2.2GiB
+ div(id="msd-message-too-big-for-dvd" class="hidden")
+ +menu_message("warning", "Current image is too big for DVD!")
+ | The maximum is 31.6GiB. Please switch to the Flash mode.
hr
div(id="msd-message-out-of-storage" class="hidden")
+menu_message("warning", "Current image is out of storage")
@@ -45,7 +45,7 @@ li(id="msd-dropdown" class="right feature-disabled")
td
div(class="radio-box")
input(checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1")
- label(for="msd-mode-radio-cdrom") CD-ROM
+ label(for="msd-mode-radio-cdrom") CD/DVD
input(type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0")
label(for="msd-mode-radio-flash") Flash
td &nbsp;
diff --git a/web/share/js/kvm/msd.js b/web/share/js/kvm/msd.js
index c20bd70a..f0192745 100644
--- a/web/share/js/kvm/msd.js
+++ b/web/share/js/kvm/msd.js
@@ -120,7 +120,7 @@ export function Msd() {
tools.hidden.setVisible($("msd-message-offline"), (state && !state.online));
tools.hidden.setVisible($("msd-message-image-broken"), (o && d.image && !d.image.complete && !s.uploading));
- tools.hidden.setVisible($("msd-message-too-big-for-cdrom"), (o && d.cdrom && d.image && d.image.size >= 2359296000));
+ tools.hidden.setVisible($("msd-message-too-big-for-dvd"), (o && d.cdrom && d.image && d.image.size >= 33957083136));
tools.hidden.setVisible($("msd-message-out-of-storage"), (o && d.image && !d.image.in_storage));
tools.hidden.setVisible($("msd-message-rw-enabled"), (o && d.rw));
tools.hidden.setVisible($("msd-message-another-user-uploads"), (o && s.uploading && !__http));