From: Jiri Denemark Date: Tue, 8 Oct 2024 10:26:40 +0000 (+0200) Subject: qemu: Drop vmx-* from migratable CPU model only when origCPU is set X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=aae8a5774ba7891401408c1169b5ed70037372bb;p=libvirt.git qemu: Drop vmx-* from migratable CPU model only when origCPU is set 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 Reviewed-by: Ján Tomko --- 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;