qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Yuanhan Liu" <yuanhan.liu@linux.intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=
	<marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 24/25] vhost-user-test: check ownership during migration
Date: Fri, 9 Oct 2015 00:18:24 +0300	[thread overview]
Message-ID: <1444338957-15293-25-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1444338957-15293-1-git-send-email-mst@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

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>
---
 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);
-- 
MST

  parent reply	other threads:[~2015-10-08 21:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 21:16 [Qemu-devel] [PULL 00/25] virtio,pc features, fixes Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 01/25] configure: probe for memfd Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 02/25] linux-headers: add unistd.h Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 03/25] util: add linux-only memfd fallback Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 04/25] util: add memfd helpers Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 05/25] util: add fallback for qemu_memfd_alloc() Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 06/25] vhost: document log resizing Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 07/25] vhost: add vhost_set_log_base op Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 08/25] vhost-user: add vhost_user_requires_shm_log() Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 09/25] vhost: alloc shareable log Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 10/25] vhost-user: send log shm fd along with log_base Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 11/25] vhost-user: add a migration blocker Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 12/25] vhost: use a function for each call Michael S. Tsirkin
2015-10-09  6:40   ` Thibaut Collet
2015-10-09  7:37     ` Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 13/25] vhost-user: document migration log Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 14/25] net: add trace_vhost_user_event Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 15/25] vhost user: add support of live migration Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 16/25] vhost user: add rarp sending after live migration for legacy guest Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 17/25] vhost-user: use an enum helper for features mask Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 18/25] vhost: add migration block if memfd failed Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 19/25] vhost-user-test: move wait_for_fds() out Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 20/25] vhost-user-test: remove useless static check Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 21/25] vhost-user-test: wrap server in TestServer struct Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 22/25] vhost-user-test: learn to tweak various qemu arguments Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 23/25] vhost-user-test: add live-migration test Michael S. Tsirkin
2015-10-08 21:18 ` Michael S. Tsirkin [this message]
2015-10-08 21:18 ` [Qemu-devel] [PULL 25/25] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
2015-10-09 11:05 ` [Qemu-devel] [PULL 00/25] virtio,pc features, fixes Peter Maydell
2015-10-09 11:09   ` Peter Maydell
2015-10-09 13:10     ` Eduardo Otubo
2015-10-09 13:37   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444338957-15293-25-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yuanhan.liu@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).