qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code

Back when the test was introduced, in commit 62c39b307, the
test was set up to run qemu-ga directly on the host performing
the test, and defaults to limiting itself to safe commands. At
the time, it was envisioned that setting QGA_TEST_SIDE_EFFECTING
in the environment could cover a few more commands, while noting
the potential danger of those side effects running in the host.

But this has NEVER been tested: if you enable the environment
variable, the test WILL fail. One obvious reason: if you are not
running as root, you'll probably get a permission failure when
trying to freeze the file systems, or when changing system time.
Less obvious: if you run the test as root (wow, you're brave), you
could end up hanging if the test tries to log things to a
temporarily frozen filesystem. But the cutest reason of all: if
you get past the above hurdles, the test uses invalid JSON in
test_qga_fstrim() (missing '' around the dictionary key 'minimum'),
and will thus fail an assertion in qmp_fd().

Rather than leave this untested time-bomb in place, rip it out.
Hopefully, as originally envisioned, we can find an opportunity
to test an actual sandboxed guest where the guest-agent has
full permissions and will not unduly affect the host running
the test - if so, 'git revert' can be used if desired, for
salvaging any useful parts of this attempt.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>

authored by

Eric Blake and committed by
Thomas Huth
f94b3f64 4446158a

-90
-90
tests/test-qga.c
··· 642 642 QDECREF(ret); 643 643 } 644 644 645 - static void test_qga_set_time(gconstpointer fix) 646 - { 647 - const TestFixture *fixture = fix; 648 - QDict *ret; 649 - int64_t current, time; 650 - gchar *cmd; 651 - 652 - /* get current time */ 653 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}"); 654 - g_assert_nonnull(ret); 655 - qmp_assert_no_error(ret); 656 - current = qdict_get_int(ret, "return"); 657 - g_assert_cmpint(current, >, 0); 658 - QDECREF(ret); 659 - 660 - /* set some old time */ 661 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-set-time'," 662 - " 'arguments': { 'time': 1000 } }"); 663 - g_assert_nonnull(ret); 664 - qmp_assert_no_error(ret); 665 - QDECREF(ret); 666 - 667 - /* check old time */ 668 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}"); 669 - g_assert_nonnull(ret); 670 - qmp_assert_no_error(ret); 671 - time = qdict_get_int(ret, "return"); 672 - g_assert_cmpint(time / 1000, <, G_USEC_PER_SEC * 10); 673 - QDECREF(ret); 674 - 675 - /* set back current time */ 676 - cmd = g_strdup_printf("{'execute': 'guest-set-time'," 677 - " 'arguments': { 'time': %" PRId64 " } }", 678 - current + time * 1000); 679 - ret = qmp_fd(fixture->fd, cmd); 680 - g_free(cmd); 681 - g_assert_nonnull(ret); 682 - qmp_assert_no_error(ret); 683 - QDECREF(ret); 684 - } 685 - 686 - static void test_qga_fstrim(gconstpointer fix) 687 - { 688 - const TestFixture *fixture = fix; 689 - QDict *ret; 690 - QList *list; 691 - const QListEntry *entry; 692 - 693 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-fstrim'," 694 - " arguments: { minimum: 4194304 } }"); 695 - g_assert_nonnull(ret); 696 - qmp_assert_no_error(ret); 697 - list = qdict_get_qlist(ret, "return"); 698 - entry = qlist_first(list); 699 - g_assert(qdict_haskey(qobject_to_qdict(entry->value), "paths")); 700 - 701 - QDECREF(ret); 702 - } 703 - 704 645 static void test_qga_blacklist(gconstpointer data) 705 646 { 706 647 TestFixture fix; ··· 828 769 status = qdict_get_try_str(ret, "return"); 829 770 g_assert_cmpstr(status, ==, "thawed"); 830 771 831 - QDECREF(ret); 832 - } 833 - 834 - static void test_qga_fsfreeze_and_thaw(gconstpointer fix) 835 - { 836 - const TestFixture *fixture = fix; 837 - QDict *ret; 838 - const gchar *status; 839 - 840 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-freeze'}"); 841 - g_assert_nonnull(ret); 842 - qmp_assert_no_error(ret); 843 - QDECREF(ret); 844 - 845 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-status'}"); 846 - g_assert_nonnull(ret); 847 - qmp_assert_no_error(ret); 848 - status = qdict_get_try_str(ret, "return"); 849 - g_assert_cmpstr(status, ==, "frozen"); 850 - QDECREF(ret); 851 - 852 - ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-thaw'}"); 853 - g_assert_nonnull(ret); 854 - qmp_assert_no_error(ret); 855 772 QDECREF(ret); 856 773 } 857 774 ··· 1028 945 test_qga_guest_exec_invalid); 1029 946 g_test_add_data_func("/qga/guest-get-osinfo", &fix, 1030 947 test_qga_guest_get_osinfo); 1031 - 1032 - if (g_getenv("QGA_TEST_SIDE_EFFECTING")) { 1033 - g_test_add_data_func("/qga/fsfreeze-and-thaw", &fix, 1034 - test_qga_fsfreeze_and_thaw); 1035 - g_test_add_data_func("/qga/set-time", &fix, test_qga_set_time); 1036 - g_test_add_data_func("/qga/fstrim", &fix, test_qga_fstrim); 1037 - } 1038 948 1039 949 ret = g_test_run(); 1040 950