From b5f8431040549da931b31892cbbde73b8724ff48 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 3 Jul 2018 10:53:34 +0200 Subject: tests/test-qga: Demonstrate the guest-agent ignores "id" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-9-armbru@redhat.com> --- tests/test-qga.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test-qga.c') diff --git a/tests/test-qga.c b/tests/test-qga.c index 30c9643..6b632e3 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -227,6 +227,25 @@ static void test_qga_ping(gconstpointer fix) qobject_unref(ret); } +static void test_qga_invalid_id(gconstpointer fix) +{ + /* + * FIXME "id" is ignored; it should either be repeated in the + * reply, or rejected on input + */ + const TestFixture *fixture = fix; + QDict *ret, *val; + + ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + val = qdict_get_qdict(ret, "return"); + g_assert(!qdict_haskey(val, "id")); + + qobject_unref(ret); +} + static void test_qga_invalid_args(gconstpointer fix) { const TestFixture *fixture = fix; @@ -934,6 +953,7 @@ int main(int argc, char **argv) g_test_add_data_func("/qga/file-ops", &fix, test_qga_file_ops); g_test_add_data_func("/qga/file-write-read", &fix, test_qga_file_write_read); g_test_add_data_func("/qga/get-time", &fix, test_qga_get_time); + g_test_add_data_func("/qga/invalid-id", &fix, test_qga_invalid_id); g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd); g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args); g_test_add_data_func("/qga/fsfreeze-status", &fix, -- cgit v1.1 From 0fa39d0b0374b983535de8591e5e561401d1d5c6 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 3 Jul 2018 10:53:35 +0200 Subject: qmp qemu-ga: Revert change that accidentally made qemu-ga accept "id" Commit cf869d53172 "qmp: support out-of-band (oob) execution" changed how we check "id": Note that in the patch I exported qmp_dispatch_check_obj() to be used to check the request earlier, and at the same time allowed "id" field to be there since actually we always allow that. The part after "and" is ill-advised: it makes qemu-ga accept and ignore "id". Revert. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-10-armbru@redhat.com> --- tests/test-qga.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tests/test-qga.c') diff --git a/tests/test-qga.c b/tests/test-qga.c index 6b632e3..564a459 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -229,19 +229,16 @@ static void test_qga_ping(gconstpointer fix) static void test_qga_invalid_id(gconstpointer fix) { - /* - * FIXME "id" is ignored; it should either be repeated in the - * reply, or rejected on input - */ const TestFixture *fixture = fix; - QDict *ret, *val; + QDict *ret, *error; + const char *class; ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}"); g_assert_nonnull(ret); - qmp_assert_no_error(ret); - val = qdict_get_qdict(ret, "return"); - g_assert(!qdict_haskey(val, "id")); + error = qdict_get_qdict(ret, "error"); + class = qdict_get_try_str(error, "class"); + g_assert_cmpstr(class, ==, "GenericError"); qobject_unref(ret); } -- cgit v1.1 From d4d7ed731ce47d10ea2a17d663cec42fc0c7d925 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 3 Jul 2018 10:53:36 +0200 Subject: tests/test-qga: Demonstrate the guest-agent ignores "control" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-11-armbru@redhat.com> --- tests/test-qga.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/test-qga.c') diff --git a/tests/test-qga.c b/tests/test-qga.c index 564a459..2e9e0f7 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -243,6 +243,22 @@ static void test_qga_invalid_id(gconstpointer fix) qobject_unref(ret); } +static void test_qga_invalid_oob(gconstpointer fix) +{ + /* FIXME "control" is ignored; it should be rejected */ + const TestFixture *fixture = fix; + QDict *ret; + + ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping'," + " 'control': {'run-oob': true}}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + qdict_get_qdict(ret, "return"); + + qobject_unref(ret); +} + static void test_qga_invalid_args(gconstpointer fix) { const TestFixture *fixture = fix; @@ -951,6 +967,7 @@ int main(int argc, char **argv) g_test_add_data_func("/qga/file-write-read", &fix, test_qga_file_write_read); g_test_add_data_func("/qga/get-time", &fix, test_qga_get_time); g_test_add_data_func("/qga/invalid-id", &fix, test_qga_invalid_id); + g_test_add_data_func("/qga/invalid-oob", &fix, test_qga_invalid_oob); g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd); g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args); g_test_add_data_func("/qga/fsfreeze-status", &fix, -- cgit v1.1 From 674ed7228f03150d15703961ea2a59cd744f3beb Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 3 Jul 2018 10:53:37 +0200 Subject: qmp qemu-ga: Fix qemu-ga not to accept "control" Commit cf869d53172 "qmp: support out-of-band (oob) execution" accidentally made qemu-ga accept and ignore "control". Fix that. Out-of-band execution in a monitor that doesn't support it now fails with {"error": {"class": "GenericError", "desc": "QMP input member 'control' is unexpected"}} instead of {"error": {"class": "GenericError", "desc": "Please enable out-of-band first for the session during capabilities negotiation"}} The old description is suboptimal when out-of-band cannot not be enabled, or the command doesn't support out-of-band execution. The new description is a bit unspecific, but it'll do. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-12-armbru@redhat.com> --- tests/test-qga.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/test-qga.c') diff --git a/tests/test-qga.c b/tests/test-qga.c index 2e9e0f7..febabc7 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -245,16 +245,17 @@ static void test_qga_invalid_id(gconstpointer fix) static void test_qga_invalid_oob(gconstpointer fix) { - /* FIXME "control" is ignored; it should be rejected */ const TestFixture *fixture = fix; - QDict *ret; + QDict *ret, *error; + const char *class; ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping'," " 'control': {'run-oob': true}}"); g_assert_nonnull(ret); - qmp_assert_no_error(ret); - qdict_get_qdict(ret, "return"); + error = qdict_get_qdict(ret, "error"); + class = qdict_get_try_str(error, "class"); + g_assert_cmpstr(class, ==, "GenericError"); qobject_unref(ret); } -- cgit v1.1 From 00ecec151d2323e742af94cccf2de77025f3c0c1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 3 Jul 2018 10:53:38 +0200 Subject: qmp: Redo how the client requests out-of-band execution Commit cf869d53172 "qmp: support out-of-band (oob) execution" added a general mechanism for command-independent arguments just for an out-of-band flag: The "control" key is introduced to store this extra flag. "control" field is used to store arguments that are shared by all the commands, rather than command specific arguments. Let "run-oob" be the first. However, it failed to reject unknown members of "control". For instance, in QMP command {"execute": "query-name", "id": 42, "control": {"crap": true}} "crap" gets silently ignored. Instead of fixing this, revert the general "control" mechanism (because YAGNI), and do it the way I initially proposed, with key "exec-oob". Simpler code, simpler interface. An out-of-band command {"execute": "migrate-pause", "id": 42, "control": {"run-oob": true}} becomes {"exec-oob": "migrate-pause", "id": 42} Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-13-armbru@redhat.com> [Commit message typo fixed] --- tests/test-qga.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/test-qga.c') diff --git a/tests/test-qga.c b/tests/test-qga.c index febabc7..daadf22 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -249,8 +249,7 @@ static void test_qga_invalid_oob(gconstpointer fix) QDict *ret, *error; const char *class; - ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping'," - " 'control': {'run-oob': true}}"); + ret = qmp_fd(fixture->fd, "{'exec-oob': 'guest-ping'}"); g_assert_nonnull(ret); error = qdict_get_qdict(ret, "error"); -- cgit v1.1