FFFF
Skip to content

incus/console: Add default console command in configuration file#2367

Merged
stgraber merged 1 commit intolxc:mainfrom
MaheshPunjabi:i2054-add-support-for-default-console-for-vms
Aug 10, 2025
Merged

incus/console: Add default console command in configuration file#2367
stgraber merged 1 commit intolxc:mainfrom
MaheshPunjabi:i2054-add-support-for-default-console-for-vms

Conversation

@MaheshPunjabi
Copy link
Copy Markdown
Contributor
@MaheshPunjabi MaheshPunjabi commented Aug 10, 2025

Ask
#2054: Ability to add arguments for VM console without a workaround on the OS. for ex: incus console instance --type=vga will launch spicy or remote-viewer.

What was changed?
After discussion in #2054 :

  1. Add the 2 vars in shared/cliconfig/default.go under DefaultSettings struct:
ConsolePreferVga bool  `yaml:"console_prefer_vga"`
ConsoleVgaCommand string `yaml:"console_vga_command"` // takes a string where the SOCKET keyword is replaced with the path to the SPICE socket
  1. Add a methods defaultConsoleType() and defaultConsoleVgaCommand() in cmd/incus/main.go to return the "vga" if the user configured console_prefer_vga, otherwise return "console"

  2. for flag, replace console with call to defaultConsoleType() in cmd/incus/console.go

  3. update logic in vga() method to call defaultConsoleVgaCommand() and apply returned string after replacing SOCKET keyword

Tests Done

  • build complete fine
  • Apply incus on test system and confirmed that new rule was put in place

Note to self:
Basic setup:

  • Setup windows VM
  • Setup a separate windows server
    • install incus client and install remote-viewer for Windows.
    • add user to incus-admin on server
    • start a VM console: incus console vm_name --type vga
    • Verify local socket: tasklist | findstr remote-viewer
    • verify console works

Manual test procedure:

  • edit your config.yml
    • in ~/.config/incus)
    • add section:
      defaults:
      console_prefer_vga: true
      console_vga_command: /usr/bin/remote-viewer -t i2054 SOCKET
  • apply incus cmd
  • Start console again: incus console vm_name
  • Validate title is set

Ref: https://discuss.linuxcontainers.org/t/how-to-connect-to-remote-windows-vm/20210/2
Ref: https://linuxcontainers.org/incus/news/ section: Configuration of list format

Closes lxc#2054

Signed-off-by: Mahesh Punjabi <mahesh.punjabi86@gmail.com>
@stgraber stgraber force-pushed the i2054-add-support-for-default-console-for-vms branch from ddcff32 to 22f8e7a Compare August 10, 2025 03:39
@stgraber stgraber changed the title cmd/incus/console: add default console command in configuration file incus/console: Add default console command in configuration file Aug 10, 2025
@stgraber stgraber enabled auto-merge August 10, 2025 03:39
@stgraber stgraber merged commit bc3fc24 into lxc:main Aug 10, 2025
102 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0