#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
#elif defined(TARGET_MIPS)
#define QEMU_ARCH QEMU_ARCH_MIPS
+#elif defined(TARGET_OPENRISC)
+#define QEMU_ARCH QEMU_ARCH_OPENRISC
#elif defined(TARGET_PPC)
#define QEMU_ARCH QEMU_ARCH_PPC
#elif defined(TARGET_S390X)
static RAMBlock *last_block;
static ram_addr_t last_offset;
+/*
+ * ram_save_block: Writes a page of memory to the stream f
+ *
+ * Returns: 0: if the page hasn't changed
+ * -1: if there are no more dirty pages
+ * n: the amount of bytes written in other case
+ */
+
static int ram_save_block(QEMUFile *f)
{
RAMBlock *block = last_block;
ram_addr_t offset = last_offset;
- int bytes_sent = 0;
+ int bytes_sent = -1;
MemoryRegion *mr;
if (!block)
ram_addr_t addr;
RAMBlock *block;
- memory_global_sync_dirty_bitmap(get_system_memory());
-
bytes_transferred = 0;
last_block = NULL;
last_offset = 0;
int i;
uint64_t expected_time;
- memory_global_sync_dirty_bitmap(get_system_memory());
-
bytes_transferred_last = bytes_transferred;
bwidth = qemu_get_clock_ns(rt_clock);
int bytes_sent;
bytes_sent = ram_save_block(f);
- bytes_transferred += bytes_sent;
- if (bytes_sent == 0) { /* no more blocks */
+ /* no more blocks to sent */
+ if (bytes_sent < 0) {
break;
}
+ bytes_transferred += bytes_sent;
/* we want to check in the 1st loop, just in case it was the 1st time
and we had to sync the dirty bitmap.
qemu_get_clock_ns() is a bit expensive, so we only check each some
DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
expected_time, migrate_max_downtime());
- return expected_time <= migrate_max_downtime();
+ if (expected_time <= migrate_max_downtime()) {
+ memory_global_sync_dirty_bitmap(get_system_memory());
+ expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
+
+ return expected_time <= migrate_max_downtime();
+ }
+ return 0;
}
static int ram_save_complete(QEMUFile *f, void *opaque)
{
- double bwidth = 0;
- int ret;
- int i;
- int bytes_sent;
-
memory_global_sync_dirty_bitmap(get_system_memory());
- bwidth = qemu_get_clock_ns(rt_clock);
+ /* try transferring iterative blocks of memory */
+
+ /* flush all remaining blocks regardless of rate limiting */
+ while (true) {
+ int bytes_sent;
- i = 0;
- while ((ret = qemu_file_rate_limit(f)) == 0) {
bytes_sent = ram_save_block(f);
- bytes_transferred += bytes_sent;
- if (bytes_sent == 0) { /* no more blocks */
+ /* no more blocks to sent */
+ if (bytes_sent < 0) {
break;
}
- /* we want to check in the 1st loop, just in case it was the 1st time
- and we had to sync the dirty bitmap.
- qemu_get_clock_ns() is a bit expensive, so we only check each some
- iterations
- */
- if ((i & 63) == 0) {
- uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000;
- if (t1 > MAX_WAIT) {
- DPRINTF("big wait: " PRIu64 " milliseconds, %d iterations\n",
- t1, i);
- break;
- }
- }
- i++;
- }
-
- if (ret < 0) {
- return ret;
- }
-
- /* try transferring iterative blocks of memory */
-
- /* flush all remaining blocks regardless of rate limiting */
- while ((bytes_sent = ram_save_block(f)) != 0) {
bytes_transferred += bytes_sent;
}
memory_global_dirty_log_stop();