From d5f47d7d75eefe6afd941f963515cafe865c7ab0 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Sat, 11 Mar 2017 00:10:56 +0100 Subject: [PATCH] qemu: Refactor KVM features check The checks are now in a dedicated qemuProcessVerifyKVMFeatures function. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 097801e732..d779b421ae 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3787,6 +3787,28 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def, } +static int +qemuProcessVerifyKVMFeatures(virDomainDefPtr def, + virCPUDataPtr cpu) +{ + int rc = 0; + + if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] != VIR_TRISTATE_SWITCH_ON) + return 0; + + rc = virCPUDataCheckFeature(cpu, VIR_CPU_x86_KVM_PV_UNHALT); + + if (rc <= 0) { + if (rc == 0) + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support paravirtual spinlocks")); + return -1; + } + + return 0; +} + + static bool qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3816,15 +3838,8 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, goto cleanup; } - if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_TRISTATE_SWITCH_ON) { - if (!virCPUDataCheckFeature(guestcpu, VIR_CPU_x86_KVM_PV_UNHALT)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support paravirtual spinlocks")); - goto cleanup; - } - } - - if (qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) + if (qemuProcessVerifyKVMFeatures(def, guestcpu) < 0 || + qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) goto cleanup; if (def->cpu) { -- GitLab