All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration
@ 2019-01-30 12:06 Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 1/4] tests: Add migration xbzrle test Juan Quintela
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Juan Quintela @ 2019-01-30 12:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Eric Blake,
	Laurent Vivier, Juan Quintela, Dr. David Alan Gilbert,
	Paolo Bonzini

Iv v11:
- Rebase to lastest
- Remove the compress test.  It didin't worked really.
  See my next series.
- Only patch missing review-by is the second one.

Please, consider them.

In v10:
- rebase to latest upstream
- code changed quite a bit with qmp refactorings
  apllied them
- make it work again
- compress threads test, continue working there, not trivial.

Two question-:
- should we integrate them on this cycle?
  they are tests
- should we enable them only on baremetal, and not on emulation?
  There is still a problem on TCG that sometimes fails the migration
  thread

ToDo:
- Finish debug compress test
  Still stuck why the test wonk when I launch qemu by hand but not
  trough qtest.  Creatuve uses of launching gdb through launched
  guests have not help so far.

- Finish fd transport test
  Not very difficult in principle, need more checking to see if it
  don't fail in other setups.

- Finish tl trasport test
  I already knew that I hate certificates, but this is too much.  Trying
  to understand how to use them.

Please commet, Juan.

In v9:
- Dropp Export SocketAddress_to_str
  just create the functions where I need them.
- drop precopy test and xbzrle (on pull requset)
  Use 100M for cache as dave suggests
- drop ppc improvemnet (on pull request)
- drop RFH, will work on tha later
- move socket_address to info migrate

Please, review.

Later, Juan.

v8:
- just rebase to make things continue to wonk

New in the other v7:
- SocketAddress is now a list (a.k.a make happy danp)
- Rebase on top of upstream
  network listener is *interesting*
- *HACK* to make SocketAddress list in common
  see patch: create-socket-paramenter

Please review, Juan.

CC: berrange@redhat.com

[v7]
This is v6, it differest from the patches that I sent with previous
multifd post:
- Rename x-tcp-port to x-socket-address
  This is more *complicated* that it looks as:

  * it is a pointer, so I need to use QAPI_CLONE() to make info
    migrate work

  * this is an union of structs.  In QAPI. So, a dict of strings.  The
    only way that I was able to make things work is parsing the qdict
    to a SocketAddress and then output a SocketAddress as an str.  It
    needs to be an easier way, for sure.

  * Cleanups here andthere.

Please, review, Juan.

[v5]
- Several patches moved to pull request
- merge info_migrate and migration_tests
  only missing bit is tcp_port, needed for tcp tests
- Rename tcp-port to x-tcp-port
  We will get better naming from David at some point, and we will use that bit
- ppc: use inline code as suggested by lvivier

Please, review.

It is based on my previous pull request

Based-on: 20180129120932.12874-1-quintela@redhat.com

[v4]
- rebase on top on v4 info_migrate patches
- Tune sleeps to make patches fast
- Create a deprecated test for deprecated commands (i.e. make peterxu happy)
- create migrate_start_postcopy function
- fix naming/sizes between power and x86
- cleanup comments to match code

[v3]

- No more tests for deprecated parameters. Now I only use
  migrate_set_parameter.  If there is a deprecated command for that,
  we tests it there.
- free "result" string, always good to return memory (Peter found it)
- use the new tcp_port parameter from info migrate.  So we are
  handling well the tcp case.
- lots of code movement around to make everything consistent.
- Several patches already integrated upstream.

[v2]
- to make review easier, I started renaming postcopy-test.c to migration-test.c
- Did cleanups/refactoring there
- Don't use global-qtest anymore
- check that the parameters that we sent got really set
- RFH: comrpress threads tests is not working for some weird reason.  Using the same code on command line works.
  still investigating why.

ToDoo:

- tcp: after discussions with dave, we ended in conclusion that we
  need to use the 0 port and let the system gives us a free one

  But .... that means that we need to be able to get that port back somehow.
  "info migrate" woring on destination side?

- compression threads.  There is some weird interaction with the test
  hardness and every migration thread get waiting in a different
  semaphore.  Investigating if it is a race/bug/whateverr

- deprecated commands: There was a suggestion to make
  migrate_set_parameter look at the parameter name and test old/new
  depending on something.  Not sure what to do here.

- testing commands: Is there a way to launch qemu and just sent
  qmp/hmp commands without having to really run anything else?

[v1]
- add test for precopy for unix/tcp
  exec and fd to came, don't know how to test rdma without hardware
- add tests using deprecated interfaces
- add test for xbzrle
  Note to myself, there is no way to set the cache size with migraton_set_parameters
- Add test for compress threads
  disabled on the series, right now it appears that compression is not working at all
- Move postcopy to use new results
  Idea is to move it on top of migration-test.c, but first I want some reviews on basic idea

Juan Quintela (4):
  tests: Add migration xbzrle test
  migration: Create socket-address parameter
  tests: Add basic migration precopy tcp test
  tests: Add migration multifd test

 hmp.c                  |  31 ++++++
 migration/migration.c  |  24 +++++
 migration/migration.h  |   4 +
 migration/socket.c     |  11 ++
 qapi/migration.json    |   6 +-
 qapi/sockets.json      |  13 +++
 tests/migration-test.c | 224 ++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 307 insertions(+), 6 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v11 1/4] tests: Add migration xbzrle test
  2019-01-30 12:06 [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration Juan Quintela
@ 2019-01-30 12:06 ` Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter Juan Quintela
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Juan Quintela @ 2019-01-30 12:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Eric Blake,
	Laurent Vivier, Juan Quintela, Dr. David Alan Gilbert,
	Paolo Bonzini, Peter Xu

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 64 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 8352612364..b0670efde7 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -584,6 +584,17 @@ static void deprecated_set_speed(QTestState *who, long long value)
     migrate_check_parameter(who, "max-bandwidth", value);
 }
 
+static void deprecated_set_cache_size(QTestState *who, long long value)
+{
+    QDict *rsp;
+
+    rsp = qtest_qmp(who, "{ 'execute': 'migrate-set-cache-size',"
+                         "'arguments': { 'value': %lld } }", value);
+    g_assert(qdict_haskey(rsp, "return"));
+    qobject_unref(rsp);
+    migrate_check_parameter(who, "xbzrle-cache-size", value);
+}
+
 static void test_deprecated(void)
 {
     QTestState *from;
@@ -592,6 +603,7 @@ static void test_deprecated(void)
 
     deprecated_set_downtime(from, 0.12345);
     deprecated_set_speed(from, 12345);
+    deprecated_set_cache_size(from, 4096);
 
     qtest_quit(from);
 }
@@ -781,6 +793,57 @@ static void test_precopy_unix(void)
     g_free(uri);
 }
 
+static void test_xbzrle(const char *uri)
+{
+    QTestState *from, *to;
+
+    if (test_migrate_start(&from, &to, uri, false)) {
+        return;
+    }
+
+    /*
+     * We want to pick a speed slow enough that the test completes
+     * quickly, but that it doesn't complete precopy even on a slow
+     * machine, so also set the downtime.
+     */
+    /* 1 ms should make it not converge*/
+    migrate_set_parameter(from, "downtime-limit", 1);
+    /* 1GB/s */
+    migrate_set_parameter(from, "max-bandwidth", 1000000000);
+
+    migrate_set_parameter(from, "xbzrle-cache-size", 33554432);
+
+    migrate_set_capability(from, "xbzrle", "true");
+    migrate_set_capability(to, "xbzrle", "true");
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    migrate(from, uri, "{}");
+
+    wait_for_migration_pass(from);
+
+    /* 300ms should converge */
+    migrate_set_parameter(from, "downtime-limit", 300);
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to, true);
+}
+
+static void test_xbzrle_unix(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+
+    test_xbzrle(uri);
+    g_free(uri);
+}
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -832,6 +895,7 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/deprecated", test_deprecated);
     qtest_add_func("/migration/bad_dest", test_baddest);
     qtest_add_func("/migration/precopy/unix", test_precopy_unix);
+    qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix);
 
     ret = g_test_run();
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter
  2019-01-30 12:06 [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 1/4] tests: Add migration xbzrle test Juan Quintela
@ 2019-01-30 12:06 ` Juan Quintela
  2019-01-30 15:55   ` Eric Blake
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 3/4] tests: Add basic migration precopy tcp test Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 4/4] tests: Add migration multifd test Juan Quintela
  3 siblings, 1 reply; 8+ messages in thread
From: Juan Quintela @ 2019-01-30 12:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Eric Blake,
	Laurent Vivier, Juan Quintela, Dr. David Alan Gilbert,
	Paolo Bonzini

It will be used to store the uri parameters. We want this only for
tcp, so we don't set it for other uris.  We need it to know what port
is migration running.

Signed-off-by: Juan Quintela <quintela@redhat.com>

--

This used to be uri parameter, but it has so many troubles to
reproduce that it don't just make sense.

This used to be a port parameter.  I was asked to move to
SocketAddress, done.
I also merged the setting of the migration tcp port in this one
because now I need to free the address, and this makes it easier.
This used to be x-socket-address with a single direction, now it is a
list of addresses.
Move SocketAddress_to_str here.  I used to try to generalize the one
in chardev/char-socket.c, but it is not worth it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp.c                 | 31 +++++++++++++++++++++++++++++++
 migration/migration.c | 24 ++++++++++++++++++++++++
 migration/migration.h |  4 ++++
 migration/socket.c    | 11 +++++++++++
 qapi/migration.json   |  6 +++++-
 qapi/sockets.json     | 13 +++++++++++++
 6 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/hmp.c b/hmp.c
index b2a2b1f84e..95d5063e5d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -166,6 +166,26 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
     qapi_free_MouseInfoList(mice_list);
 }
 
+static char *SocketAddress_to_str(SocketAddress *addr)
+{
+    switch (addr->type) {
+    case SOCKET_ADDRESS_TYPE_INET:
+        return g_strdup_printf("tcp:%s:%s",
+                               addr->u.inet.host,
+                               addr->u.inet.port);
+        break;
+    case SOCKET_ADDRESS_TYPE_UNIX:
+        return g_strdup_printf("unix:%s",
+                               addr->u.q_unix.path);
+        break;
+    case SOCKET_ADDRESS_TYPE_FD:
+        return g_strdup_printf("fd:%s", addr->u.fd.str);
+        break;
+    default:
+        abort();
+    }
+}
+
 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
 {
     MigrationInfo *info;
@@ -306,6 +326,17 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
         g_free(str);
         visit_free(v);
     }
+    if (info->has_socket_address) {
+        SocketAddressList *addr;
+
+        monitor_printf(mon, "socket address: [\n");
+
+        for (addr = info->socket_address; addr; addr = addr->next) {
+            char *s = SocketAddress_to_str(addr->value);
+            monitor_printf(mon, "\t%s\n", s);
+        }
+        monitor_printf(mon, "]\n");
+    }
     qapi_free_MigrationInfo(info);
     qapi_free_MigrationCapabilityStatusList(caps);
 }
diff --git a/migration/migration.c b/migration/migration.c
index 37e06b76dc..ef1d53cde2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -31,6 +31,8 @@
 #include "migration/vmstate.h"
 #include "block/block.h"
 #include "qapi/error.h"
+#include "qapi/clone-visitor.h"
+#include "qapi/qapi-visit-sockets.h"
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-events-migration.h"
 #include "qapi/qmp/qerror.h"
@@ -197,6 +199,11 @@ void migration_incoming_state_destroy(void)
     }
 
     qemu_event_reset(&mis->main_thread_load_event);
+
+    if (mis->socket_address) {
+        qapi_free_SocketAddressList(mis->socket_address);
+        mis->socket_address = NULL;
+    }
 }
 
 static void migrate_generate_event(int new_state)
@@ -312,6 +319,17 @@ void migration_incoming_enable_colo(void)
     migration_colo_enabled = true;
 }
 
+void migrate_add_address(SocketAddress *address)
+{
+    MigrationIncomingState *mis = migration_incoming_get_current();
+    SocketAddressList *addrs;
+
+    addrs = g_new0(SocketAddressList, 1);
+    addrs->next = mis->socket_address;
+    mis->socket_address = addrs;
+    addrs->value = QAPI_CLONE(SocketAddress, address);
+}
+
 void qemu_start_incoming_migration(const char *uri, Error **errp)
 {
     const char *p;
@@ -966,6 +984,12 @@ static void fill_destination_migration_info(MigrationInfo *info)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
 
+    if (mis->socket_address) {
+        info->has_socket_address = true;
+        info->socket_address =
+            QAPI_CLONE(SocketAddressList, mis->socket_address);
+    }
+
     switch (mis->state) {
     case MIGRATION_STATUS_NONE:
         return;
diff --git a/migration/migration.h b/migration/migration.h
index dcd05d9f87..bd41b57af9 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -80,6 +80,9 @@ struct MigrationIncomingState {
     bool postcopy_recover_triggered;
     QemuSemaphore postcopy_pause_sem_dst;
     QemuSemaphore postcopy_pause_sem_fault;
+
+    /* List of listening socket addresses  */
+    SocketAddressList *socket_address;
 };
 
 MigrationIncomingState *migration_incoming_get_current(void);
@@ -300,6 +303,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);
 
 void dirty_bitmap_mig_before_vm_start(void);
 void init_dirty_bitmap_incoming_migration(void);
+void migrate_add_address(SocketAddress *address);
 
 #define qemu_ram_foreach_block \
   #warning "Use qemu_ram_foreach_block_migratable in migration code"
diff --git a/migration/socket.c b/migration/socket.c
index f4c8174400..239527fb1f 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -15,6 +15,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 
 #include "qemu-common.h"
 #include "qemu/error-report.h"
@@ -177,6 +178,7 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
                                             Error **errp)
 {
     QIONetListener *listener = qio_net_listener_new();
+    size_t i;
 
     qio_net_listener_set_name(listener, "migration-socket-listener");
 
@@ -189,6 +191,15 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
                                           socket_accept_incoming_migration,
                                           NULL, NULL,
                                           g_main_context_get_thread_default());
+
+    for (i = 0; i < listener->nsioc; i++)  {
+        SocketAddress *address =
+            qio_channel_socket_get_local_address(listener->sioc[i], errp);
+        if (!address) {
+            return;
+        }
+        migrate_add_address(address);
+    }
 }
 
 void tcp_start_incoming_migration(const char *host_port, Error **errp)
diff --git a/qapi/migration.json b/qapi/migration.json
index 7a795ecc16..d7b5b3f6e7 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -6,6 +6,7 @@
 ##
 
 { 'include': 'common.json' }
+{ 'include': 'sockets.json' }
 
 ##
 # @MigrationStats:
@@ -199,6 +200,8 @@
 # @compression: migration compression statistics, only returned if compression
 #           feature is on and status is 'active' or 'completed' (Since 3.1)
 #
+# @socket-address: Only used for tcp, to know what the real port is (Since 3.1)
+#
 # Since: 0.14.0
 ##
 { 'struct': 'MigrationInfo',
@@ -213,7 +216,8 @@
            '*error-desc': 'str',
            '*postcopy-blocktime' : 'uint32',
            '*postcopy-vcpu-blocktime': ['uint32'],
-           '*compression': 'CompressionStats'} }
+           '*compression': 'CompressionStats',
+           '*socket-address': ['SocketAddress'] } }
 
 ##
 # @query-migrate:
diff --git a/qapi/sockets.json b/qapi/sockets.json
index fc81d8d5e8..d7f77984af 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -152,3 +152,16 @@
             'unix': 'UnixSocketAddress',
             'vsock': 'VsockSocketAddress',
             'fd': 'String' } }
+
+##
+# @DummyStruct:
+#
+# Both block-core and migration needs SocketAddressList
+# I am open to comments about how to share it
+#
+# @dummy-list: A dummy list
+#
+# Since: 3.1
+##
+{ 'struct': 'DummyStruct',
+  'data': { 'dummy-list': ['SocketAddress'] } }
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v11 3/4] tests: Add basic migration precopy tcp test
  2019-01-30 12:06 [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 1/4] tests: Add migration xbzrle test Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter Juan Quintela
@ 2019-01-30 12:06 ` Juan Quintela
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 4/4] tests: Add migration multifd test Juan Quintela
  3 siblings, 0 replies; 8+ messages in thread
From: Juan Quintela @ 2019-01-30 12:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Eric Blake,
	Laurent Vivier, Juan Quintela, Dr. David Alan Gilbert,
	Paolo Bonzini, Peter Xu

Not sharing code from precopy/unix because we have to read back the
tcp parameter.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 109 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 104 insertions(+), 5 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index b0670efde7..a27f095b28 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -20,6 +20,9 @@
 #include "qemu/sockets.h"
 #include "chardev/char.h"
 #include "sysemu/sysemu.h"
+#include "qapi/qapi-visit-sockets.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
 
 #include "migration/migration-test.h"
 
@@ -332,15 +335,67 @@ static void cleanup(const char *filename)
     g_free(path);
 }
 
+static char *SocketAddress_to_str(SocketAddress *addr)
+{
+    switch (addr->type) {
+    case SOCKET_ADDRESS_TYPE_INET:
+        return g_strdup_printf("tcp:%s:%s",
+                               addr->u.inet.host,
+                               addr->u.inet.port);
+        break;
+    case SOCKET_ADDRESS_TYPE_UNIX:
+        return g_strdup_printf("unix:%s",
+                               addr->u.q_unix.path);
+        break;
+    case SOCKET_ADDRESS_TYPE_FD:
+        return g_strdup_printf("fd:%s", addr->u.fd.str);
+        break;
+    default:
+        abort();
+    }
+}
+
+static char *migrate_get_socket_address(QTestState *who, const char *parameter)
+{
+    QDict *rsp;
+    char *result;
+    Error *local_err = NULL;
+    SocketAddressList *addrs;
+    Visitor *iv = NULL;
+    QObject *object;
+
+    rsp = migrate_query(who);
+    object = qdict_get(rsp, parameter);
+
+    iv = qobject_input_visitor_new(object);
+    visit_type_SocketAddressList(iv, NULL, &addrs, &local_err);
+
+    /* we are only using a single address */
+    result = g_strdup_printf("%s", SocketAddress_to_str(addrs->value));
+
+    qapi_free_SocketAddressList(addrs);
+    qobject_unref(rsp);
+    return result;
+}
+
+static long long migrate_get_parameter(QTestState *who, const char *parameter)
+{
+    QDict *rsp;
+    long long result;
+
+    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
+    result = qdict_get_int(rsp, parameter);
+    qobject_unref(rsp);
+    return result;
+}
+
 static void migrate_check_parameter(QTestState *who, const char *parameter,
                                     long long value)
 {
-    QDict *rsp_return;
+    long long result;
 
-    rsp_return = wait_command(who,
-                              "{ 'execute': 'query-migrate-parameters' }");
-    g_assert_cmpint(qdict_get_int(rsp_return, parameter), ==, value);
-    qobject_unref(rsp_return);
+    result = migrate_get_parameter(who, parameter);
+    g_assert_cmpint(result, ==, value);
 }
 
 static void migrate_set_parameter(QTestState *who, const char *parameter,
@@ -844,6 +899,49 @@ static void test_xbzrle_unix(void)
     g_free(uri);
 }
 
+static void test_precopy_tcp(void)
+{
+    char *uri;
+    QTestState *from, *to;
+
+    if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", false)) {
+        return;
+    }
+
+    /*
+     * We want to pick a speed slow enough that the test completes
+     * quickly, but that it doesn't complete precopy even on a slow
+     * machine, so also set the downtime.
+     */
+    /* 1 ms should make it not converge*/
+    migrate_set_parameter(from, "downtime-limit", 1);
+    /* 1GB/s */
+    migrate_set_parameter(from, "max-bandwidth", 1000000000);
+
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    uri = migrate_get_socket_address(to, "socket-address");
+
+    migrate(from, uri, "{}");
+
+    wait_for_migration_pass(from);
+
+    /* 300ms should converge */
+    migrate_set_parameter(from, "downtime-limit", 300);
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to, true);
+    g_free(uri);
+}
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -895,6 +993,7 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/deprecated", test_deprecated);
     qtest_add_func("/migration/bad_dest", test_baddest);
     qtest_add_func("/migration/precopy/unix", test_precopy_unix);
+    qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
     qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix);
 
     ret = g_test_run();
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v11 4/4] tests: Add migration multifd test
  2019-01-30 12:06 [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration Juan Quintela
                   ` (2 preceding siblings ...)
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 3/4] tests: Add basic migration precopy tcp test Juan Quintela
@ 2019-01-30 12:06 ` Juan Quintela
  3 siblings, 0 replies; 8+ messages in thread
From: Juan Quintela @ 2019-01-30 12:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Eric Blake,
	Laurent Vivier, Juan Quintela, Dr. David Alan Gilbert,
	Paolo Bonzini

We set the x-multifd-page-count and x-multifd-channels.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 51 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index a27f095b28..2a2ffc893d 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -942,6 +942,56 @@ static void test_precopy_tcp(void)
     g_free(uri);
 }
 
+static void test_multifd_tcp(void)
+{
+    char *uri;
+    QTestState *from, *to;
+
+    if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", false)) {
+        return;
+    }
+
+    /*
+     * We want to pick a speed slow enough that the test completes
+     * quickly, but that it doesn't complete precopy even on a slow
+     * machine, so also set the downtime.
+     */
+    /* 1 ms should make it not converge*/
+    migrate_set_parameter(from, "downtime-limit", 1);
+    /* 1GB/s */
+    migrate_set_parameter(from, "max-bandwidth", 1000000000);
+
+    migrate_set_parameter(from, "x-multifd-channels", 8);
+    migrate_set_parameter(to, "x-multifd-channels", 8);
+
+    migrate_set_parameter(from, "x-multifd-page-count", 64);
+    migrate_set_parameter(to, "x-multifd-page-count", 64);
+
+    migrate_set_capability(from, "x-multifd", "true");
+    migrate_set_capability(to, "x-multifd", "true");
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    uri = migrate_get_socket_address(to, "socket-address");
+
+    migrate(from, uri, "{}");
+
+    wait_for_migration_pass(from);
+
+    /* 300ms it should converge */
+    migrate_set_parameter(from, "downtime-limit", 300);
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to, true);
+}
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -995,6 +1045,7 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/precopy/unix", test_precopy_unix);
     qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
     qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix);
+    qtest_add_func("/migration/multifd/tcp", test_multifd_tcp);
 
     ret = g_test_run();
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter
  2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter Juan Quintela
@ 2019-01-30 15:55   ` Eric Blake
  2019-02-06 12:35     ` Juan Quintela
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Blake @ 2019-01-30 15:55 UTC (permalink / raw)
  To: Juan Quintela, qemu-devel
  Cc: Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Laurent Vivier,
	Dr. David Alan Gilbert, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 3882 bytes --]

On 1/30/19 6:06 AM, Juan Quintela wrote:
> It will be used to store the uri parameters. We want this only for
> tcp, so we don't set it for other uris.  We need it to know what port
> is migration running.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> 
> --
> 

> +++ b/hmp.c
> @@ -166,6 +166,26 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
>      qapi_free_MouseInfoList(mice_list);
>  }
>  
> +static char *SocketAddress_to_str(SocketAddress *addr)
> +{
> +    switch (addr->type) {
> +    case SOCKET_ADDRESS_TYPE_INET:
> +        return g_strdup_printf("tcp:%s:%s",
> +                               addr->u.inet.host,
> +                               addr->u.inet.port);
> +        break;
> +    case SOCKET_ADDRESS_TYPE_UNIX:
> +        return g_strdup_printf("unix:%s",
> +                               addr->u.q_unix.path);
> +        break;
> +    case SOCKET_ADDRESS_TYPE_FD:
> +        return g_strdup_printf("fd:%s", addr->u.fd.str);
> +        break;
> +    default:
> +        abort();

Is abort()ing on SOCKET_ADDRESS_TYPE_VSOCK intentional?

> +    }
> +}
> +
>  void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>  {
>      MigrationInfo *info;
> @@ -306,6 +326,17 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>          g_free(str);
>          visit_free(v);
>      }
> +    if (info->has_socket_address) {
> +        SocketAddressList *addr;
> +
> +        monitor_printf(mon, "socket address: [\n");
> +
> +        for (addr = info->socket_address; addr; addr = addr->next) {
> +            char *s = SocketAddress_to_str(addr->value);
> +            monitor_printf(mon, "\t%s\n", s);
> +        }
> +        monitor_printf(mon, "]\n");
> +    }

Leaks 's'.

>      qapi_free_MigrationInfo(info);
>      qapi_free_MigrationCapabilityStatusList(caps);
>  }
> diff --git a/migration/migration.c b/migration/migration.c
> index 37e06b76dc..ef1d53cde2 100644
> --- a/migration/migration.c

> +++ b/qapi/migration.json
> @@ -6,6 +6,7 @@
>  ##
>  
>  { 'include': 'common.json' }
> +{ 'include': 'sockets.json' }
>  
>  ##
>  # @MigrationStats:
> @@ -199,6 +200,8 @@
>  # @compression: migration compression statistics, only returned if compression
>  #           feature is on and status is 'active' or 'completed' (Since 3.1)
>  #
> +# @socket-address: Only used for tcp, to know what the real port is (Since 3.1)
> +#

s/3.1/4.0/

>  # Since: 0.14.0
>  ##
>  { 'struct': 'MigrationInfo',
> @@ -213,7 +216,8 @@
>             '*error-desc': 'str',
>             '*postcopy-blocktime' : 'uint32',
>             '*postcopy-vcpu-blocktime': ['uint32'],
> -           '*compression': 'CompressionStats'} }
> +           '*compression': 'CompressionStats',
> +           '*socket-address': ['SocketAddress'] } }
>  
>  ##
>  # @query-migrate:
> diff --git a/qapi/sockets.json b/qapi/sockets.json
> index fc81d8d5e8..d7f77984af 100644
> --- a/qapi/sockets.json
> +++ b/qapi/sockets.json
> @@ -152,3 +152,16 @@
>              'unix': 'UnixSocketAddress',
>              'vsock': 'VsockSocketAddress',
>              'fd': 'String' } }
> +
> +##
> +# @DummyStruct:
> +#
> +# Both block-core and migration needs SocketAddressList
> +# I am open to comments about how to share it
> +#
> +# @dummy-list: A dummy list
> +#
> +# Since: 3.1

s/3.1/4.0/
This matches how we force list types elsewhere for use in C code even
when the type is not exposed through QMP. But do you still need to force
the generation, given that ['SocketAddress'] used in MigrationInfo is
visible through QMP?

> +##
> +{ 'struct': 'DummyStruct',
> +  'data': { 'dummy-list': ['SocketAddress'] } }
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter
  2019-01-30 15:55   ` Eric Blake
@ 2019-02-06 12:35     ` Juan Quintela
  2019-02-06 18:49       ` Markus Armbruster
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Quintela @ 2019-02-06 12:35 UTC (permalink / raw)
  To: Eric Blake
  Cc: qemu-devel, Daniel P. Berrangé,
	Gerd Hoffmann, Thomas Huth, Markus Armbruster, Laurent Vivier,
	Dr. David Alan Gilbert, Paolo Bonzini

Eric Blake <eblake@redhat.com> wrote:
> On 1/30/19 6:06 AM, Juan Quintela wrote:
>> It will be used to store the uri parameters. We want this only for
>> tcp, so we don't set it for other uris.  We need it to know what port
>> is migration running.
>> 
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> 
>> +        return g_strdup_printf("fd:%s", addr->u.fd.str);
>> +        break;
>> +    default:
>> +        abort();
>
> Is abort()ing on SOCKET_ADDRESS_TYPE_VSOCK intentional?

No.  Althought migration has no clue about how to handle VSOCK.  Changed
it to return something sensible for vsock and an "unknown" message for default.

>
>> +    }
>> +}
>> +
>>  void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>>  {
>>      MigrationInfo *info;
>> @@ -306,6 +326,17 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>>          g_free(str);
>>          visit_free(v);
>>      }
>> +    if (info->has_socket_address) {
>> +        SocketAddressList *addr;
>> +
>> +        monitor_printf(mon, "socket address: [\n");
>> +
>> +        for (addr = info->socket_address; addr; addr = addr->next) {
>> +            char *s = SocketAddress_to_str(addr->value);
>> +            monitor_printf(mon, "\t%s\n", s);
>> +        }
>> +        monitor_printf(mon, "]\n");
>> +    }
>
> Leaks 's'.

Good catch.

>> @@ -199,6 +200,8 @@
>>  # @compression: migration compression statistics, only returned if compression
>>  #           feature is on and status is 'active' or 'completed' (Since 3.1)
>>  #
>> +# @socket-address: Only used for tcp, to know what the real port is (Since 3.1)
>> +#
>
> s/3.1/4.0/

Done.

>> +##
>> +# @DummyStruct:
>> +#
>> +# Both block-core and migration needs SocketAddressList
>> +# I am open to comments about how to share it
>> +#
>> +# @dummy-list: A dummy list
>> +#
>> +# Since: 3.1
>
> s/3.1/4.0/
> This matches how we force list types elsewhere for use in C code even
> when the type is not exposed through QMP. But do you still need to force
> the generation, given that ['SocketAddress'] used in MigrationInfo is
> visible through QMP?

I think so but I am not an expert here.

Later, Juan.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter
  2019-02-06 12:35     ` Juan Quintela
@ 2019-02-06 18:49       ` Markus Armbruster
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2019-02-06 18:49 UTC (permalink / raw)
  To: Juan Quintela
  Cc: Eric Blake, Laurent Vivier, Thomas Huth, qemu-devel,
	Gerd Hoffmann, Paolo Bonzini, Dr. David Alan Gilbert

Juan Quintela <quintela@redhat.com> writes:

> Eric Blake <eblake@redhat.com> wrote:
>> On 1/30/19 6:06 AM, Juan Quintela wrote:
>>> It will be used to store the uri parameters. We want this only for
>>> tcp, so we don't set it for other uris.  We need it to know what port
>>> is migration running.
>>> 
>>> Signed-off-by: Juan Quintela <quintela@redhat.com>
[...]
>>> @@ -199,6 +200,8 @@
>>>  # @compression: migration compression statistics, only returned if compression
>>>  #           feature is on and status is 'active' or 'completed' (Since 3.1)
>>>  #
>>> +# @socket-address: Only used for tcp, to know what the real port is (Since 3.1)
>>> +#
>>
>> s/3.1/4.0/
>
> Done.
>
>>> +##
>>> +# @DummyStruct:
>>> +#
>>> +# Both block-core and migration needs SocketAddressList
>>> +# I am open to comments about how to share it
>>> +#
>>> +# @dummy-list: A dummy list
>>> +#
>>> +# Since: 3.1
>>
>> s/3.1/4.0/
>> This matches how we force list types elsewhere for use in C code even
>> when the type is not exposed through QMP. But do you still need to force
>> the generation, given that ['SocketAddress'] used in MigrationInfo is
>> visible through QMP?
>
> I think so but I am not an expert here.

If the list type is visible in QMP, we shouldn't add this hack to force
it.  Easy to find out: drop DummyStruct, and if it still compiles, the
forcing needs to go.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-06 18:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 12:06 [Qemu-devel] [PATCH v11 0/4] Add make check tests for Migration Juan Quintela
2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 1/4] tests: Add migration xbzrle test Juan Quintela
2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 2/4] migration: Create socket-address parameter Juan Quintela
2019-01-30 15:55   ` Eric Blake
2019-02-06 12:35     ` Juan Quintela
2019-02-06 18:49       ` Markus Armbruster
2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 3/4] tests: Add basic migration precopy tcp test Juan Quintela
2019-01-30 12:06 ` [Qemu-devel] [PATCH v11 4/4] tests: Add migration multifd test Juan Quintela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.