The checks are now in a dedicated qemuProcessVerifyCPUFeatures function. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_process.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index df9489f3e..25371b93d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3801,6 +3801,36 @@ qemuProcessVerifyKVMFeatures(virDomainDefPtr def, } +static int +qemuProcessVerifyCPUFeatures(virDomainDefPtr def, + virCPUDataPtr cpu) +{ + int rc; + + if (!def->cpu || + (def->cpu->mode == VIR_CPU_MODE_CUSTOM && + !def->cpu->model)) + return 0; + + rc = virCPUCheckFeature(def->os.arch, def->cpu, "invtsc"); + + if (rc < 0) { + return -1; + } else if (rc == 1) { + rc = virCPUDataCheckFeature(cpu, "invtsc"); + if (rc <= 0) { + if (rc == 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support invariant TSC")); + } + return -1; + } + } + + return 0; +} + + static bool qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3812,7 +3842,6 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; int rc; bool ret = false; - size_t i; switch (arch) { case VIR_ARCH_I686: @@ -3834,21 +3863,8 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) goto cleanup; - if (def->cpu) { - for (i = 0; i < def->cpu->nfeatures; i++) { - virCPUFeatureDefPtr feature = &def->cpu->features[i]; - - if (feature->policy != VIR_CPU_FEATURE_REQUIRE) - continue; - - if (STREQ(feature->name, "invtsc") && - !virCPUDataCheckFeature(guestcpu, feature->name)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support invariant TSC")); - goto cleanup; - } - } - } + if (qemuProcessVerifyCPUFeatures(def, guestcpu) < 0) + goto cleanup; break; default: -- 2.12.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list