diff --git a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml index 990661bf38..32f981db0c 100644 --- a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml +++ b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml @@ -3,6 +3,7 @@ kvm pc-1.2 x86_64 + /usr/share/AAVMF/AAVMF_CODE.fd diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.x86_64.caps index 4fdb88b1c4..257a123896 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -114,4 +118,42 @@ + 1002002 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.x86_64.caps index 6aac9c789d..6f6a5b9b95 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -130,4 +134,46 @@ + 1003001 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.x86_64.caps index b3440b5516..18550e29ba 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -131,4 +135,47 @@ + 1004002 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.x86_64.caps index 69f1ae0cff..72f09f7a6b 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -140,4 +144,47 @@ + 1005003 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.x86_64.caps index 90ea076a14..c612c11ecc 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -146,4 +150,51 @@ + 1006000 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.x86_64.caps index 8fcdae23f4..f4603c155f 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -146,4 +150,53 @@ + 1006050 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.x86_64.caps index ac5d29fbbf..4663e192bc 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -164,4 +168,58 @@ + 2001001 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.x86_64.caps index 249a507e16..a8df7e1c41 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -177,4 +181,65 @@ + 2004000 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_2.5.0-1.x86_64.caps index 9b30bbb778..216017377e 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -178,4 +182,65 @@ + 2004000 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-1.x86_64.caps b/tests/qemucapabilitiesdata/caps_2.6.0-1.x86_64.caps index 905144aee8..9024d63882 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-1.x86_64.caps +++ b/tests/qemucapabilitiesdata/caps_2.6.0-1.x86_64.caps @@ -1,4 +1,8 @@ + 0 + 0 + 0 + @@ -183,4 +187,65 @@ + 2005050 + 0 + + x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 80f3cd8daa..8b73a8910a 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -22,7 +22,8 @@ #include "testutils.h" #include "testutilsqemu.h" #include "qemumonitortestutils.h" - +#define __QEMU_CAPSRIV_H_ALLOW__ +#include "qemu/qemu_capspriv.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -85,42 +86,17 @@ testQemuFeedMonitor(char *replies, return NULL; } -static int -testQemuCapsCompare(virQEMUCapsPtr capsExpected, - virQEMUCapsPtr capsActual) -{ - int ret = 0; - size_t i; - - for (i = 0; i < QEMU_CAPS_LAST; i++) { - if (virQEMUCapsGet(capsExpected, i) && - !virQEMUCapsGet(capsActual, i)) { - fprintf(stderr, "Expected caps flag not set: %s\n", - virQEMUCapsTypeToString(i)); - ret = -1; - } - - if (!virQEMUCapsGet(capsExpected, i) && - virQEMUCapsGet(capsActual, i)) { - fprintf(stderr, "Unexpected caps flag set: %s\n", - virQEMUCapsTypeToString(i)); - ret = -1; - } - } - - return ret; -} - static int testQemuCaps(const void *opaque) { int ret = -1; const testQemuData *data = opaque; - char *repliesFile = NULL, *capsFile = NULL; + char *repliesFile = NULL; + char *capsFile = NULL; char *replies = NULL; qemuMonitorTestPtr mon = NULL; - virQEMUCapsPtr capsExpected = NULL; virQEMUCapsPtr capsActual = NULL; + char *actual = NULL; if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.%s.replies", abs_srcdir, data->base, data->archName) < 0 || @@ -134,17 +110,15 @@ testQemuCaps(const void *opaque) if (!(mon = testQemuFeedMonitor(replies, data->xmlopt))) goto cleanup; - if (!(capsExpected = qemuTestParseCapabilities(capsFile))) - goto cleanup; - - if (!(capsActual = virQEMUCapsNew())) - goto cleanup; - - if (virQEMUCapsInitQMPMonitor(capsActual, + if (!(capsActual = virQEMUCapsNew()) || + virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) goto cleanup; - if (testQemuCapsCompare(capsExpected, capsActual) < 0) + if (!(actual = virQEMUCapsFormatCache(capsActual, 0, 0))) + goto cleanup; + + if (virtTestCompareToFile(actual, capsFile) < 0) goto cleanup; ret = 0; @@ -152,8 +126,8 @@ testQemuCaps(const void *opaque) VIR_FREE(repliesFile); VIR_FREE(capsFile); VIR_FREE(replies); + VIR_FREE(actual); qemuMonitorTestFree(mon); - virObjectUnref(capsExpected); virObjectUnref(capsActual); return ret; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 114cd24265..8f7f52b89c 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -452,48 +452,19 @@ virQEMUCapsPtr qemuTestParseCapabilities(const char *capsFile) { virQEMUCapsPtr qemuCaps = NULL; - xmlDocPtr xml; - xmlXPathContextPtr ctxt = NULL; - ssize_t i, n; - xmlNodePtr *nodes = NULL; + time_t qemuctime; + time_t selfctime; + unsigned long version; - if (!(xml = virXMLParseFileCtxt(capsFile, &ctxt))) + if (!(qemuCaps = virQEMUCapsNew()) || + virQEMUCapsLoadCache(qemuCaps, capsFile, + &qemuctime, &selfctime, &version) < 0) goto error; - if ((n = virXPathNodeSet("/qemuCaps/flag", ctxt, &nodes)) < 0) { - fprintf(stderr, "failed to parse qemu capabilities flags"); - goto error; - } - - if (n > 0) { - if (!(qemuCaps = virQEMUCapsNew())) - goto error; - - for (i = 0; i < n; i++) { - char *str = virXMLPropString(nodes[i], "name"); - if (str) { - int flag = virQEMUCapsTypeFromString(str); - if (flag < 0) { - fprintf(stderr, "Unknown qemu capabilities flag %s", str); - VIR_FREE(str); - goto error; - } - VIR_FREE(str); - virQEMUCapsSet(qemuCaps, flag); - } - } - } - - VIR_FREE(nodes); - xmlFreeDoc(xml); - xmlXPathFreeContext(ctxt); return qemuCaps; error: - VIR_FREE(nodes); virObjectUnref(qemuCaps); - xmlFreeDoc(xml); - xmlXPathFreeContext(ctxt); return NULL; }