mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
testutilsqemuschema: Allow loading non-latest schema
Add testQEMUSchemaLoad and refactor internals so that we can load the QMP schema from an arbitrary caps replies file. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
18e9806c64
commit
b6246d9320
@ -607,37 +607,23 @@ testQEMUSchemaValidateCommand(const char *command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
static virJSONValuePtr
|
||||||
* testQEMUSchemaGetLatest:
|
testQEMUSchemaLoadReplies(const char *filename)
|
||||||
*
|
|
||||||
* Returns the schema data as the qemu monitor would reply from the latest
|
|
||||||
* replies file used for qemucapabilitiestest for the x86_64 architecture.
|
|
||||||
*/
|
|
||||||
virJSONValuePtr
|
|
||||||
testQEMUSchemaGetLatest(const char* arch)
|
|
||||||
{
|
{
|
||||||
g_autofree char *capsLatestFile = NULL;
|
g_autofree char *caps = NULL;
|
||||||
g_autofree char *capsLatest = NULL;
|
|
||||||
char *schemaReply;
|
char *schemaReply;
|
||||||
char *end;
|
char *end;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr schema = NULL;
|
virJSONValuePtr schema = NULL;
|
||||||
|
|
||||||
if (!(capsLatestFile = testQemuGetLatestCapsForArch(arch, "replies"))) {
|
if (virTestLoadFile(filename, &caps) < 0)
|
||||||
VIR_TEST_VERBOSE("failed to find latest caps replies");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile);
|
|
||||||
|
|
||||||
if (virTestLoadFile(capsLatestFile, &capsLatest) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(schemaReply = strstr(capsLatest, "\"execute\": \"query-qmp-schema\"")) ||
|
if (!(schemaReply = strstr(caps, "\"execute\": \"query-qmp-schema\"")) ||
|
||||||
!(schemaReply = strstr(schemaReply, "\n\n")) ||
|
!(schemaReply = strstr(schemaReply, "\n\n")) ||
|
||||||
!(end = strstr(schemaReply + 2, "\n\n"))) {
|
!(end = strstr(schemaReply + 2, "\n\n"))) {
|
||||||
VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%s'",
|
VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%s'",
|
||||||
capsLatestFile);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,13 +632,13 @@ testQEMUSchemaGetLatest(const char* arch)
|
|||||||
|
|
||||||
if (!(reply = virJSONValueFromString(schemaReply))) {
|
if (!(reply = virJSONValueFromString(schemaReply))) {
|
||||||
VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%s'",
|
VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%s'",
|
||||||
capsLatestFile);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(schema = virJSONValueObjectStealArray(reply, "return"))) {
|
if (!(schema = virJSONValueObjectStealArray(reply, "return"))) {
|
||||||
VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'",
|
VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'",
|
||||||
capsLatestFile);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,6 +646,28 @@ testQEMUSchemaGetLatest(const char* arch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testQEMUSchemaGetLatest:
|
||||||
|
*
|
||||||
|
* Returns the schema data as the qemu monitor would reply from the latest
|
||||||
|
* replies file used for qemucapabilitiestest for the x86_64 architecture.
|
||||||
|
*/
|
||||||
|
virJSONValuePtr
|
||||||
|
testQEMUSchemaGetLatest(const char *arch)
|
||||||
|
{
|
||||||
|
g_autofree char *capsLatestFile = NULL;
|
||||||
|
|
||||||
|
if (!(capsLatestFile = testQemuGetLatestCapsForArch(arch, "replies"))) {
|
||||||
|
VIR_TEST_VERBOSE("failed to find latest caps replies");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile);
|
||||||
|
|
||||||
|
return testQEMUSchemaLoadReplies(capsLatestFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
testQEMUSchemaLoadLatest(const char *arch)
|
testQEMUSchemaLoadLatest(const char *arch)
|
||||||
{
|
{
|
||||||
@ -670,3 +678,15 @@ testQEMUSchemaLoadLatest(const char *arch)
|
|||||||
|
|
||||||
return virQEMUQAPISchemaConvert(schema);
|
return virQEMUQAPISchemaConvert(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virHashTablePtr
|
||||||
|
testQEMUSchemaLoad(const char *filename)
|
||||||
|
{
|
||||||
|
virJSONValuePtr schema;
|
||||||
|
|
||||||
|
if (!(schema = testQEMUSchemaLoadReplies(filename)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return virQEMUQAPISchemaConvert(schema);
|
||||||
|
}
|
||||||
|
@ -42,3 +42,6 @@ testQEMUSchemaGetLatest(const char* arch);
|
|||||||
|
|
||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
testQEMUSchemaLoadLatest(const char *arch);
|
testQEMUSchemaLoadLatest(const char *arch);
|
||||||
|
|
||||||
|
virHashTablePtr
|
||||||
|
testQEMUSchemaLoad(const char *filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user