mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemu: Add migratable parameter to virQEMUCapsInitCPUModel
The caller can ask for a migratable CPU model by passing true for the new parameter. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
d84b93fad5
commit
00e0cbcb56
@ -3116,7 +3116,8 @@ virQEMUCapsCPUFilterFeatures(const char *name,
|
|||||||
static int
|
static int
|
||||||
virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
||||||
qemuMonitorCPUModelInfoPtr modelInfo,
|
qemuMonitorCPUModelInfoPtr modelInfo,
|
||||||
virCPUDefPtr cpu)
|
virCPUDefPtr cpu,
|
||||||
|
bool migratable)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -3144,8 +3145,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
if (VIR_STRDUP(feature->name, prop->name) < 0)
|
if (VIR_STRDUP(feature->name, prop->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
feature->policy = prop->value.boolean ? VIR_CPU_FEATURE_REQUIRE
|
|
||||||
: VIR_CPU_FEATURE_DISABLE;
|
if (!prop->value.boolean ||
|
||||||
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
||||||
|
feature->policy = VIR_CPU_FEATURE_DISABLE;
|
||||||
|
else
|
||||||
|
feature->policy = VIR_CPU_FEATURE_REQUIRE;
|
||||||
cpu->nfeatures++;
|
cpu->nfeatures++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3162,7 +3167,8 @@ static int
|
|||||||
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
||||||
virDomainVirtType type,
|
virDomainVirtType type,
|
||||||
qemuMonitorCPUModelInfoPtr model,
|
qemuMonitorCPUModelInfoPtr model,
|
||||||
virCPUDefPtr cpu)
|
virCPUDefPtr cpu,
|
||||||
|
bool migratable)
|
||||||
{
|
{
|
||||||
virCPUDataPtr data = NULL;
|
virCPUDataPtr data = NULL;
|
||||||
unsigned long long sigFamily = 0;
|
unsigned long long sigFamily = 0;
|
||||||
@ -3183,9 +3189,13 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
switch (prop->type) {
|
switch (prop->type) {
|
||||||
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
||||||
if (prop->value.boolean &&
|
if (!prop->value.boolean ||
|
||||||
virCPUx86DataAddFeature(data, prop->name) < 0)
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (virCPUx86DataAddFeature(data, prop->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
||||||
@ -3224,13 +3234,14 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
||||||
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
* 1 when the caller should fall back to other methods
|
||||||
* -1 on error.
|
* -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
virDomainVirtType type,
|
virDomainVirtType type,
|
||||||
virCPUDefPtr cpu)
|
virCPUDefPtr cpu,
|
||||||
|
bool migratable)
|
||||||
{
|
{
|
||||||
qemuMonitorCPUModelInfoPtr model;
|
qemuMonitorCPUModelInfoPtr model;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
@ -3240,10 +3251,13 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
|||||||
else
|
else
|
||||||
model = qemuCaps->tcgCPUModelInfo;
|
model = qemuCaps->tcgCPUModelInfo;
|
||||||
|
|
||||||
|
if (migratable && model && !model->migratability)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (ARCH_IS_S390(qemuCaps->arch))
|
if (ARCH_IS_S390(qemuCaps->arch))
|
||||||
ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu);
|
ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu, migratable);
|
||||||
else if (ARCH_IS_X86(qemuCaps->arch))
|
else if (ARCH_IS_X86(qemuCaps->arch))
|
||||||
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu);
|
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu, migratable);
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
||||||
@ -3272,7 +3286,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
|||||||
cpu->match = VIR_CPU_MATCH_EXACT;
|
cpu->match = VIR_CPU_MATCH_EXACT;
|
||||||
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
||||||
|
|
||||||
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu)) < 0) {
|
if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
} else if (rc == 1) {
|
} else if (rc == 1) {
|
||||||
VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
|
VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
|
||||||
|
@ -81,7 +81,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
|||||||
int
|
int
|
||||||
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
virDomainVirtType type,
|
virDomainVirtType type,
|
||||||
virCPUDefPtr cpu);
|
virCPUDefPtr cpu,
|
||||||
|
bool migratable);
|
||||||
|
|
||||||
void
|
void
|
||||||
virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
|
virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
|
||||||
|
@ -709,7 +709,7 @@ cpuTestJSONCPUID(const void *arg)
|
|||||||
cpu->match = VIR_CPU_MATCH_EXACT;
|
cpu->match = VIR_CPU_MATCH_EXACT;
|
||||||
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
||||||
|
|
||||||
if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu) != 0)
|
if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = cpuTestCompareXML(data->arch, cpu, result, false);
|
ret = cpuTestCompareXML(data->arch, cpu, result, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user