summary refs log tree commit diff stats
path: root/migration/migration.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-09-25 14:46:18 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-09-25 14:46:18 +0100
commit8d16e72f2d4df2c9e631393adf1669a1da7efe8a (patch)
treebadeaa53bb34f24540bf03dc00e536483eaa61f1 /migration/migration.c
parent8c1c07929feae876202ba26f07a540c5115c18cd (diff)
parente12a0edafeb5019aac74114b62a4703f79c5c693 (diff)
downloadfocaccia-qemu-8d16e72f2d4df2c9e631393adf1669a1da7efe8a.tar.gz
focaccia-qemu-8d16e72f2d4df2c9e631393adf1669a1da7efe8a.zip
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200925a' into staging
Migration and virtiofsd pull

Chuan Zheng's Dirtyrate and TLS changes, with small fixes from Dov and
Luarent.
Small virtiofs changes from Harry, Stefan, Vivek and Jiachen.
One HMP/monitor rework from me.

# gpg: Signature made Fri 25 Sep 2020 13:03:50 BST
# gpg:                using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full]
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20200925a: (26 commits)
  virtiofsd: Add -o allow_direct_io|no_allow_direct_io options
  virtiofsd: Used glib "shared" thread pool
  virtiofsd: document cache=auto default
  monitor: Use LOCK_GUARD macros
  migration/tls: add trace points for multifd-tls
  migration/tls: add support for multifd tls-handshake
  migration/tls: extract cleanup function for common-use
  migration/tls: add tls_hostname into MultiFDSendParams
  migration/tls: extract migration_tls_client_create for common-use
  migration/tls: save hostname into MigrationState
  migration: increase max-bandwidth to 128 MiB/s (1 Gib/s)
  migration: Truncate state file in xen-save-devices-state
  migration/dirtyrate: Add trace_calls to make it easier to debug
  migration/dirtyrate: Implement qmp_cal_dirty_rate()/qmp_get_dirty_rate() function
  migration/dirtyrate: Implement calculate_dirtyrate() function
  migration/dirtyrate: Implement set_sample_page_period() and is_sample_period_valid()
  migration/dirtyrate: skip sampling ramblock with size below MIN_RAMBLOCK_SIZE
  migration/dirtyrate: Compare page hash results for recorded sampled page
  migration/dirtyrate: Record hash results for each sampled page
  migration/dirtyrate: move RAMBLOCK_FOREACH_MIGRATABLE into ram.h
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/migration/migration.c b/migration/migration.c
index d9d1e0b190..838ca79f57 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -57,7 +57,7 @@
 #include "qemu/queue.h"
 #include "multifd.h"
 
-#define MAX_THROTTLE  (32 << 20)      /* Migration transfer speed throttling */
+#define MAX_THROTTLE  (128 << 20)      /* Migration transfer speed throttling */
 
 /* Amount of time to allocate to each "chunk" of bandwidth-throttled
  * data. */
@@ -238,12 +238,15 @@ void migration_incoming_state_destroy(void)
         mis->postcopy_remote_fds = NULL;
     }
 
-    qemu_event_reset(&mis->main_thread_load_event);
-
     if (mis->socket_address_list) {
         qapi_free_SocketAddressList(mis->socket_address_list);
         mis->socket_address_list = NULL;
     }
+
+    qemu_event_destroy(&mis->main_thread_load_event);
+    qemu_sem_destroy(&mis->postcopy_pause_sem_dst);
+    qemu_sem_destroy(&mis->postcopy_pause_sem_fault);
+    qemu_mutex_destroy(&mis->rp_mutex);
 }
 
 static void migrate_generate_event(int new_state)
@@ -311,25 +314,35 @@ error:
     return ret;
 }
 
-/* Request a range of pages from the source VM at the given
- * start address.
- *   rbname: Name of the RAMBlock to request the page in, if NULL it's the same
- *           as the last request (a name must have been given previously)
+/* Request one page from the source VM at the given start address.
+ *   rb: the RAMBlock to request the page in
  *   Start: Address offset within the RB
  *   Len: Length in bytes required - must be a multiple of pagesize
  */
-int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname,
-                              ram_addr_t start, size_t len)
+int migrate_send_rp_req_pages(MigrationIncomingState *mis, RAMBlock *rb,
+                              ram_addr_t start)
 {
     uint8_t bufc[12 + 1 + 255]; /* start (8), len (4), rbname up to 256 */
     size_t msglen = 12; /* start + len */
+    size_t len = qemu_ram_pagesize(rb);
     enum mig_rp_message_type msg_type;
+    const char *rbname;
+    int rbname_len;
 
     *(uint64_t *)bufc = cpu_to_be64((uint64_t)start);
     *(uint32_t *)(bufc + 8) = cpu_to_be32((uint32_t)len);
 
-    if (rbname) {
-        int rbname_len = strlen(rbname);
+    /*
+     * We maintain the last ramblock that we requested for page.  Note that we
+     * don't need locking because this function will only be called within the
+     * postcopy ram fault thread.
+     */
+    if (rb != mis->last_rb) {
+        mis->last_rb = rb;
+
+        rbname = qemu_ram_get_idstr(rb);
+        rbname_len = strlen(rbname);
+
         assert(rbname_len < 256);
 
         bufc[msglen++] = rbname_len;
@@ -1883,6 +1896,7 @@ void migrate_init(MigrationState *s)
     s->migration_thread_running = false;
     error_free(s->error);
     s->error = NULL;
+    s->hostname = NULL;
 
     migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);