954c63
From 84cedeca547585a51f6044186d241a501ff757d2 Mon Sep 17 00:00:00 2001
954c63
Message-Id: <84cedeca547585a51f6044186d241a501ff757d2@dist-git>
954c63
From: Michal Privoznik <mprivozn@redhat.com>
954c63
Date: Mon, 31 Jan 2022 12:55:47 +0100
954c63
Subject: [PATCH] qemu: Validate domain definition even on migration
954c63
954c63
When we are about to spawn QEMU, we validate the domain
954c63
definition against qemuCaps. Except when domain is/was already
954c63
running before (i.e. on incoming migration, snapshots, resume
954c63
from a file). However, especially on incoming migration it may
954c63
happen that the destination QEMU is different to the source
954c63
QEMU, e.g. the destination QEMU may have some devices disabled.
954c63
954c63
And we have a function that validates devices/features requested
954c63
in domain XML against the desired QEMU capabilities (aka
954c63
qemuCaps) - it's virDomainDefValidate() which calls
954c63
qemuValidateDomainDef() and qemuValidateDomainDeviceDef()
954c63
subsequently.
954c63
954c63
But the problem here is that the validation function is
954c63
explicitly skipped over in specific scenarios (like incoming
954c63
migration, restore from a snapshot or previously saved file).
954c63
954c63
This in turn means that we may spawn QEMU and request
954c63
device/features it doesn't support. When that happens QEMU fails
954c63
to load migration stream:
954c63
954c63
  qemu-kvm: ... 'virtio-mem-pci' is not a valid device model name
954c63
954c63
(NB, while the example shows one particular device, the problem
954c63
is paramount)
954c63
954c63
This problem is easier to run into since we are slowly moving
954c63
validation from qemu_command.c into said validation functions.
954c63
954c63
The solution is simple: do the validation in all cases. And while
954c63
it may happen that users would be unable to migrate/restore a
954c63
guest due to a bug in our validator, spawning QEMU without
954c63
validation is worse (especially when you consider that users can
954c63
supply their own XMLs for migrate/restore operations - these were
954c63
never validated).
954c63
954c63
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2048435
954c63
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
954c63
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
954c63
(cherry picked from commit 517b8c12b98d7ac0bb4d582e0b491d50d776eb6d)
954c63
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
954c63
---
954c63
 src/qemu/qemu_process.c | 6 +-----
954c63
 1 file changed, 1 insertion(+), 5 deletions(-)
954c63
954c63
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
954c63
index 5c9ca0fe4f..5c6657a876 100644
954c63
--- a/src/qemu/qemu_process.c
954c63
+++ b/src/qemu/qemu_process.c
954c63
@@ -5411,11 +5411,7 @@ qemuProcessStartValidate(virQEMUDriver *driver,
954c63
 
954c63
     }
954c63
 
954c63
-    /* Checks below should not be executed when starting a qemu process for a
954c63
-     * VM that was running before (migration, snapshots, save). It's more
954c63
-     * important to start such VM than keep the configuration clean */
954c63
-    if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
954c63
-        virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
954c63
+    if (virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
954c63
         return -1;
954c63
 
954c63
     if (qemuProcessStartValidateGraphics(vm) < 0)
954c63
-- 
954c63
2.35.1
954c63