From patchwork Thu Oct 1 17:24:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 525253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 16B12140D6E for ; Fri, 2 Oct 2015 04:32:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=0pFOZ3eo; dkim-atps=neutral Received: from localhost ([::1]:55169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhieo-00079O-5Z for incoming@patchwork.ozlabs.org; Thu, 01 Oct 2015 14:32:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhhbl-0000Al-EX for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:25:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zhhbi-0001H6-9v for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:25:29 -0400 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]:35458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhhbi-0001Gf-5e for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:25:26 -0400 Received: by qgt47 with SMTP id 47so73394351qgt.2 for ; Thu, 01 Oct 2015 10:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=5M0U5ZSC7jX6ZSvFgBVSg3WhBm7fmCkJn1pFSUQDGLE=; b=0pFOZ3eoOw6/PTRsRUsbzgAcoy78AqNRneAbU4OLXriYCjKUxx3Pn3AeWF2ohW7hAf 4AFbJDYHoGVjd3QN77uo7jhSFQqotUlAaSpU98sAocWjYbALlj5OrihTEBYfg+/8slZD ifL3OlHRQKAWgEz4GBcG18CGGjMkbWwgMCnzFqbStUdaJ/HzHjvkgBEnr75k11trwN5i LXOBwhQ7TNladqU7x4bi8K6SgDS5TLM15BbMj/ekS4akuaGtrBxft6EA+aTlNQn9RwjB 8NoZFQWC8Ak5o/Udh8zTJVQ71Unhnye8eVbQlzJqHZJBbmIvIHQsmtULB+D5OtGLQTO9 ev7Q== X-Received: by 10.140.97.136 with SMTP id m8mr13697788qge.74.1443720325917; Thu, 01 Oct 2015 10:25:25 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id o65sm2787857qhb.21.2015.10.01.10.25.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 10:25:25 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Thu, 1 Oct 2015 19:24:08 +0200 Message-Id: <1443720248-15482-25-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443720248-15482-1-git-send-email-marcandre.lureau@redhat.com> References: <1443720248-15482-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::229 Cc: haifeng.lin@huawei.com, mst@redhat.com, thibaut.collet@6wind.com, jasowang@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH v7 24/24] vhost-user-test: check ownership during migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Marc-André Lureau Check that backend source and destination do not have simultaneous ownership during migration. Signed-off-by: Marc-André Lureau --- 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 *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);