Skip to content

Conversation

@llogen
Copy link
Contributor

@llogen llogen commented Dec 8, 2025

The PiKVM module provides comprehensive control of a DUT via a PiKVM device. It offers power management through ATX control, keyboard input simulation, and virtual media mounting capabilities.

Power management commands: on, off, force-off, reset, force-reset,
and status. Keyboard control commands: type, key, combo, and paste.
Virtual media commands: mount, mount-url, unmount, and media-status.

The module connects to a PiKVM device using HTTP/HTTPS with configurable host, user, password, and timeout. It supports both short and long ATX button presses for power and reset control, allows sending keyboard input and key combinations, and enables mounting ISO images from local files or URLs.

resolves #246

@llogen llogen force-pushed the feat/addPiKVModule branch 2 times, most recently from 9dbc7d7 to ad77246 Compare December 8, 2025 10:22
Copy link
Contributor

@RiSKeD RiSKeD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes, looks pretty clean overall. Just some thoughts:

  • Maybe separate the power,virtual-media,keyboard functionalities into separate files for better readability
  • 'combo' -> key-combo

Tell me what you think 😄

@llogen llogen force-pushed the feat/addPiKVModule branch from ad77246 to ae564e7 Compare December 17, 2025 10:27
@llogen
Copy link
Contributor Author

llogen commented Dec 17, 2025

Nice changes, looks pretty clean overall. Just some thoughts:

  • Maybe separate the power,virtual-media,keyboard functionalities into separate files for better readability
  • 'combo' -> key-combo

Tell me what you think 😄

I think thats a good idea :)

@llogen llogen force-pushed the feat/addPiKVModule branch from ae564e7 to 4e04fe1 Compare December 17, 2025 12:26
@llogen llogen force-pushed the feat/addPiKVModule branch 4 times, most recently from 2183a74 to 9454670 Compare January 6, 2026 14:55
Copy link
Member

@jenstopp jenstopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, full KVM feature set implemented 🚀 :)

Comment on lines 231 to 233
func (p *PiKVM) doRequest(ctx context.Context, method, urlPath string, body io.Reader, contentType string) (*http.Response, error) {
return p.doRequestWithOptions(ctx, method, urlPath, body, contentType, requestOptions{})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for testing purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the purpose of not having 3 different methods and combine them within one with the requestOptions input

Comment on lines 301 to 273
func (p *PiKVM) buildRequestURL(urlPath string) (string, error) {
targetURL := *p.baseURL

parsedPath, err := url.Parse(urlPath)
if err != nil {
return "", fmt.Errorf("invalid URL path: %v", err)
}

targetURL.Path = path.Join(targetURL.Path, parsedPath.Path)
targetURL.RawQuery = parsedPath.RawQuery

return targetURL.String(), nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this done during init?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you change anything?

The PiKVM module provides comprehensive control of a DUT via a
PiKVM device. It offers power management through ATX control,
keyboard input simulation, and virtual media mounting capabilities.

Power management commands: on, off, force-off, reset, force-reset,
and status. Keyboard control commands: type, key, combo, and paste.
Virtual media commands: mount, mount-url, unmount, and media-status.

The module connects to a PiKVM device using HTTP/HTTPS with
configurable host, user, password, and timeout. It supports both
short and long ATX button presses for power and reset control,
allows sending keyboard input and key combinations, and enables
mounting ISO images from local files or URLs.

Signed-off-by: llogen <christoph.lange@blindspot.software>
Signed-off-by: llogen <christoph.lange@blindspot.software>
Add support for streaming file transfers in 1MB chunks to avoid
loading large disk images entirely into memory. This fixes OOM issues
and connection timeouts when transferring multi-gigabyte files.

Changes:
- Add FileChunk message to protobuf for streaming file transfers
- Implement sendFileInChunks() in client to stream files in 1MB chunks
- Implement receiveFileChunk() in client for incoming chunked files
- Update agent session to write chunks directly to temp files
- Update agent worker to stream files to client in chunks
- Remove verbose logging from ChanReader to reduce noise

The chunked approach reduces memory usage from ~5GB+ for a 5GB file
transfer down to ~1-2MB (only the current chunk in memory).

Backward compatible: old File message still supported for small files.
Avoid unnecessary file transfers by calculating SHA256 hash on the
client side and checking PiKVM storage before transferring files.

Workflow optimization:
- Client calculates file hash locally (automated in dutctl)
- Agent checks if image already exists on PiKVM by hash
- If exists: mount directly without transfer (saves minutes)
- If missing: request file from client and upload

This significantly improves the user experience when mounting the same
disk image multiple times, reducing the operation from ~2-3 minutes
(full transfer) to ~2 seconds (hash check only).

Example:
  ./dutctl -s server:1024 device media mount ~/image.img

First mount: Calculates hash, transfers 3.5GB, uploads to PiKVM
Second mount: Calculates hash, finds on PiKVM, mounts immediately

Changes:
- Add preprocessArgs() to dutctl for automatic hash calculation
- Update PiKVM handleMount() to accept precomputed hash and size
- Check PiKVM storage before requesting file from client
- Backward compatible: works without hash (calculates server-side)
Signed-off-by: llogen <christoph.lange@blindspot.software>
@llogen llogen force-pushed the feat/addPiKVModule branch from ec724a1 to 4be888f Compare January 15, 2026 13:05
@jenstopp
Copy link
Member

Please put the changes to the file transfer out of this PR (maybe in a separate one). These are serious changes to the core code and need more detailed review and testing.

@jenstopp
Copy link
Member

Please put the changes to the file transfer out of this PR (maybe in a separate one). These are serious changes to the core code and need more detailed review and testing.

@llogen ? I saw the separate PR for the reworked file transfer, but what about getting this parts out of here, so we can get this PR merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PiKVM Module Proposal

4 participants