代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 740581f96fa4007d6549e82131a9ef48a6478149 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 4 Mar 2020 10:22:19 +0100
Subject: [PATCH 14/18] testutilsqemuschema: Introduce
testQEMUSchemaValidateCommand
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The new helper splits out all steps necessary to validate a QMP command
against the schema.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/testutilsqemuschema.c | 44 +++++++++++++++++++++++++++++++++++++
tests/testutilsqemuschema.h | 6 +++++
2 files changed, 50 insertions(+)
diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c
index 7b82ff27b2..fe8501f3a0 100644
--- a/tests/testutilsqemuschema.c
+++ b/tests/testutilsqemuschema.c
@@ -517,6 +517,50 @@ testQEMUSchemaValidate(virJSONValuePtr obj,
}
+/**
+ * testQEMUSchemaValidateCommand:
+ * @command: command to validate
+ * @arguments: arguments of @command to validate
+ * @schema: hash table containing schema entries
+ * @debug: a virBuffer which will be filled with debug information if provided
+ *
+ * Validates whether @command and its @arguments conform to the QAPI schema
+ * passed in via @schema. Returns 0, if the command and args match @schema,
+ * -1 if it does not and -2 if there is a problem with the schema or with
+ * internals.
+ *
+ * @debug is filled with information regarding the validation process
+ */
+int
+testQEMUSchemaValidateCommand(const char *command,
+ virJSONValuePtr arguments,
+ virHashTablePtr schema,
+ virBufferPtr debug)
+{
+ g_autofree char *schemapatharguments = g_strdup_printf("%s/arg-type", command);
+ g_autoptr(virJSONValue) emptyargs = NULL;
+ virJSONValuePtr schemarootcommand;
+ virJSONValuePtr schemarootarguments;
+
+ if (virQEMUQAPISchemaPathGet(command, schema, &schemarootcommand) < 0 ||
+ !schemarootcommand) {
+ virBufferAsprintf(debug, "ERROR: command '%s' not found in the schema", command);
+ return -1;
+ }
+
+ if (!arguments)
+ arguments = emptyargs = virJSONValueNewObject();
+
+ if (virQEMUQAPISchemaPathGet(schemapatharguments, schema, &schemarootarguments) < 0 ||
+ !schemarootarguments) {
+ virBufferAsprintf(debug, "ERROR: failed to look up 'arg-type' of '%s'", command);
+ return -1;
+ }
+
+ return testQEMUSchemaValidateRecurse(arguments, schemarootarguments, schema, debug);
+}
+
+
/**
* testQEMUSchemaGetLatest:
*
diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h
index 84ee9a9670..e3a375b038 100644
--- a/tests/testutilsqemuschema.h
+++ b/tests/testutilsqemuschema.h
@@ -28,6 +28,12 @@ testQEMUSchemaValidate(virJSONValuePtr obj,
virHashTablePtr schema,
virBufferPtr debug);
+int
+testQEMUSchemaValidateCommand(const char *command,
+ virJSONValuePtr arguments,
+ virHashTablePtr schema,
+ virBufferPtr debug);
+
virJSONValuePtr
testQEMUSchemaGetLatest(const char* arch);
--
2.23.0.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。