diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-01-27 00:49:13 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-06-02 11:33:53 +0400 |
commit | 1ce2610c106d925387669b3133fc18ea986f0476 (patch) | |
tree | bd08c41941ea2235cabde4c02739f6ca52ff07d7 /tests | |
parent | a9b1ca38c2b1f062f22d4847e3b4c848d0fb84c3 (diff) |
char: make chr_fe_deinit() optionaly delete backend
This simplifies removing a backend for a frontend user (no need to
retrieve the associated driver and separate delete call etc).
NB: many frontends have questionable handling of ending a chardev. They
should probably delete the backend to prevent broken reusage.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-char.c | 22 | ||||
-rw-r--r-- | tests/vhost-user-test.c | 4 |
2 files changed, 9 insertions, 17 deletions
diff --git a/tests/test-char.c b/tests/test-char.c index d7ecf1056a..dfe856cb85 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -97,8 +97,7 @@ static void char_stdio_test_subprocess(void) ret = qemu_chr_fe_write(&be, (void *)"buf", 4); g_assert_cmpint(ret, ==, 4); - qemu_chr_fe_deinit(&be); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&be, true); } static void char_stdio_test(void) @@ -146,8 +145,7 @@ static void char_ringbuf_test(void) g_assert_cmpstr(data, ==, ""); g_free(data); - qemu_chr_fe_deinit(&be); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&be, true); /* check alias */ opts = qemu_opts_create(qemu_find_opts("chardev"), "memory-label", @@ -231,9 +229,8 @@ static void char_mux_test(void) g_assert_cmpint(strlen(data), !=, 0); g_free(data); - qemu_chr_fe_deinit(&chr_be1); - qemu_chr_fe_deinit(&chr_be2); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&chr_be1, false); + qemu_chr_fe_deinit(&chr_be2, true); } typedef struct SocketIdleData { @@ -396,8 +393,7 @@ static void char_pipe_test(void) g_assert_cmpint(fe.read_count, ==, 8); g_assert_cmpstr(fe.read_buf, ==, "pipe-in"); - qemu_chr_fe_deinit(&be); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&be, true); g_assert(g_unlink(in) == 0); g_assert(g_unlink(out) == 0); @@ -511,8 +507,7 @@ static void char_file_test(void) g_assert_cmpint(fe.read_count, ==, 8); g_assert_cmpstr(fe.read_buf, ==, "fifo-in"); - qemu_chr_fe_deinit(&be); - object_unref(OBJECT(chr)); + qemu_chr_fe_deinit(&be, true); g_unlink(fifo); g_free(fifo); } @@ -549,7 +544,7 @@ static void char_null_test(void) error_free_or_abort(&err); /* deinit & reinit */ - qemu_chr_fe_deinit(&be); + qemu_chr_fe_deinit(&be, false); qemu_chr_fe_init(&be, chr, &error_abort); qemu_chr_fe_set_open(&be, true); @@ -563,8 +558,7 @@ static void char_null_test(void) ret = qemu_chr_fe_write(&be, (void *)"buf", 4); g_assert_cmpint(ret, ==, 4); - qemu_chr_fe_deinit(&be); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&be, true); } static void char_invalid_test(void) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 4ca11ae28d..b3cc045765 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -488,10 +488,8 @@ static inline void test_server_connect(TestServer *server) static gboolean _test_server_free(TestServer *server) { int i; - Chardev *chr = qemu_chr_fe_get_driver(&server->chr); - qemu_chr_fe_deinit(&server->chr); - object_unparent(OBJECT(chr)); + qemu_chr_fe_deinit(&server->chr, true); for (i = 0; i < server->fds_num; i++) { close(server->fds[i]); |