From 30de7164efa18fce6c5e87134b0ec61e14507aef Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 3 Aug 2016 10:47:00 +0200 Subject: [PATCH] qemuxml2argvtest: Reorder functions testCompareXMLToArgv will soon need to call a few function which are defined further in the code. Let's move them up a bit. Signed-off-by: Jiri Denemark --- tests/qemuxml2argvtest.c | 104 ++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bd140fc3b2..6c7bc4b1eb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -274,6 +274,59 @@ struct testInfo { unsigned int parseFlags; }; + +static int +testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy) +{ + const char *newModels[] = { + "Opteron_G3", "Opteron_G2", "Opteron_G1", + "Nehalem", "Penryn", "Conroe", + "Haswell-noTSX", "Haswell", + }; + const char *legacyModels[] = { + "n270", "athlon", "pentium3", "pentium2", "pentium", + "486", "coreduo", "kvm32", "qemu32", "kvm64", + "core2duo", "phenom", "qemu64", + }; + + if (virQEMUCapsAddCPUDefinitions(caps, newModels, + ARRAY_CARDINALITY(newModels)) < 0) + return -1; + + if (skipLegacy) + return 0; + + if (virQEMUCapsAddCPUDefinitions(caps, legacyModels, + ARRAY_CARDINALITY(legacyModels)) < 0) + return -1; + + return 0; +} + + +static int +testPrepareExtraFlags(struct testInfo *info, + bool skipLegacyCPUs, + int gic) +{ + int ret = -1; + + if (!(info->qemuCaps = virQEMUCapsNew())) + goto cleanup; + + if (testAddCPUModels(info->qemuCaps, skipLegacyCPUs) < 0) + goto cleanup; + + if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0) + goto cleanup; + + ret = 0; + + cleanup: + return ret; +} + + static int testCompareXMLToArgv(const void *data) { @@ -424,57 +477,6 @@ testCompareXMLToArgv(const void *data) } -static int -testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy) -{ - const char *newModels[] = { - "Opteron_G3", "Opteron_G2", "Opteron_G1", - "Nehalem", "Penryn", "Conroe", - "Haswell-noTSX", "Haswell", - }; - const char *legacyModels[] = { - "n270", "athlon", "pentium3", "pentium2", "pentium", - "486", "coreduo", "kvm32", "qemu32", "kvm64", - "core2duo", "phenom", "qemu64", - }; - - if (virQEMUCapsAddCPUDefinitions(caps, newModels, - ARRAY_CARDINALITY(newModels)) < 0) - return -1; - - if (skipLegacy) - return 0; - - if (virQEMUCapsAddCPUDefinitions(caps, legacyModels, - ARRAY_CARDINALITY(legacyModels)) < 0) - return -1; - - return 0; -} - - -static int -testPrepareExtraFlags(struct testInfo *info, - bool skipLegacyCPUs, - int gic) -{ - int ret = -1; - - if (!(info->qemuCaps = virQEMUCapsNew())) - goto cleanup; - - if (testAddCPUModels(info->qemuCaps, skipLegacyCPUs) < 0) - goto cleanup; - - if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0) - goto cleanup; - - ret = 0; - - cleanup: - return ret; -} - static int mymain(void) {