When qemuDomainMakeCPUMigratable is called with origCPU == NULL the code
just removed all vmx-* features marked as added in the specified CPU
model just like when origCPU is not NULL, but does not list any of the
vmx-* features. But this is wrong, we should not touch these features at
all when no origCPU is supplied, which happens when parsing XML passed
by a user (e.g., migration XML). Such XML is supposed to be generated by
libvirt as migration XML and contains only vmx-* features explicitly
requested by a user.
https://issues.redhat.com/browse/RHEL-52314
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b6762cc372..f8eac603ec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6889,23 +6889,21 @@ qemuDomainMakeCPUMigratable(virArch arch,
virCPUDefUpdateFeature(cpu, "pconfig", VIR_CPU_FEATURE_DISABLE);
}
- if (virCPUx86GetAddedFeatures(cpu->model, &data.added) < 0)
- return -1;
-
- /* Drop features marked as added in a cpu model, but only
- * when they are not mentioned in origCPU, i.e., when they were not
- * explicitly mentioned by the user.
- */
- if (data.added) {
- g_auto(GStrv) keep = NULL;
+ if (origCPU) {
+ if (virCPUx86GetAddedFeatures(cpu->model, &data.added) < 0)
+ return -1;
- if (origCPU) {
- keep = virCPUDefListExplicitFeatures(origCPU);
+ /* Drop features marked as added in a cpu model, but only
+ * when they are not mentioned in origCPU, i.e., when they were not
+ * explicitly mentioned by the user.
+ */
+ if (data.added) {
+ g_auto(GStrv) keep = virCPUDefListExplicitFeatures(origCPU);
data.keep = keep;
- }
- if (virCPUDefFilterFeatures(cpu, qemuDomainDropAddedCPUFeatures, &data) <
0)
- return -1;
+ if (virCPUDefFilterFeatures(cpu, qemuDomainDropAddedCPUFeatures, &data)
< 0)
+ return -1;
+ }
}
return 0;
--
2.46.2