a7b9285
From 45d723c48255328fbd5128c4c70c91103e420590 Mon Sep 17 00:00:00 2001
Alon Levy b37e208
From: Michael Roth <mdroth@linux.vnet.ibm.com>
Alon Levy b37e208
Date: Thu, 16 May 2013 16:25:44 -0500
Alon Levy b37e208
Subject: [PATCH] Revert "migration: don't account sleep time for calculating
Alon Levy b37e208
 bandwidth"
Alon Levy b37e208
Alon Levy b37e208
This reverts commit 7161082c8d8cf167c508976887a0a63f4db92b51.
Alon Levy b37e208
Alon Levy b37e208
Reverting this patch fixes a divide-by-zero error in qemu that can be
Alon Levy b37e208
fairly reliably triggered by doing block migration. In this case, the
Alon Levy b37e208
configuration/error was:
Alon Levy b37e208
Alon Levy b37e208
source: temp/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -L temp-bios
Alon Levy b37e208
-M pc-i440fx-1.4 -m 512M -kernel boot/vmlinuz-x86_64 -initrd
Alon Levy b37e208
boot/test-initramfs-x86_64.img.gz -vga std -append seed=1234 -drive
Alon Levy b37e208
file=disk1.img,if=virtio -drive file=disk2.img,if=virtio -device
Alon Levy b37e208
virtio-net-pci,netdev=net0 -netdev user,id=net0 -monitor
Alon Levy b37e208
unix:/tmp/vm-hmp.sock,server,nowait -qmp
Alon Levy b37e208
unix:/tmp/vm-qmp.sock,server,nowait -vnc :100
Alon Levy b37e208
Alon Levy b37e208
16837 Floating point exception(core dumped)
Alon Levy b37e208
Alon Levy b37e208
target: temp/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -L temp-bios
Alon Levy b37e208
-M pc-i440fx-1.4 -m 512M -kernel boot/vmlinuz-x86_64 -initrd
Alon Levy b37e208
boot/test-initramfs-x86_64.img.gz -vga std -append seed=1234 -drive
Alon Levy b37e208
file=target_disk1.img,if=virtio -drive file=target_disk2.img,if=virtio
Alon Levy b37e208
-device virtio-net-pci,netdev=net0 -netdev user,id=net0 -incoming
Alon Levy b37e208
unix:/tmp/migrate.sock -monitor
Alon Levy b37e208
unix:/tmp/vm-hmp-incoming.sock,server,nowait -qmp
Alon Levy b37e208
unix:/tmp/vm-qmp-incoming.sock,server,nowait -vnc :101
Alon Levy b37e208
Alon Levy b37e208
Receiving block device images
Alon Levy b37e208
20 %
Alon Levy b37e208
21 %
Alon Levy b37e208
load of migration failed
Alon Levy b37e208
Alon Levy b37e208
This revert potentially re-introduces a bug that was present in 1.4,
Alon Levy b37e208
but fixes a prevalent issue with block migration so we should revert
Alon Levy b37e208
it for now and take an updated patch later.
Alon Levy b37e208
Alon Levy b37e208
Conflicts:
Alon Levy b37e208
Alon Levy b37e208
	migration.c
Alon Levy b37e208
Alon Levy b37e208
* fixed up to remove logic introduced in 7161082c while leaving
Alon Levy b37e208
  changes in HEAD intact
Alon Levy b37e208
Alon Levy b37e208
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Alon Levy b37e208
Message-id: 1368739544-31021-1-git-send-email-mdroth@linux.vnet.ibm.com
Alon Levy b37e208
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
a7b9285
(cherry picked from commit 77417f10701d330c7005b0f0a2c0cef9e05d430d)
Alon Levy b37e208
---
Alon Levy b37e208
 migration.c | 5 +----
Alon Levy b37e208
 1 file changed, 1 insertion(+), 4 deletions(-)
Alon Levy b37e208
Alon Levy b37e208
diff --git a/migration.c b/migration.c
Alon Levy b37e208
index 0aff06d..cca6df6 100644
Alon Levy b37e208
--- a/migration.c
Alon Levy b37e208
+++ b/migration.c
Alon Levy b37e208
@@ -497,7 +497,6 @@ static void *migration_thread(void *opaque)
Alon Levy b37e208
 {
Alon Levy b37e208
     MigrationState *s = opaque;
Alon Levy b37e208
     int64_t initial_time = qemu_get_clock_ms(rt_clock);
Alon Levy b37e208
-    int64_t sleep_time = 0;
Alon Levy b37e208
     int64_t initial_bytes = 0;
Alon Levy b37e208
     int64_t max_size = 0;
Alon Levy b37e208
     int64_t start_time = initial_time;
Alon Levy b37e208
@@ -540,7 +539,7 @@ static void *migration_thread(void *opaque)
Alon Levy b37e208
         current_time = qemu_get_clock_ms(rt_clock);
Alon Levy b37e208
         if (current_time >= initial_time + BUFFER_DELAY) {
Alon Levy b37e208
             uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes;
Alon Levy b37e208
-            uint64_t time_spent = current_time - initial_time - sleep_time;
Alon Levy b37e208
+            uint64_t time_spent = current_time - initial_time;
Alon Levy b37e208
             double bandwidth = transferred_bytes / time_spent;
Alon Levy b37e208
             max_size = bandwidth * migrate_max_downtime() / 1000000;
Alon Levy b37e208
 
Alon Levy b37e208
@@ -554,14 +553,12 @@ static void *migration_thread(void *opaque)
Alon Levy b37e208
             }
Alon Levy b37e208
 
Alon Levy b37e208
             qemu_file_reset_rate_limit(s->file);
Alon Levy b37e208
-            sleep_time = 0;
Alon Levy b37e208
             initial_time = current_time;
Alon Levy b37e208
             initial_bytes = qemu_ftell(s->file);
Alon Levy b37e208
         }
Alon Levy b37e208
         if (qemu_file_rate_limit(s->file)) {
Alon Levy b37e208
             /* usleep expects microseconds */
Alon Levy b37e208
             g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
Alon Levy b37e208
-            sleep_time += qemu_get_clock_ms(rt_clock) - current_time;
Alon Levy b37e208
         }
Alon Levy b37e208
     }
Alon Levy b37e208