On Mon, Nov 02, 2026 at 09:32:39 +0000, Abhisek Panda wrote:
Libvirt by default attempt to use the TLS-PSK-enabled VM migration. The source host adds the pre-shared key in the migration cookie. Upon parsing the migration cookie, the destination host informs the source host whether to use TLS X.509 or TLS PSK during VM migration via the migration cookie.
For a migration session, Libvirt generates a random key of the specified length, and then stores the content, "qemu:<random key>", at <tls_psk_state_dir>/$ID-$VMNAME/keys.psk on the source host. This is because QEMU's tls-creds-psk object does not accept a raw key string as a parameter, it only accepts a dir argument pointing to a directory from which it can read the key file. Subsequently, it sends the key to destination by embedding it within the migration cookie. The destination's Libvirt extracts the key from the migration cookie. Upon migration completion or any failure, both source and destination Libvirt must delete the directory containing the session's keys.psk.
Signed-off-by: Abhisek Panda <abhisek.panda1@nutanix.com> --- src/qemu/qemu_conf.c | 4 ++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 6 ++ src/qemu/qemu_migration.c | 104 ++++++++++++++++++++++++++++- src/qemu/qemu_migration.h | 3 + src/qemu/qemu_migration_cookie.c | 67 ++++++++++++++++++- src/qemu/qemu_migration_cookie.h | 5 ++ src/qemu/qemu_process.c | 3 + tests/qemumigrationcookiexmltest.c | 12 +++- 11 files changed, 200 insertions(+), 7 deletions(-)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>