qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 6/9] tests: extend qmp test with pereconfig c


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 6/9] tests: extend qmp test with pereconfig checks
Date: Tue, 27 Feb 2018 16:13:20 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/16/2018 06:37 AM, Igor Mammedov wrote:

In the subject line: s/pereconfig/preconfig/

Add permission checks for commands in 'preconfig' state.

It should work for all targets, but won't work with
machine 'none' as it's limited to -smp 1 only.
So use PC machine for testing preconfig and 'runstate'
parameter.

Signed-off-by: Igor Mammedov <address@hidden>
---
  tests/qmp-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 49 insertions(+)


+static bool is_err(QDict *rsp)
+{
+    const char *desc = NULL;
+    QDict *error = qdict_get_qdict(rsp, "error");
+    if (error) {
+        desc = qdict_get_try_str(error, "desc");
+    }
+    QDECREF(rsp);
+    return !!desc;

Wait, so this returns false if this was an error but without a valid desc?

+}
+
+static void test_qmp_preconfig(void)
+{
+    QDict *rsp, *ret;
+    QTestState *qs = qtest_startf("-nodefaults -preconfig -smp 2");
+
+    /* preconfig state */
+    /* enabled commands, no error expected  */
+    g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }")));
+
+    /* forbidden commands, expected error */
+    g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }")));

Does introspection show which commands are valid in preconfig state? That may be useful information for a client to know.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]