How can the SPICE password of a libvirt+kvm+qemu virtual machine be changed while the machine is running?
Solution 1:
In order to be able to change the SPICE access password without a stop/start of the VM, the VM must already be equipped with a password. SPICE passwords cannot be added/removed without a restart.
Under this prerequis, we have two options to achieve this:
A: solution with virt-xml
Use the command virt-xml [-c qemu+ssh://host/system] name-of-the-vm --edit all --graphics password=verys3cr3t --update
B: solution with virsh
virsh [-c qemu+ssh://host/system] dumpxml --security-info name-of-the-vm > output.xml
- look for the block
<graphics type='spice' port='5900' autoport='no' listen='0.0.0.0' passwd='testpass'>...</graphics>
and isolate it, throw the rest away, save the graphics XML block undergraphics.xml
- Change the
passwd
attribute to the new desired password virsh [-c qemu+ssh://host/system] update-device name-of-the-vm graphics.xml