]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Validate domain definition even on migration
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 31 Jan 2022 11:55:47 +0000 (12:55 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Feb 2022 12:49:39 +0000 (13:49 +0100)
When we are about to spawn QEMU, we validate the domain
definition against qemuCaps. Except when domain is/was already
running before (i.e. on incoming migration, snapshots, resume
from a file). However, especially on incoming migration it may
happen that the destination QEMU is different to the source
QEMU, e.g. the destination QEMU may have some devices disabled.

And we have a function that validates devices/features requested
in domain XML against the desired QEMU capabilities (aka
qemuCaps) - it's virDomainDefValidate() which calls
qemuValidateDomainDef() and qemuValidateDomainDeviceDef()
subsequently.

But the problem here is that the validation function is
explicitly skipped over in specific scenarios (like incoming
migration, restore from a snapshot or previously saved file).

This in turn means that we may spawn QEMU and request
device/features it doesn't support. When that happens QEMU fails
to load migration stream:

  qemu-kvm: ... 'virtio-mem-pci' is not a valid device model name

(NB, while the example shows one particular device, the problem
is paramount)

This problem is easier to run into since we are slowly moving
validation from qemu_command.c into said validation functions.

The solution is simple: do the validation in all cases. And while
it may happen that users would be unable to migrate/restore a
guest due to a bug in our validator, spawning QEMU without
validation is worse (especially when you consider that users can
supply their own XMLs for migrate/restore operations - these were
never validated).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2048435
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_process.c

index c13280c8f39a5f23c7737a579ab704b9a81f7bb3..ea586e54c146d0e993e5cbd34f23789750204316 100644 (file)
@@ -5399,11 +5399,7 @@ qemuProcessStartValidate(virQEMUDriver *driver,
 
     }
 
-    /* Checks below should not be executed when starting a qemu process for a
-     * VM that was running before (migration, snapshots, save). It's more
-     * important to start such VM than keep the configuration clean */
-    if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
-        virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
+    if (virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
         return -1;
 
     if (qemuProcessStartValidateGraphics(vm) < 0)