Change VNC listen address in Libvirt without restarting VM

kvm-virtualizationlibvirtvnc

Is there a way to to edit the listen address of a Libvirt-Machine on the fly? At the moment it seems like when I want to edit the listen address, I have to shut down the corresponding VM first, then edit the xml and redefine the domain.

I'm currently building a small web application (libvirt frontend) where I would like to implement a function called "enable / disable vnc" – however, that doesn't seem possible to me at the moment if the only way is shutting down the vm.

Best Answer

You have to go to QEMU Monitor and run:

change vnc display,options

Where display is <host>:<display_number> or unix:<path> or none. Options are options for display. See: https://qemu.weilnetz.de/doc/qemu-doc.html#sec_005finvocation

E.g. To change the port to 5905 and accept VNC connections for any host:

change vnc :5

If you are using virsh, use "qemu-monitor-command":

virsh # qemu-monitor-command <domain> --hmp change  vnc :5