[libvirt] [RFC] Fixing a regression caused by recent CPU driver changes

Jiri Denemark jdenemar at redhat.com
Thu May 18 08:22:59 UTC 2017


Hi all,

when I was enhancing libvirt's guest CPU configuration code to be able
to really ensure stable guest CPU ABI, I added a new attribute
//cpu/@check which is nicely backward compatible... an old libvirt will
just ignore it. However, even if check='full' will be ignored, an old
libvirt will still see the updated CPU definition (features added or
removed by the hypervisor will be shown there). And because we need QEMU
2.9.0 to check what features are going to be added or removed before we
actually start the domain, migrating such domain to an older libvirt or
QEMU may fail if QEMU enables a feature which is not supported by the
host CPU. Known features causing problems are, e.g., x2apic, hypervisor,
and arat. To make things even worse, updating a CPU definition with the
automatically added/removed features can be done since QEMU 1.5.0.

Even save/restore or snapshot revert on a single host running new
libvirt and QEMU < 2.9.0 is now affected by this regression.

The big question is how to fix the regression in a backward compatible
way and still keep the ability to properly check guest CPU ABI with new
enough libvirt and QEMU. Clearly, we need to keep both the original and
the updated CPU definition (or one of them and a diff against the
other).

I came up with the following options:

1. When migrating a domain, the domain XML would contain the original
   CPU def while the updated one would be transferred in a migration
   cookie.
   - doesn't fix save/restore or snapshot revert
     - could be fixed by not updating the CPU with QEMU < 2.9.0, but it
       won't work when restore is done on a different host with older
       QEMU (and yes, this happens in real life, e.g., with oVirt)
   - doesn't even fix migration after save/restore or snapshot revert

2. Use migration cookie and change the save image format to contain
   additional data (something like migration cookie) which a new libvirt
   could make use of while old libvirt would ignore any additional data
   it doesn't know about
   - snapshot XML would need to be updated too, but that's trivial
   - cleanly changing save image format requires its version to be
     increased and old libvirt will just refuse to read such image
   - this would fix save/restore on the same host or on a host with
     older QEMU
   - doesn't fix restore on a different host running older libvirt
     - even this is done by oVirt

3. Use migration cookie and change the save image format without
   increasing its version (and update snapshot XML)
   - this fixes all cases
   - technically possible by using one of the unused 32b ints and
     adding \0 at the end of the domain XML followed by anothe XML with
     the additional data (pointed to by the formerly unused uint32_t)
   - very ugly hack

4. Format both CPUs in domain XML by adding a new subelement in <cpu>
   which would list all extra features disabled or enabled by QEMU
   - fixes all cases without the need to use migration cookie, change
     save image format, or snapshot XML
   - but it may be very confusing for users and it would need to be
     documented as "output only, don't touch staff"

5. Add the additional data in <metadata>
   - a bad joke really


So my preferred solution is 2. It breaks restore on a host with older
libvirt, but it was never guaranteed to work, even though it usually
just worked. And we could just tell oVirt to fix there usage :-) Also
additional data in save image header may be very useful in the future; I
think I remember someone sighing about the inability to store more than
just domain XML in a saved image when they were trying to fix some
compatibility issues.

Any thoughts about the options or even completely new ideas are very
welcome.

Thanks,

Jirka




More information about the libvir-list mailing list