QEMU is able to tell us whether a CPU feature would block migration or not. This patch adds support for storing such features in qemuMonitorCPUModelInfo. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 39 +++++++++++++++++++++--- src/qemu/qemu_monitor.c | 2 ++ src/qemu/qemu_monitor.h | 2 ++ tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 2 +- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 4 +-- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f51141b99..446c15f92 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3272,6 +3272,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, int ret = -1; size_t i; int n; + int val; if (virtType == VIR_DOMAIN_VIRT_KVM) hostCPUNode = virXPathNode("./hostCPU[@type='kvm']", ctxt); @@ -3293,6 +3294,15 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, goto cleanup; } + if (!(str = virXMLPropString(hostCPUNode, "migratability")) || + (val = virTristateBoolTypeFromString(str)) <= 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid migratability value for host CPU model")); + goto cleanup; + } + hostCPU->migratability = val == VIR_TRISTATE_BOOL_YES; + VIR_FREE(str); + ctxt->node = hostCPUNode; if ((n = virXPathNodeSet("./property", ctxt, &nodes)) > 0) { @@ -3303,7 +3313,6 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, for (i = 0; i < n; i++) { qemuMonitorCPUPropertyPtr prop = hostCPU->props + i; - int type; ctxt->node = nodes[i]; @@ -3315,7 +3324,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, } if (!(str = virXMLPropString(ctxt->node, "type")) || - (type = qemuMonitorCPUPropertyTypeFromString(str)) < 0) { + (val = qemuMonitorCPUPropertyTypeFromString(str)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or invalid CPU model property type " "in QEMU capabilities cache")); @@ -3323,7 +3332,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, } VIR_FREE(str); - prop->type = type; + prop->type = val; switch (prop->type) { case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN: if (virXPathBoolean("./@value='true'", ctxt)) @@ -3355,6 +3364,19 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps, case QEMU_MONITOR_CPU_PROPERTY_LAST: break; } + + if ((str = virXMLPropString(ctxt->node, "migratable"))) { + if ((val = virTristateBoolTypeFromString(str)) <= 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown migratable value for '%s' host " + "CPU model property"), + prop->name); + goto cleanup; + } + + prop->migratable = val; + VIR_FREE(str); + } } } @@ -3707,8 +3729,10 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps, if (!model) return; - virBufferAsprintf(buf, "<hostCPU type='%s' model='%s'>\n", - typeStr, model->name); + virBufferAsprintf(buf, + "<hostCPU type='%s' model='%s' migratability='%s'>\n", + typeStr, model->name, + model->migratability ? "yes" : "no"); virBufferAdjustIndent(buf, 2); for (i = 0; i < model->nprops; i++) { @@ -3735,6 +3759,11 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps, case QEMU_MONITOR_CPU_PROPERTY_LAST: break; } + + if (prop->migratable > 0) + virBufferAsprintf(buf, " migratable='%s'", + virTristateBoolTypeToString(prop->migratable)); + virBufferAddLit(buf, "/>\n"); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 78d9cb752..e9ba5fdea 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3747,12 +3747,14 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) if (VIR_STRDUP(copy->name, orig->name) < 0) goto error; + copy->migratability = orig->migratability; copy->nprops = orig->nprops; for (i = 0; i < orig->nprops; i++) { if (VIR_STRDUP(copy->props[i].name, orig->props[i].name) < 0) goto error; + copy->props[i].migratable = orig->props[i].migratable; copy->props[i].type = orig->props[i].type; switch (orig->props[i].type) { case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN: diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 87a1496cf..332652178 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -992,6 +992,7 @@ struct _qemuMonitorCPUProperty { char *string; long long number; } value; + virTristateBool migratable; }; typedef struct _qemuMonitorCPUModelInfo qemuMonitorCPUModelInfo; @@ -1001,6 +1002,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUPropertyPtr props; + bool migratability; }; typedef enum { diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml index d49f0fbd1..42c92c567 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -136,7 +136,7 @@ <kvmVersion>0</kvmVersion> <package></package> <arch>s390x</arch> - <hostCPU type='kvm' model='zEC12.2-base'> + <hostCPU type='kvm' model='zEC12.2-base' migratability='no'> <property name='aefsi' type='boolean' value='true'/> <property name='msa5' type='boolean' value='true'/> <property name='msa4' type='boolean' value='true'/> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index bb5463469..0b14e53e2 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -211,7 +211,7 @@ <kvmVersion>0</kvmVersion> <package> (v2.9.0-rc0-142-g940a8ce)</package> <arch>x86_64</arch> - <hostCPU type='kvm' model='base'> + <hostCPU type='kvm' model='base' migratability='no'> <property name='phys-bits' type='number' value='0'/> <property name='core-id' type='number' value='-1'/> <property name='xlevel' type='number' value='2147483656'/> @@ -443,7 +443,7 @@ <property name='avx512pf' type='boolean' value='false'/> <property name='xstore-en' type='boolean' value='false'/> </hostCPU> - <hostCPU type='tcg' model='base'> + <hostCPU type='tcg' model='base' migratability='no'> <property name='phys-bits' type='number' value='0'/> <property name='core-id' type='number' value='-1'/> <property name='xlevel' type='number' value='2147483658'/> -- 2.12.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list