Destroy console connections after an ERR reply
A client that never closed its end could keep rejected connections open
without counting against the pending limit.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Claude-Session: https://claude.ai/code/session_019GjJri3QtFN4DpaQhSo4ZE
Bound console tickets and session lifetime
Stop the listener once no tickets remain, even with unauthenticated
connections open, cap outstanding tickets, and end sessions after 8 hours.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Claude-Session: https://claude.ai/code/session_019GjJri3QtFN4DpaQhSo4ZE
Replace always-on console proxy with ticketed sessions
vmadm info <uuid> console now issues a single-use ticket instead of
reporting a permanent unauthenticated listener. Tickets and sessions are
revoked for all brands when a VM leaves running.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Claude-Session: https://claude.ai/code/session_019GjJri3QtFN4DpaQhSo4ZE
Add named constants and improve protocol validation
- Add CONSOLE_HANDSHAKE_TIMEOUT (5000ms) and CONSOLE_LOG_TRUNCATE_LEN (100)
named constants to replace magic numbers
- Use stricter protocol validation: data.toString().trim() === 'OK'
instead of indexOf('OK') === 0 for more robust handshake checking
The stricter validation prevents false positives if the response contains
"OK" as a substring of a different message.
Addresses PR review feedback from https://github.com/TritonDataCenter/smartos-live/pull/1159
Co-Authored-By: Claude Opus 4.5 <noreply at anthropic.com>
Fix resource leaks and add handshake timeout in console proxy
Critical fixes for console connection handler:
1. Replace deprecated net.Stream() with new net.Socket()
2. Add cleanup() function with idempotent guard to prevent double-cleanup
3. Add 5-second timeout for zone console handshake
4. Ensure socket.destroy() called on all error paths:
- Client close
- Console socket error
- Client error
- Handshake timeout
- Handshake failure
5. Rename 'console' variable to 'consoleSocket' to avoid shadowing global
6. Truncate handshake error messages to prevent log spam
These fixes prevent file descriptor leaks and hanging connections that
could exhaust system resources under error conditions.
[3 lines not shown]
Use zoneadmd console socket instead of /dev/zcons device
The correct console socket for zlogin -C is managed by zoneadmd at
/var/run/zones/<zonename>.console_sock, not the /dev/zcons device.
All brands now use unix sockets:
- KVM: /zones/<uuid>/root/tmp/vm.console (serial console)
- Others: /var/run/zones/<zonename>.console_sock (zoneadmd console)
This allows simple net.Stream() connection for all brands.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Fix console proxy to use fs streams for device files
Zone console devices (/dev/zcons/*/zoneconsole) are character devices,
not unix sockets. net.connect() fails with ENOTSOCK when trying to
connect to them.
Fix by using different connection methods based on brand:
- KVM: net.Stream().connect() for unix socket
- Others: fs.createReadStream/WriteStream for device file
This allows proper bidirectional data flow for zone console devices.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Spawn console proxy for all running VMs at startup
Fix issue where non-KVM/Bhyve VMs (Joyent, LX) were not getting console
proxies spawned at vmadmd startup. Previously only KVM/Bhyve called loadVM()
which spawned the console proxy.
Now all running VMs get console proxies regardless of brand.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Add console proxy support to vmadmd
Implement TCP proxy for console access across all VM brands:
- KVM: Proxy to unix socket at /tmp/vm.console (serial console)
- Bhyve/Joyent/LX: Proxy to zone console device at /dev/zcons/<zonename>/zoneconsole
Changes:
- Add CONSOLE object to track console proxy state
- Add spawnConsoleProxy() to create TCP listeners for console access
- Add clearConsoleProxy() and reloadConsoleProxy() for lifecycle management
- Add infoConsole() to return console connection details via vm.info()
- Add console proxy spawning alongside VNC/SPICE in VM lifecycle
- Add vm.info() support for joyent, joyent-minimal, and lx brands (console only)
Console proxies are automatically created when VMs start and cleaned up when VMs stop.
Connection details (host, port, type) are available via vm.info(['console']).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Use socat to proxy zone console devices
fs.createReadStream doesn't work properly with character devices like
/dev/zcons/*/zoneconsole. Use socat instead to handle the device I/O
properly.
For non-KVM brands, spawn socat process per connection to proxy between
TCP socket and zone console device with proper raw/echo settings.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Add console to runtime_info for all VM brands
Add 'console' to runtime_info feature list for all brands to enable
vmadm info queries for console connection details.
Changes:
- KVM: Add 'console' to existing runtime_info array
- Bhyve: Add 'console' to runtime_info array
- Joyent: Add runtime_info: ['console'] (new)
- Joyent-minimal: Add runtime_info: ['console'] (new)
- LX: Add runtime_info: ['console'] (new)
This allows vm.info(['console']) to work for all brands, which is
required by CNAPI console endpoint and vmadmd console proxy.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
Add zoneadmd console handshake for non-KVM brands
The zoneadmd console_sock requires a protocol handshake before data flows.
Send 'IDENT C 0\n' and wait for 'OK' response before proxying data.
This matches the zlogin -C handshake protocol.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply at anthropic.com>
OS-7351 VM.create should allow disk with image to be grown (doc fixup)
Reviewed by: Carlos Neira <cneira at edgecast.io>
Reviewed by: Toomas Soome <tsoome at edgecast.io>
Approved by: Toomas Soome <tsoome at edgecast.io>
OS-7351 VM.create should allow disk with image to be grown (doc fixup)
vmadm(8) has said since OS-1916 (791d5838, 2013) that disks.*.size is
"not allowed" when a disk includes image_uuid. OS-7351 (466f00ae,
"VM.create should allow disk with image to be grown") changed that in
2018 without updating the man page: vmadm accepts the size, and creates
the disk that size, as long as it is at least the size of the image.
OS-7351's tests show it, in src/vm/tests/test-bhyve-disk-resize.js
(at 54701331): 'boot disk is grown when size > image_size' (line 340)
and 'create fails when size < image_size' (line 361). The code, in
src/vm/node_modules/VM.js (at 54701331):
- Validation rejects a size only when it is smaller than the image's
(lines 1132-1136: `image.target.size < i.size` adds 'size' to
bad_values; added by OS-7351).
- createVolume() uses the payload's size when there is one and the
image's size only otherwise (lines 2418-2422; OS-7352 gave it this
shape).
[12 lines not shown]
This branch should build components from related branches on Jenkins too.
NOTE: THIS CHANGE AND ANY OTHERS IN Jenkinsfile SHOULD NOT GET PUSHED
INTO `master` WHEN IT IS READY FOR BEING ACTUALLY COMMITTED!
OS-8766 load_sdc_sysinfo forks cut and sed per line, adding ~850ms to every zone boot
The loop forked a subshell, cut and sed for each line of sysinfo
output, about 71 processes per call. The function runs from the zone
brand statechange hook, so every zone boot paid for it.
Measured on a compute node with an Intel Xeon Gold 6240:
load_sdc_sysinfo 842 ms -> 33 ms
statechange hook 1012 ms -> 161 ms
vmadm start to guest ready 2631 ms -> 1721 ms
Output verified identical under both bash and ksh93: 69 variables,
byte for byte.
load_sdc_bootparams and sdc_bootparams_keys below have the same
pattern and are left alone here; they were not on the path measured.
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>
Claude-Session: https://claude.ai/code/session_01XsuxyuVvHe6ro76LWLs8GP
Fix gcc14-debug release builds with a bit more space in /. (#1183)
Reviewed by: Toomas Soome <tsoome at edgecast.io>
Reviewed by: Nahum Shalman <nshalman at edgecast.io>
Approved by: Nahum Shalman <nshalman at edgecast.io>
OS-8766 load_sdc_sysinfo forks cut and sed per line, adding ~850ms to every zone boot
The loop forked a subshell, cut and sed for each line of sysinfo
output, about 71 processes per call. The function runs from the zone
brand statechange hook, so every zone boot paid for it.
Measured on a compute node with an Intel Xeon Gold 6240:
load_sdc_sysinfo 842 ms -> 33 ms
statechange hook 1012 ms -> 161 ms
vmadm start to guest ready 2631 ms -> 1721 ms
Output verified identical under both bash and ksh93: 69 variables,
byte for byte.
load_sdc_bootparams and sdc_bootparams_keys below have the same
pattern and are left alone here; they were not on the path measured.
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>
Claude-Session: https://claude.ai/code/session_012Kn8vg7nnv6i6kYcSaRHty
OS-8759 SmartOS installation needs to pull newer bootstrap tar
Reviewed by: Jonathan Perkin <jperkin at edgecast.io>
Reviewed by: Nahum Shalman <nshalman at edgecast.io>
Approved by: Nahum Shalman <nshalman at edgecast.io>
OS-8754 let Jenkinsfile skip stages in case of single-stage failure
Reviewed by: Toomas Soome <tsoome at edgecast.io>
Approved by: Toomas Soome <tsoome at edgecast.io>