aboutsummaryrefslogtreecommitdiff
path: root/tests/vhost-user-test.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2015-10-09 17:17:40 +0200
committerMichael S. Tsirkin <mst@redhat.com>2015-10-22 14:34:50 +0300
commit1d9edff78fa0b294d6084df76da89e20ee93fdab (patch)
tree3097842a37def287e54b17f71b2e4382093e5be4 /tests/vhost-user-test.c
parentb181974724e106c62e4d0ecbe085df09b8a482bb (diff)
vhost-user-test: check ownership during migration
Check that backend source and destination do not have simultaneous ownership during migration. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
Diffstat (limited to 'tests/vhost-user-test.c')
-rw-r--r--tests/vhost-user-test.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index ef22e3e0c5..a74c934cc0 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 *buf, int size)
g_cond_signal(&s->data_cond);
break;
+ case VHOST_USER_RESET_DEVICE:
+ s->fds_num = 0;
+ break;
+
default:
break;
}
@@ -461,12 +465,37 @@ static guint64 get_log_size(TestServer *s)
return log_size;
}
+typedef struct TestMigrateSource {
+ GSource source;
+ TestServer *src;
+ TestServer *dest;
+} TestMigrateSource;
+
+static gboolean
+test_migrate_source_check(GSource *source)
+{
+ TestMigrateSource *t = (TestMigrateSource *)source;
+ gboolean overlap = t->src->fds_num > 0 && t->dest->fds_num > 0;
+
+ g_assert(!overlap);
+
+ return FALSE;
+}
+
+GSourceFuncs test_migrate_source_funcs = {
+ NULL,
+ test_migrate_source_check,
+ NULL,
+ NULL
+};
+
static void test_migrate(void)
{
TestServer *s = test_server_new("src");
TestServer *dest = test_server_new("dest");
const char *uri = "tcp:127.0.0.1:1234";
QTestState *global = global_qtest, *from, *to;
+ GSource *source;
gchar *cmd;
QDict *rsp;
guint8 *log;
@@ -484,6 +513,12 @@ static void test_migrate(void)
to = qtest_init(cmd);
g_free(cmd);
+ source = g_source_new(&test_migrate_source_funcs,
+ sizeof(TestMigrateSource));
+ ((TestMigrateSource *)source)->src = s;
+ ((TestMigrateSource *)source)->dest = 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 = qmp("{ 'execute': 'migrate_set_speed',"
@@ -522,6 +557,9 @@ static void test_migrate(void)
read_guest_mem(dest);
+ g_source_destroy(source);
+ g_source_unref(source);
+
qtest_quit(to);
test_server_free(dest);
qtest_quit(from);