From patchwork Tue Sep 29 16:34:53 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: 524567 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 D9D29140D6F for ; Thu, 1 Oct 2015 06:47:01 +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=tp3AS0Uy; dkim-atps=neutral Received: from localhost ([::1]:32956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhOHD-000507-PB for incoming@patchwork.ozlabs.org; Wed, 30 Sep 2015 16:46:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgxsr-0002Gx-OM for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgxsq-0004VV-Fn for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:36:05 -0400 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:34343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgxsq-0004VP-Aq for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:36:04 -0400 Received: by qgez77 with SMTP id z77so11093071qge.1 for ; Tue, 29 Sep 2015 09:36:04 -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=fPV5mXlAFUyXxepSuaG6mtKvMzCgI58nJjeLYXD/Lr8=; b=tp3AS0UyWX0V9pTtEaVVsCclhu8Qn3HXcZEf2GL2sBgN2lVMP8JRlbgIVi+c/QXDFF w3Kh360HaxtyWMoFSt6LZuEUSHb5Nfgq829AisUCFTu/DahGbT8/U6IHLgOi//ELxCcy 5894RpkpFn+M6O+88E9pfAnuplSW3OewDnkIcwlKf4uwKAtx65U0DmG1VisR9D9qrtLZ O/JGvNBM4+ADP9umDpCwQJgGBzrX4LAfqLevp5uwOr1XBEn+FghjKPC1CB6a9OK20SHx fSAMuBbVc/+YPKFJTWNkvRqL3dAjxKDrd+ikciALCToXk7vdtQZ+a2jaH37Q4rpJ6etj 4qWg== X-Received: by 10.140.152.134 with SMTP id 128mr20908171qhy.65.1443544564120; Tue, 29 Sep 2015 09:36:04 -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 d10sm9523405qhc.36.2015.09.29.09.36.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 09:36:03 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2015 18:34:53 +0200 Message-Id: <1443544494-28737-24-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443544494-28737-1-git-send-email-marcandre.lureau@redhat.com> References: <1443544494-28737-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::234 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 v6 23/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 7b5f130..56a24df 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -380,6 +380,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; } @@ -511,12 +515,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; @@ -534,6 +563,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'," @@ -572,6 +607,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);