qapi patches for 2018-03-12, 2.12-rc1

- Peter Xu: 0/4 Turn OOB off for 2.12-rc1, revert OOB tests
 - Eric Blake: qapi: Force UTF8 encoding when parsing qapi files
 -----BEGIN PGP SIGNATURE-----
 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
 
 iQEcBAABCAAGBQJatTr1AAoJEKeha0olJ0Nq8MsH/1fFRjQcdx8BnGGZif4Cl0W5
 HlYRNh0VSpdaCyz49o2RQ0bpa01aap7bwYPrd40US2oMWz/CjOhzsot2gKCcp7qA
 CFa/pYlb/TFSaCSRm505a76tu+2eR+Co0LQgl+eFeo88cp1qOvSZG0RZhXDbXs+K
 ozR0cDqxNyhDUJLF52pOvergS1bPFG90f+y6x3zTTy6LCRTRNudI5U18iLrrqGzU
 3UhIZt+LD3c4Ly+quOUrhQ83bBRTXGZWrnN2Aim0wFUi3U4OK2JCBCB9WAFr3hxD
 KvZH3yrGwCOzuxO5W9OrKbODNr0cKiqd8gX/JWqwAuOn/WhhALdZz4kD4yiG1Yo=
 =j7Wi
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ericb/tags/pull-qapi-2018-03-23' into staging

qapi patches for 2018-03-12, 2.12-rc1

- Peter Xu: 0/4 Turn OOB off for 2.12-rc1, revert OOB tests
- Eric Blake: qapi: Force UTF8 encoding when parsing qapi files

# gpg: Signature made Fri 23 Mar 2018 17:35:49 GMT
# gpg:                using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-qapi-2018-03-23:
  qapi: Force UTF8 encoding when parsing qapi files
  Revert "monitor: enable IO thread for (qmp & !mux) typed"
  Revert "tests: qmp-test: verify command batching"
  Revert "tests: qmp-test: add oob test"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-03-23 17:41:56 +00:00
commit 66793daa03
3 changed files with 5 additions and 103 deletions

View File

@ -36,7 +36,6 @@
#include "net/slirp.h"
#include "chardev/char-fe.h"
#include "chardev/char-io.h"
#include "chardev/char-mux.h"
#include "ui/qemu-spice.h"
#include "sysemu/numa.h"
#include "monitor/monitor.h"
@ -4537,10 +4536,8 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
void monitor_init(Chardev *chr, int flags)
{
Monitor *mon = g_malloc(sizeof(*mon));
/* Enable IOThread for QMPs that are not using MUX chardev backends. */
bool use_io_thr = (!CHARDEV_IS_MUX(chr)) && (flags & MONITOR_USE_CONTROL);
monitor_data_init(mon, false, use_io_thr);
monitor_data_init(mon, false, false);
qemu_chr_fe_init(&mon->chr, chr, &error_abort);
mon->flags = flags;

View File

@ -669,13 +669,13 @@ tests/test-qapi-events.c tests/test-qapi-events.h \
tests/test-qapi-introspect.c tests/test-qapi-introspect.h: \
tests/test-qapi-gen-timestamp ;
tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-gen.py \
-o tests -p "test-" $<, \
"GEN","$(@:%-timestamp=%)")
@>$@
tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(qapi-py)
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-gen.py \
-o tests/qapi-schema -p "doc-good-" $<, \
"GEN","$@")
@mv tests/qapi-schema/doc-good-qapi-doc.texi $@
@ -927,7 +927,7 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF)
.PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
$(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
$(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \
$(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
$(PYTHON_UTF8) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
$^ >$*.test.out 2>$*.test.err; \
echo $$? >$*.test.exit, \
"TEST","$*.out")

View File

@ -80,9 +80,6 @@ static void test_qmp_protocol(void)
QDict *resp, *q, *ret;
QList *capabilities;
QTestState *qts;
const QListEntry *entry;
QString *qstr;
int i;
qts = qtest_init_without_qmp_handshake(common_args);
@ -92,13 +89,7 @@ static void test_qmp_protocol(void)
g_assert(q);
test_version(qdict_get(q, "version"));
capabilities = qdict_get_qlist(q, "capabilities");
g_assert(capabilities);
entry = qlist_first(capabilities);
g_assert(entry);
qstr = qobject_to(QString, entry->value);
g_assert(qstr);
g_assert_cmpstr(qstring_get_str(qstr), ==, "oob");
QDECREF(resp);
g_assert(capabilities && qlist_empty(capabilities));
/* Test valid command before handshake */
resp = qtest_qmp(qts, "{ 'execute': 'query-version' }");
@ -140,94 +131,9 @@ static void test_qmp_protocol(void)
g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
QDECREF(resp);
/*
* Test command batching. In current test OOB is not enabled, we
* should be able to run as many commands in batch as we like.
* Using 16 (>8, which is OOB queue length) to make sure OOB won't
* break existing clients. Note: this test does not control the
* scheduling of QEMU's QMP command processing threads so it may
* not really trigger batching inside QEMU. This is just a
* best-effort test.
*/
for (i = 0; i < 16; i++) {
qtest_async_qmp(qts, "{ 'execute': 'query-version' }");
}
/* Verify the replies to make sure no command is dropped. */
for (i = 0; i < 16; i++) {
resp = qtest_qmp_receive(qts);
/* It should never be dropped. Each of them should be a reply. */
g_assert(qdict_haskey(resp, "return"));
g_assert(!qdict_haskey(resp, "event"));
QDECREF(resp);
}
qtest_quit(qts);
}
/* Tests for Out-Of-Band support. */
static void test_qmp_oob(void)
{
QDict *resp;
int acks = 0;
const char *cmd_id;
global_qtest = qtest_init_without_qmp_handshake(common_args);
/* Ignore the greeting message. */
resp = qmp_receive();
g_assert(qdict_get_qdict(resp, "QMP"));
QDECREF(resp);
/* Try a fake capability, it should fail. */
resp = qmp("{ 'execute': 'qmp_capabilities', "
" 'arguments': { 'enable': [ 'cap-does-not-exist' ] } }");
g_assert(qdict_haskey(resp, "error"));
QDECREF(resp);
/* Now, enable OOB in current QMP session, it should succeed. */
resp = qmp("{ 'execute': 'qmp_capabilities', "
" 'arguments': { 'enable': [ 'oob' ] } }");
g_assert(qdict_haskey(resp, "return"));
QDECREF(resp);
/*
* Try any command that does not support OOB but with OOB flag. We
* should get failure.
*/
resp = qmp("{ 'execute': 'query-cpus',"
" 'control': { 'run-oob': true } }");
g_assert(qdict_haskey(resp, "error"));
QDECREF(resp);
/*
* First send the "x-oob-test" command with lock=true and
* oob=false, it should hang the dispatcher and main thread;
* later, we send another lock=false with oob=true to continue
* that thread processing. Finally we should receive replies from
* both commands.
*/
qmp_async("{ 'execute': 'x-oob-test',"
" 'arguments': { 'lock': true }, "
" 'id': 'lock-cmd'}");
qmp_async("{ 'execute': 'x-oob-test', "
" 'arguments': { 'lock': false }, "
" 'control': { 'run-oob': true }, "
" 'id': 'unlock-cmd' }");
/* Ignore all events. Wait for 2 acks */
while (acks < 2) {
resp = qmp_receive();
cmd_id = qdict_get_str(resp, "id");
if (!g_strcmp0(cmd_id, "lock-cmd") ||
!g_strcmp0(cmd_id, "unlock-cmd")) {
acks++;
}
QDECREF(resp);
}
qtest_end();
}
static int query_error_class(const char *cmd)
{
static struct {
@ -412,7 +318,6 @@ int main(int argc, char *argv[])
g_test_init(&argc, &argv, NULL);
qtest_add_func("qmp/protocol", test_qmp_protocol);
qtest_add_func("qmp/oob", test_qmp_oob);
qmp_schema_init(&schema);
add_query_tests(&schema);