summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2017-06-01 16:01:59 +0200
committerPeter Maydell2017-06-01 16:01:59 +0200
commite5cac10a3b8c97af1f482cd9e8859cc54fc46524 (patch)
treef1e5768d6ae1825da1427cc1d77241abf780a83a
parentMerge remote-tracking branch 'remotes/aurel/tags/pull-target-sh4-20170530' in... (diff)
parentmigration: use dirty_rate_high_cnt more aggressively (diff)
downloadqemu-e5cac10a3b8c97af1f482cd9e8859cc54fc46524.tar.gz
qemu-e5cac10a3b8c97af1f482cd9e8859cc54fc46524.tar.xz
qemu-e5cac10a3b8c97af1f482cd9e8859cc54fc46524.zip
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20170531' into staging
migration/next for 20170531 # gpg: Signature made Wed 31 May 2017 08:53:06 BST # gpg: using RSA key 0xF487EF185872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" # gpg: aka "Juan Quintela <quintela@trasno.org>" # Primary key fingerprint: 1899 FF8E DEBF 58CC EE03 4B82 F487 EF18 5872 D723 * remotes/juanquintela/tags/migration/20170531: migration: use dirty_rate_high_cnt more aggressively migration: set bytes_xfer_* outside of autoconverge logic migration: set dirty_pages_rate before autoconverge logic migration: keep bytes_xfer_prev init'd to zero migration: Create savevm.h for functions exported from savevm.c Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--include/sysemu/sysemu.h47
-rw-r--r--migration/colo.c1
-rw-r--r--migration/migration.c1
-rw-r--r--migration/postcopy-ram.c1
-rw-r--r--migration/ram.c23
-rw-r--r--migration/savevm.c29
-rw-r--r--migration/savevm.h41
7 files changed, 80 insertions, 63 deletions
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 69046ebf1b..723c8dcb1a 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -97,53 +97,6 @@ int load_vmstate(const char *name, Error **errp);
void qemu_announce_self(void);
-/* Subcommands for QEMU_VM_COMMAND */
-enum qemu_vm_cmd {
- MIG_CMD_INVALID = 0, /* Must be 0 */
- MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */
- MIG_CMD_PING, /* Request a PONG on the RP */
-
- MIG_CMD_POSTCOPY_ADVISE, /* Prior to any page transfers, just
- warn we might want to do PC */
- MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming
- pages as it's running. */
- MIG_CMD_POSTCOPY_RUN, /* Start execution */
-
- MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that
- were previously sent during
- precopy but are dirty. */
- MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */
- MIG_CMD_MAX
-};
-
-#define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24)
-
-bool qemu_savevm_state_blocked(Error **errp);
-void qemu_savevm_state_begin(QEMUFile *f);
-void qemu_savevm_state_header(QEMUFile *f);
-int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
-void qemu_savevm_state_cleanup(void);
-void qemu_savevm_state_complete_postcopy(QEMUFile *f);
-void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only);
-void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
- uint64_t *res_non_postcopiable,
- uint64_t *res_postcopiable);
-void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command,
- uint16_t len, uint8_t *data);
-void qemu_savevm_send_ping(QEMUFile *f, uint32_t value);
-void qemu_savevm_send_open_return_path(QEMUFile *f);
-int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len);
-void qemu_savevm_send_postcopy_advise(QEMUFile *f);
-void qemu_savevm_send_postcopy_listen(QEMUFile *f);
-void qemu_savevm_send_postcopy_run(QEMUFile *f);
-
-void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
- uint16_t len,
- uint64_t *start_list,
- uint64_t *length_list);
-
-int qemu_loadvm_state(QEMUFile *f);
-
extern int autostart;
typedef enum {
diff --git a/migration/colo.c b/migration/colo.c
index 8c13a3c3f1..3dd1390573 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -16,6 +16,7 @@
#include "qemu-file-channel.h"
#include "migration/migration.h"
#include "migration/qemu-file.h"
+#include "savevm.h"
#include "migration/colo.h"
#include "migration/block.h"
#include "io/channel-buffer.h"
diff --git a/migration/migration.c b/migration/migration.c
index ad29e53400..7087d1abbb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -19,6 +19,7 @@
#include "qemu/main-loop.h"
#include "migration/blocker.h"
#include "migration/migration.h"
+#include "savevm.h"
#include "qemu-file-channel.h"
#include "migration/qemu-file.h"
#include "migration/vmstate.h"
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index a37620dac6..3f9ae1bff2 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -22,6 +22,7 @@
#include "exec/target_page.h"
#include "migration/migration.h"
#include "migration/qemu-file.h"
+#include "savevm.h"
#include "postcopy-ram.h"
#include "sysemu/sysemu.h"
#include "sysemu/balloon.h"
diff --git a/migration/ram.c b/migration/ram.c
index c07a9c08d9..26e03a5dfa 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -673,10 +673,6 @@ static void migration_bitmap_sync(RAMState *rs)
rs->bitmap_sync_count++;
- if (!rs->bytes_xfer_prev) {
- rs->bytes_xfer_prev = ram_bytes_transferred();
- }
-
if (!rs->time_last_bitmap_sync) {
rs->time_last_bitmap_sync = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
}
@@ -698,23 +694,25 @@ static void migration_bitmap_sync(RAMState *rs)
/* more than 1 second = 1000 millisecons */
if (end_time > rs->time_last_bitmap_sync + 1000) {
+ /* calculate period counters */
+ rs->dirty_pages_rate = rs->num_dirty_pages_period * 1000
+ / (end_time - rs->time_last_bitmap_sync);
+ bytes_xfer_now = ram_bytes_transferred();
+
if (migrate_auto_converge()) {
/* The following detection logic can be refined later. For now:
Check to see if the dirtied bytes is 50% more than the approx.
amount of bytes that just got transferred since the last time we
were in this routine. If that happens twice, start or increase
throttling */
- bytes_xfer_now = ram_bytes_transferred();
- if (rs->dirty_pages_rate &&
- (rs->num_dirty_pages_period * TARGET_PAGE_SIZE >
+ if ((rs->num_dirty_pages_period * TARGET_PAGE_SIZE >
(bytes_xfer_now - rs->bytes_xfer_prev) / 2) &&
- (rs->dirty_rate_high_cnt++ >= 2)) {
+ (++rs->dirty_rate_high_cnt >= 2)) {
trace_migration_throttle();
rs->dirty_rate_high_cnt = 0;
mig_throttle_guest_down();
- }
- rs->bytes_xfer_prev = bytes_xfer_now;
+ }
}
if (migrate_use_xbzrle()) {
@@ -727,10 +725,11 @@ static void migration_bitmap_sync(RAMState *rs)
rs->iterations_prev = rs->iterations;
rs->xbzrle_cache_miss_prev = rs->xbzrle_cache_miss;
}
- rs->dirty_pages_rate = rs->num_dirty_pages_period * 1000
- / (end_time - rs->time_last_bitmap_sync);
+
+ /* reset period counters */
rs->time_last_bitmap_sync = end_time;
rs->num_dirty_pages_period = 0;
+ rs->bytes_xfer_prev = bytes_xfer_now;
}
if (migrate_use_events()) {
qapi_event_send_migration_pass(rs->bitmap_sync_count, NULL);
diff --git a/migration/savevm.c b/migration/savevm.c
index a4532b6b58..a2d4f9c53c 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -36,6 +36,7 @@
#include "qemu/timer.h"
#include "migration/migration.h"
#include "qemu-file-channel.h"
+#include "savevm.h"
#include "postcopy-ram.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
@@ -63,6 +64,26 @@ const unsigned int postcopy_ram_discard_version = 0;
static bool skip_section_footers;
+/* Subcommands for QEMU_VM_COMMAND */
+enum qemu_vm_cmd {
+ MIG_CMD_INVALID = 0, /* Must be 0 */
+ MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */
+ MIG_CMD_PING, /* Request a PONG on the RP */
+
+ MIG_CMD_POSTCOPY_ADVISE, /* Prior to any page transfers, just
+ warn we might want to do PC */
+ MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming
+ pages as it's running. */
+ MIG_CMD_POSTCOPY_RUN, /* Start execution */
+
+ MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that
+ were previously sent during
+ precopy but are dirty. */
+ MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */
+ MIG_CMD_MAX
+};
+
+#define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24)
static struct mig_cmd_args {
ssize_t len; /* -1 = variable */
const char *name;
@@ -807,10 +828,10 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se)
* @len: Length of associated data
* @data: Data associated with command.
*/
-void qemu_savevm_command_send(QEMUFile *f,
- enum qemu_vm_cmd command,
- uint16_t len,
- uint8_t *data)
+static void qemu_savevm_command_send(QEMUFile *f,
+ enum qemu_vm_cmd command,
+ uint16_t len,
+ uint8_t *data)
{
trace_savevm_command_send(command, len);
qemu_put_byte(f, QEMU_VM_COMMAND);
diff --git a/migration/savevm.h b/migration/savevm.h
new file mode 100644
index 0000000000..eb4487771a
--- /dev/null
+++ b/migration/savevm.h
@@ -0,0 +1,41 @@
+/*
+ * QEMU save vm functions
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2009-2017 Red Hat Inc
+ *
+ * Authors:
+ * Juan Quintela <quintela@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef MIGRATION_SAVEVM_H
+#define MIGRATION_SAVEVM_H
+
+bool qemu_savevm_state_blocked(Error **errp);
+void qemu_savevm_state_begin(QEMUFile *f);
+void qemu_savevm_state_header(QEMUFile *f);
+int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
+void qemu_savevm_state_cleanup(void);
+void qemu_savevm_state_complete_postcopy(QEMUFile *f);
+void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only);
+void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
+ uint64_t *res_non_postcopiable,
+ uint64_t *res_postcopiable);
+void qemu_savevm_send_ping(QEMUFile *f, uint32_t value);
+void qemu_savevm_send_open_return_path(QEMUFile *f);
+int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len);
+void qemu_savevm_send_postcopy_advise(QEMUFile *f);
+void qemu_savevm_send_postcopy_listen(QEMUFile *f);
+void qemu_savevm_send_postcopy_run(QEMUFile *f);
+
+void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
+ uint16_t len,
+ uint64_t *start_list,
+ uint64_t *length_list);
+
+int qemu_loadvm_state(QEMUFile *f);
+
+#endif