From 4e39f57c0010b689ffa15658ff063006b45309db Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 1 Dec 2015 14:34:14 +0100 Subject: migration: Clean up use of g_poll() in socket_writev_buffer() socket_writev_buffer() writes in a loop, using g_poll() to block. If g_poll() fails, it tries to write more before the file descriptor is ready. In theory, this could go into a tight loop. In practice, errors other than EINTR are really unlikely, and when they happen, we're probably screwed anyway, so we can just as well loop. Clean it up a bit: retry poll on EINTR, keep ignoring other errors. Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file-unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/qemu-file-unix.c b/migration/qemu-file-unix.c index c503b02..6ca53e7 100644 --- a/migration/qemu-file-unix.c +++ b/migration/qemu-file-unix.c @@ -72,7 +72,8 @@ static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt, pfd.fd = s->fd; pfd.events = G_IO_OUT | G_IO_ERR; pfd.revents = 0; - g_poll(&pfd, 1 /* 1 fd */, -1 /* no timeout */); + TFR(err = g_poll(&pfd, 1, -1 /* no timeout */)); + /* Errors other than EINTR intentionally ignored */ } } -- cgit v1.1 From a694ee343d13159d214823294bbda08e4bdac685 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 26 Jan 2015 12:12:27 +0100 Subject: migration: do floating-point division Dividing integer expressions transferred_bytes and time_spent, and then converting the integer quotient to type double. Any remainder, or fractional part of the quotient, is ignored. Fix this. Signed-off-by: Paolo Bonzini Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 1a42aee..adc6b6f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1674,7 +1674,7 @@ static void *migration_thread(void *opaque) if (current_time >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes; uint64_t time_spent = current_time - initial_time; - double bandwidth = transferred_bytes / time_spent; + double bandwidth = (double)transferred_bytes / time_spent; max_size = bandwidth * migrate_max_downtime() / 1000000; s->mbps = time_spent ? (((double) transferred_bytes * 8.0) / -- cgit v1.1