mirror of https://gitee.com/openkylin/libvirt.git
qemuMonitorCPUModelInfo: Add support for non-migratable features
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@redhat.com>
This commit is contained in:
parent
8a91e85382
commit
03a6a0dbe0
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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'/>
|
||||
|
|
|
@ -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'/>
|
||||
|
|
Loading…
Reference in New Issue