mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): saving a SPICE console's settings keeps it SPICE
The console type list offers VNC and Serial only, so the page of a SPICE VM showed VNC and any save, of the keymap alone, switched the console: libvirt refused the definition when the VM had a SPICE channel, and without one the VM silently got a new VNC console. A console type the panel does not create is now offered as it is, and kept on save. A switch from SPICE that is chosen removes the SPICE channels, USB redirection and smartcards libvirt refuses without SPICE graphics and mutes SPICE audio. A new VNC console keeps the keymap and a password VNC can take; a longer one is replaced by a generated password. The console settings were read from the first graphics device that had each attribute: with VNC and SPICE devices the page showed VNC's port with SPICE's password. All are read from the first device, the one the settings change.
This commit is contained in:
parent
cd3edf4dff
commit
7fe79463fc
8 changed files with 276 additions and 176 deletions
|
|
@ -55,6 +55,9 @@ class ConsoleForm(forms.Form):
|
|||
types = [("vnc", "VNC")]
|
||||
if settings.SERIAL_CONSOLE_ENABLED:
|
||||
types.append(("pty", _("Serial (xterm; the guest needs a getty on ttyS0)")))
|
||||
# a type the panel does not create (SPICE) is offered, so a save keeps it
|
||||
if instance.config_console_type not in (None, "pty", "vnc"):
|
||||
types.append((instance.config_console_type, instance.config_console_type.upper()))
|
||||
self.fields["console_type"].choices = types
|
||||
# the VNC settings are shown and saved while the console is VNC; a
|
||||
# switch to Serial ignores them
|
||||
|
|
@ -88,8 +91,11 @@ class ConsoleForm(forms.Form):
|
|||
if not password:
|
||||
self.add_error("password", _("Enter the new password."))
|
||||
# VNC takes 8 bytes, and the browser console sends only ASCII as typed
|
||||
elif len(password) > 8 or not all(" " <= c <= "~" for c in password):
|
||||
elif (data.get("console_type") or self.initial["console_type"]) == "vnc" and (
|
||||
len(password) > 8 or not all(" " <= c <= "~" for c in password)):
|
||||
self.add_error("password", _("A VNC password takes up to 8 letters, digits or symbols, without accents."))
|
||||
elif not password.isprintable(): # a SPICE password
|
||||
self.add_error("password", _("A password takes no line breaks or other control characters."))
|
||||
# A console that listens beyond localhost (set by an administrator)
|
||||
# keeps its password unless an administrator removes it.
|
||||
if action == "none" and not self.is_superuser and not self.instance.proxy.console_listens_locally():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue