From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoqdK-000714-06 for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoqdF-0006gh-Vf for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:28:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoqdF-0006g7-PV for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:28:33 -0400 Date: Wed, 21 Oct 2015 13:28:28 +0300 From: "Michael S. Tsirkin" Message-ID: <1445423133-5119-34-git-send-email-mst@redhat.com> References: <1445423133-5119-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1445423133-5119-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 33/38] vhost-user-test: check ownership during migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Yuanhan Liu , Thibaut Collet , Gonglei , =?us-ascii?B?PT9VVEYtOD9xP01hcmMtQW5kcj1DMz1BOT0yMEx1cmVhdT89?= , Paolo Bonzini From: Marc-Andr=E9 Lureau Check that backend source and destination do not have simultaneous ownership during migration. Signed-off-by: Marc-Andr=E9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Thibaut Collet --- tests/vhost-user-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index ef22e3e..a74c934 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -307,6 +307,10 @@ static void chr_read(void *opaque, const uint8_t *bu= f, int size) g_cond_signal(&s->data_cond); break; =20 + case VHOST_USER_RESET_DEVICE: + s->fds_num =3D 0; + break; + default: break; } @@ -461,12 +465,37 @@ static guint64 get_log_size(TestServer *s) return log_size; } =20 +typedef struct TestMigrateSource { + GSource source; + TestServer *src; + TestServer *dest; +} TestMigrateSource; + +static gboolean +test_migrate_source_check(GSource *source) +{ + TestMigrateSource *t =3D (TestMigrateSource *)source; + gboolean overlap =3D t->src->fds_num > 0 && t->dest->fds_num > 0; + + g_assert(!overlap); + + return FALSE; +} + +GSourceFuncs test_migrate_source_funcs =3D { + NULL, + test_migrate_source_check, + NULL, + NULL +}; + static void test_migrate(void) { TestServer *s =3D test_server_new("src"); TestServer *dest =3D test_server_new("dest"); const char *uri =3D "tcp:127.0.0.1:1234"; QTestState *global =3D global_qtest, *from, *to; + GSource *source; gchar *cmd; QDict *rsp; guint8 *log; @@ -484,6 +513,12 @@ static void test_migrate(void) to =3D qtest_init(cmd); g_free(cmd); =20 + source =3D g_source_new(&test_migrate_source_funcs, + sizeof(TestMigrateSource)); + ((TestMigrateSource *)source)->src =3D s; + ((TestMigrateSource *)source)->dest =3D dest; + g_source_attach(source, NULL); + /* slow down migration to have time to fiddle with log */ /* TODO: qtest could learn to break on some places */ rsp =3D qmp("{ 'execute': 'migrate_set_speed'," @@ -522,6 +557,9 @@ static void test_migrate(void) =20 read_guest_mem(dest); =20 + g_source_destroy(source); + g_source_unref(source); + qtest_quit(to); test_server_free(dest); qtest_quit(from); --=20 MST