On 10/04/2017 10:58 AM, Jiri Denemark wrote:
When testing cpuDecode for computing guest CPU definition from CPUID
data (the CPU definition reported by domain capabilities), we need to
use CPU models (and their usability blockers) from QEMU if they are
available to cpuDecode in the same way it is actually used in the qemu
driver.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
tests/cputest.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 75 insertions(+), 6 deletions(-)
diff --git a/tests/cputest.c b/tests/cputest.c
index b72c17a168..18618ad309 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -515,6 +515,37 @@ cpuTestMakeQEMUCaps(const struct data *data)
qemuCaps = NULL;
goto cleanup;
}
+
+
+static virDomainCapsCPUModelsPtr
+cpuTestGetCPUModels(const struct data *data)
+{
+ virDomainCapsCPUModelsPtr models = NULL;
+ virQEMUCapsPtr qemuCaps;
+
+ if (data->flags != JSON_MODELS)
+ return NULL;
+
+ if (!(qemuCaps = cpuTestMakeQEMUCaps(data)))
+ return NULL;
+
+ models = virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM);
+ if (models)
+ virObjectRef(models);
As I learned a while back virObjectRef() works on a NULL @models - so no
need for the if (models) (and the Unref already doesn't have one).
+
+ virObjectUnref(qemuCaps);
+
+ return models;
+}
+
Reviewed-by: John Ferlan <jferlan(a)redhat.com>
John