d/kvm-spice: fix when acceleration is already defined on the commandline
Issue:
- lxc exec testkvm-impish-from -- virsh migrate --unsafe --live kvmguest-bionic-normal qemu+ssh://10.104.227.250/system error: internal error: process exited while connecting to monitor: /usr/bin/kvm-spice: W: this is an old compat wrapper script for qemu-system-x86_64 -enable-kvm /usr/bin/kvm-spice: W: please use qemu-system-x86_64 instead of /usr/bin/kvm-spice 2022-02-07T15:16:56.765786Z qemu-system-x86_64: The -accel and "-machine accel=" options are incompatible
Original check since qemu 5.0 commit 6f6e1698 Author: Paolo Bonzini pbonzini@redhat.com Date: Wed Nov 13 10:10:47 2019 +0100
vl: configure accelerators from -accel options
But since recent commit (qemu 6.1)
commit dadafe67 Author: Jason Andryuk jandryuk@gmail.com Date: Mon Jul 12 22:15:52 2021 -0400
vl: Parse legacy default_machine_opt
Combined with our fallback legacy kvm-spice wrapper that does exec qemu-system-x86_64 -enable-kvm "$@"
It can happen that we have -enable-kvm added by our wrapper (e.g. a guest created on Bionic has that set as emulator, migrating to a new system). Then the wrapper adds -enable-kvm. Internally that is mapped to QEMU_OPTION_enable_kvm which becomes qdict_put_str(machine_opts_dict, "accel", "kvm") that is equivalent to '-accel kvm'
But if libvirt is already passing the new style '-machine accel=kvm' then the above older check triggers and rightfully complains about the duplication.
Repro, on jammy spawn a guest and set /usr/bin/kvm-spice Then starting it will fail with above message.
An example arg might look like: -machine none,accel=kvm:tcg -machine none,accel=tcg -machine accel=tcg -accel kvm -accel tcg
In that case we can not add -enable-kvm without breaking it. Check for that pattern and skip adding -enable-kvm.
Signed-off-by: Christian Ehrhardt christian.ehrhardt@canonical.com