Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consoles: Allow configuring VNC #1973

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Jan 14, 2025

Demo: https://youtu.be/cSMRsOmSEhE

Via the "Consoles" card, when the machine is off.

This is the minimum to get #1795 finished, IMO, and we should not try to do more. Anything on top happens in #1972 and elsewhere, at its own pace.

  • tests, coverage

@mvollmer
Copy link
Member Author

mvollmer commented Jan 14, 2025

There is more work to be done here, of course:

  • Optional password reveal in the dialogs.
  • Explicit option to select "auto" for the port instead of having to input -1.
  • Input validation in the dialogs, e.g. check if address is valid, check if port is in the required range
  • Wording change, I think it should be "Listening address" instead of "VNC address", etc, since we are configuring the server, not the client.
  • tests, coverage

@garrett
Copy link
Member

garrett commented Jan 15, 2025

Can you add a screenshot of the current status please? Thanks!

@mvollmer
Copy link
Member Author

mvollmer commented Jan 15, 2025

Can you add a screenshot of the current status please? Thanks!

Yes! Thanks for having a look @garrett!

A runing virtual machine looks and behaves exactly like before. The console card of a not running machine has details about VNC.

Machine without VNC:

image

Machine with default VNC:

image

Machine with custom VNC:

image

Dialog for editing the VNC config:

image

Dialog for adding VNC:

image

(None of the above is meant to be final, of course.)

@garrett
Copy link
Member

garrett commented Jan 15, 2025

Thanks for adding the screenshots! I like what I'm seeing so far.

(None of the above is meant to be final, of course.)

It looks like a great start though, and I think it can be banged into resembling the mockups for this. Thanks again for picking up the work on Machines!

@mvollmer
Copy link
Member Author

I think it can be banged into resembling the mockups for this.

I think I didn't see any mockups of a stopped machine, hmm. Is this mockup also meant for stopped machines?

image

@mvollmer mvollmer force-pushed the console-vnc-edit branch 2 times, most recently from f5583f6 to 78c6280 Compare January 16, 2025 15:07
@mvollmer
Copy link
Member Author

A runing virtual machine looks and behaves exactly like before.

Sorry, that isn't true. A running machine without VNC now allows the selection of the VNC tab, which will look like this:

image

@mvollmer
Copy link
Member Author

I have changed the information display a bit. It deemphasizes the "VNC" term and the listening address.

No VNC:

image

VNC with auto port:

image

VNC with custom port:

image

In the selector, "VNC console" is changed to "Graphical console (VNC)".

image

The idea is that Cockpit talks about support for a graphical console inside Cockpit. That happens to be implemented via VNC, but that's a detail. And the per-VM listening address is not that interesting. People will very likely leave it at its default, and are better off changing the global default in qemu.conf in any case. The port on the other hand is interesting. VMs might fail to start if they use the same port by accident, and it is a genuine per-VM config setting.

@mvollmer
Copy link
Member Author

I have polished the dialogs some. They look like this now when everything is at default:

image

With a bogus port:

image

With a number but out of range:

image

So that people can edit them or add VNC if it is missing.
- The dialogs talk about "server" and "listening" to make that
  clearer.

- There are now placeholder texts to explain the defaults

- We use the empty string instead "-1" to signify automatic port
  assignment in the UI.

- The port does validation of its value.

- The password field takes the whole row and has can reveal its value.
If the inactive XML config contains a port but not a address, we would
try to connect too early, before the address was actually filled in.
Comment on lines +46 to +49
function add_vnc() {
Dialogs.show(<AddVNC
idPrefix="add-vnc"
vm={vm} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

These 4 added lines are not executed by any test.

Comment on lines +52 to +58
function edit_vnc() {
Dialogs.show(<EditVNCModal
idPrefix="edit-vnc"
consoleDetail={vnc}
vmName={vm.name}
vmId={vm.id}
connectionName={vm.connectionName} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

These 7 added lines are not executed by any test.

Comment on lines +121 to +129
if (!consoleDetail) {
return (
<div className="pf-v5-c-console__vnc">
<EmptyState>
<EmptyStateBody>
{_("Graphical console not supported. Shut down the virtual machine to add support.")}
</EmptyStateBody>
</EmptyState>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

These 9 added lines are not executed by any test.

Comment on lines +34 to +35
constructor(props) {
super(props);
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 added lines are not executed by any test.

Comment on lines +37 to +43
this.state = {
dialogError: undefined,
vncAddress: "",
vncPort: "",
vncPassword: "",
addVncInProgress: false,
validationErrors: { },
Copy link
Contributor

Choose a reason for hiding this comment

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

These 7 added lines are not executed by any test.

if (connectionName === "system")
options.superuser = "try";

return cockpit.spawn(args, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

Comment on lines +1103 to +1108
export function domainChangeVncSettings({
connectionName,
vmName,
vncAddress,
vncPort,
vncPassword,
Copy link
Contributor

Choose a reason for hiding this comment

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

These 6 added lines are not executed by any test.

Comment on lines +1110 to +1112
const options = { err: "message" };
if (connectionName === "system")
options.superuser = "try";
Copy link
Contributor

Choose a reason for hiding this comment

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

These 3 added lines are not executed by any test.

if (connectionName === "system")
options.superuser = "try";

const args = ["virt-xml", "-c", `qemu:///${connectionName}`, vmName, "--edit", "--graphics", `vnc,listen=${vncAddress},port=${vncPort},passwd=${vncPassword}`];
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.


const args = ["virt-xml", "-c", `qemu:///${connectionName}`, vmName, "--edit", "--graphics", `vnc,listen=${vncAddress},port=${vncPort},passwd=${vncPassword}`];

return cockpit.spawn(args, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

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.

4 participants