Is there a way to keep VM vga console attached on reboot?

If I run a virtual machine with lxc start VMNAME --console=vga it will open a display window connected to the VM’s GPU. Unlike with libvirt, when rebooting the VM, the window is closed and I have to reattach with lxc console VMNAME --type vga.

Is there some way to prevent this detach behavior and keep window open on reboot?

No. That’s because the VM isn’t so much rebooting as being stopped and started back by LXD.

We do this so we have a chance to update the hypervisor if needed as well as to cleanly re-apply the VM configuration should anything have changed (or bugs been fixed).

So the SPICE server which is built into QEMU gets completely stopped as QEMU itself exits, making it impossible to keep the connection going across an instance restart.

Interesting that this happens even if I reboot by typing “reboot” inside the VM. Can you explain how does LXD “intercepts” the reboot in order to shutdown + restart? The reason I ask is because I’m running a local fork of LXD, so I wouldn’t mind tweaking it so that it doesn’t shutdown qemu when rebooting.

LXD connects to QEMU over QMP, QMP sends an event on shutdown and reboot, LXD then tells the emulator to terminate.

1 Like

@tarruda
From an LXD Host terminal you can do this to get your Desktop vga console back again

$ lxc restart vm-name --console=vga