Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
01267b8
vnc_worker: improve VNC server compatibility and performance
bitranox Apr 5, 2026
5bb7b2a
Merge branch 'microsoft:main' into vnc-novnc-compat
bitranox Apr 6, 2026
1f079e5
vnc_worker: fix rustfmt formatting
bitranox Apr 6, 2026
9f79ef7
vnc_worker: reject unsupported pixel formats instead of panicking
bitranox Apr 6, 2026
bae9522
vnc_worker: validate client-selected security type
bitranox Apr 6, 2026
9c514c6
vnc_worker: handle zlib compression errors instead of panicking
bitranox Apr 6, 2026
452f08d
vnc_worker: convert cursor pixels through negotiated pixel format
bitranox Apr 6, 2026
a67b239
vnc_worker: respect big_endian_flag in pixel format conversion
bitranox Apr 6, 2026
0151d3d
Merge branch 'microsoft:main' into vnc-novnc-compat
bitranox Apr 6, 2026
7871e02
vnc_worker: disconnect on resolution change without DesktopSize support
bitranox Apr 6, 2026
f589cb2
vnc_worker: validate pixel format shifts and true_color_flag
bitranox Apr 6, 2026
7213e79
Guide: update VNC documentation with new capabilities
bitranox Apr 6, 2026
bfa851a
vnc_worker: use div_ceil for mask stride calculation
bitranox Apr 6, 2026
c2fa3c2
vnc_worker: factor out duplicated connection setup into start_connection
bitranox Apr 6, 2026
0db65e4
vnc_worker: replace synthetic IO errors with proper error variants
bitranox Apr 6, 2026
d97c430
vnc_worker: replace zlib compression synthetic IO error with proper v…
bitranox Apr 7, 2026
c9389be
vnc_worker: add socket2 dependency for start_connection signature
bitranox Apr 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10108,6 +10108,7 @@ dependencies = [
name = "vnc"
version = "0.0.0"
dependencies = [
"flate2",
"futures",
"pal_async",
"socket2",
Expand Down
61 changes: 58 additions & 3 deletions workers/vnc_worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,64 @@ impl<T: Listener> Server<T> {
abort: abort_send,
};
}
State::Connected { task, .. } => {
let (view, input) = task.await;
self.state = State::Listening { view, input };
State::Connected { .. } => {
// Take ownership of the connected state so we can
// move abort_send into the new-connection branch.
let (mut task, abort, _old_addr) = if let State::Connected {
task,
abort,
remote_addr,
} =
std::mem::replace(&mut self.state, State::Invalid)
{
(task, abort, remote_addr)
} else {
unreachable!()
};

// Race: current connection vs new incoming connection.
futures::select! {
result = task.as_mut().fuse() => {
let (view, input) = result;
self.state = State::Listening { view, input };
}
accept = self.listener.accept().fuse() => {
let (new_socket, remote_addr) = accept?;
tracing::info!(address = ?remote_addr, "New VNC client, disconnecting previous");
// Abort the current connection and wait for resources.
abort.send(());
let (view, input) = task.await;
// Now set up the new connection.
let socket = PolledSocket::new(driver, new_socket.into())?;
let mut vncserver = vnc::Server::new("OpenVMM VM".into(), socket, view, input);
let mut timer = PolledTimer::new(driver);
let (abort_send, abort_recv) = mesh::oneshot();
let connection = Box::pin(async move {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A lot of this stuff is duplicated with the code that handles the initial connection. Can you factor this out?

Copy link
Copy Markdown
Author

@bitranox bitranox Apr 6, 2026

Choose a reason for hiding this comment

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

factored out in c2fa3c2. The connection setup (vnc::Server, timer, abort channel, async task) now lives in a single start_connection helper that both the initial-connect and reconnect paths call. Removes ~20 lines of duplication.

let updater = vncserver.updater();
let update_task = async {
loop {
timer.sleep(Duration::from_millis(30)).await;
updater.update();
}
};
let r = futures::select! {
r = vncserver.run().fuse() => r.context("VNC error"),
_ = abort_recv.fuse() => Err(anyhow!("VNC connection aborted")),
_ = update_task.fuse() => unreachable!(),
};
match r {
Ok(_) => tracing::info!("VNC client disconnected"),
Err(err) => tracing::error!(error = err.as_error(), "VNC client error"),
}
vncserver.done()
});
self.state = State::Connected {
remote_addr,
task: connection,
abort: abort_send,
};
}
}
}
State::Invalid => unreachable!(),
}
Expand Down
1 change: 1 addition & 0 deletions workers/vnc_worker/vnc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rust-version.workspace = true
[dependencies]
pal_async.workspace = true

flate2.workspace = true
futures.workspace = true
thiserror.workspace = true
zerocopy.workspace = true
Expand Down
Loading
Loading