Migration queue
The following changes since commit 19b599f7664b2ebfd0f405fb79c14dd241557452:
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-08-27-v2' into staging (2018-08-27 16:44:20 +0100)
are available in the Git repository at:
git://github.com/juanquintela/qemu.git tags/migration/20180903
for you to fetch changes up to a28652cd4c138e9ed5d7dd9f7d10e3562f89ccac:
Add a hint message to loadvm and exits on failure (2018-09-03 19:50:42 +0200)
----------------------------------------------------------------
migration/next for 20180903
Reviewed patches for migration:
- fix clang warning (david)
- Improve loadvm handling (Jose)
- Include migration test for s390 (thomas)
- Improve compression handling (xiao)
Please apply.
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
migration/rdma: Fix uninitialised rdma_return_path
Jose Ricardo Ziviani (1):
Add a hint message to loadvm and exits on failure
Thomas Huth (1):
tests/migration: Enable the migration test on s390x, too
Xiao Guangrong (2):
migration: fix calculating xbzrle_counters.cache_miss_rate
migration: handle the error condition properly
migration/ram.c | 36 +- migration/rdma.c | 2 +- migration/savevm.c | 4 +- tests/Makefile.include | 1 + tests/Makefile.include.orig | 1025 ++++++++++++++++++++++++++++++++++ tests/migration-test.c | 23 + tests/migration-test.c.orig | 780 ++++++++++++++++++++++++++ tests/migration/s390x-a-b-rebuild.sh | 42 ++ tests/migration/s390x-a-b.c | 35 ++ tests/migration/s390x-a-b.h | 427 ++++++++++++++ vl.c | 1 + 11 files changed, 2362 insertions(+), 14 deletions(-) create mode 100644 tests/Makefile.include.orig create mode 100644 tests/migration-test.c.orig create mode 100755 tests/migration/s390x-a-b-rebuild.sh create mode 100644 tests/migration/s390x-a-b.c create mode 100644 tests/migration/s390x-a-b.h
[Qemu-devel] [PULL 1/5] migration/rdma: Fix uninitialised rdma_return_path
From: "Dr. David Alan Gilbert" <[email protected]>
Clang correctly errors out moaning that rdma_return_path is used uninitialised in the earlier error paths. Make it NULL so that the error path ignores it.
Message-Id: <[email protected]>
--- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
migration/rdma.c +1 -1
@@ -4012,7 +4012,7 @@ static void rdma_accept_incoming_migration(void *opaque)void rdma_start_incoming_migration (const char *host_port,Error **errp) {int ret; -RDMAContext *rdma, *rdma_return_path; +RDMAContext *rdma, *rdma_return_path =NULL ;Error *local_err =NULL ;trace_rdma_start_incoming_migration ();
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 3/5] migration: fix calculating xbzrle_counters.cache_miss_rate
In reply to Juan QuintelaFrom: Xiao Guangrong <[email protected]>
As Peter pointed out:
| - xbzrle_counters.cache_miss is done in save_xbzrle_page(), so it's | per-guest-page granularity | | - RAMState.iterations is done for each ram_find_and_save_block(), so | it's per-host-page granularity | | An example is that when we migrate a 2M huge page in the guest, we | will only increase the RAMState.iterations by 1 (since | ram_find_and_save_block() will be called once), but we might increase | xbzrle_counters.cache_miss for 2M/4K=512 times (we'll call | save_xbzrle_page() that many times) if all the pages got cache miss. | Then IMHO the cache miss rate will be 512/1=51200% (while it should | actually be just 100% cache miss).
And he also suggested as xbzrle_counters.cache_miss_rate is the only user of rs->iterations we can adapt it to count target guest page numbers
After that, rename 'iterations' to 'target_page_count' to better reflect its meaning
Message-Id: <[email protected]>
--- migration/ram.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
migration/ram.c +9 -9
@@ -301,10 +301,10 @@ struct RAMState {uint64_t num_dirty_pages_period;/* xbzrle misses since the beginning of the period */ uint64_t xbzrle_cache_miss_prev; -/* number of iterations at the beginning of period */ -uint64_t iterations_prev; -/* Iterations since start */ -uint64_t iterations; +/* total handled target pages at the beginning of period */ +uint64_t target_page_count_prev; +/* total handled target pages since start */ +uint64_t target_page_count;/* number of dirty bits in the bitmap */ uint64_t migration_dirty_pages;/* protects modification of the bitmap */
@@ -1592,19 +1592,19 @@ uint64_t ram_pagesize_summary(void)static void migration_update_rates (RAMState *rs,int64_t end_time) { -uint64_t iter_count = rs->iterations - rs->iterations_prev; +uint64_t page_count = rs->target_page_count - rs->target_page_count_prev;/* calculate period counters */ ram_counters.dirty_pages_rate = rs->num_dirty_pages_period *1000 / (end_time - rs->time_last_bitmap_sync); -if (!iter_count) { +if (!page_count) {return ; }if (migrate_use_xbzrle ()) { xbzrle_counters.cache_miss_rate = (double )(xbzrle_counters.cache_miss - - rs->xbzrle_cache_miss_prev) / iter_count; + rs->xbzrle_cache_miss_prev) / page_count; rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss; } }
@@ -1662,7 +1662,7 @@ static void migration_bitmap_sync(RAMState *rs)migration_update_rates (rs, end_time); - rs->iterations_prev = rs->iterations; + rs->target_page_count_prev = rs->target_page_count;/* reset period counters */ rs->time_last_bitmap_sync = end_time;
@@ -3196,7 +3196,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done =1 ;break ; } - rs->iterations++; + rs->target_page_count += pages;/* we want to check in the 1st loop, just in case it was the 1st time and we had to sync the dirty bitmap.
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 4/5] migration: handle the error condition properly
In reply to Juan QuintelaFrom: Xiao Guangrong <[email protected]>
ram_find_and_save_block() can return negative if any error hanppens, however, it is completely ignored in current code
Message-Id: <[email protected]>
--- migration/ram.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
migration/ram.c +15 -3
@@ -2372,7 +2372,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,* * Called within an RCU critical section. * -* Returns the number of pages written where zero means no dirty pages +* Returns the number of pages written where zero means no dirty pages, +* or negative on error * * @rs: current RAM state * @last_stage: if we are at the completion stage
@@ -3196,6 +3197,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done =1 ;break ; } + +if (pages <0 ) { +qemu_file_set_error (f, pages); +break ; + } + rs->target_page_count += pages;/* we want to check in the 1st loop, just in case it was the 1st time
@@ -3238,7 +3245,7 @@ out:/** * ram_save_complete: function called to send the remaining amount of ram * -* Returns zero to indicate success +* Returns zero to indicate success or negative on error * * Called with iothread lock *
@@ -3249,6 +3256,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) {RAMState **temp = opaque;RAMState *rs = *temp; +int ret =0 ;rcu_read_lock ();
@@ -3269,6 +3277,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)if (pages ==0 ) {break ; } +if (pages <0 ) { + ret = pages; +break ; + } }flush_compressed_data (rs);
@@ -3280,7 +3292,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)qemu_put_be64 (f,RAM_SAVE_FLAG_EOS );qemu_fflush (f); -return 0 ; +return ret; } static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 5/5] Add a hint message to loadvm and exits on failure
In reply to Juan QuintelaFrom: Jose Ricardo Ziviani <[email protected]>
This patch adds a small hint for the failure case of the load snapshot process. It may be useful for users to remember that the VM configuration has changed between the save and load processes.
(qemu) loadvm vm-20180903083641
Unknown savevm section or instance 'cpu_common' 4.
Make sure that your current VM setup matches your saved VM setup, including any hotplugged devices Error -22 while loading VM state
(qemu) device_add host-spapr-cpu-core,core-id=4
(qemu) loadvm vm-20180903083641
(qemu) c
(qemu) info status
VM status: running
It also exits Qemu if the snapshot cannot be loaded before reaching the main loop (-loadvm in the command line).
$ qemu-system-ppc64 ... -loadvm vm-20180903083641 qemu-system-ppc64: Unknown savevm section or instance 'cpu_common' 4. Make sure that your current VM setup matches your saved VM setup, including any hotplugged devices qemu-system-ppc64: Error -22 while loading VM state $
Message-Id: <[email protected]>
--- migration/savevm.c | 4 +++- vl.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
migration/savevm.c +3 -1
@@ -2078,7 +2078,9 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)/* Find savevm section */ se =find_se (idstr, instance_id);if (se ==NULL ) { -error_report ("Unknown savevm section or instance '%s' %d" , +error_report ("Unknown savevm section or instance '%s' %d. " +"Make sure that your current VM setup matches your " +"saved VM setup, including any hotplugged devices" , idstr, instance_id);return -EINVAL ; }
vl.c +1 -0
@@ -4620,6 +4620,7 @@ int main(int argc, char **argv, char **envp)if (load_snapshot (loadvm, &local_err) <0 ) {error_report_err (local_err); autostart =0 ; +exit (1 ); } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 2/5] tests/migration: Enable the migration test on s390x, too
In reply to Juan QuintelaFrom: Thomas Huth <[email protected]>
We can re-use the s390-ccw bios code to implement a small firmware for a s390x guest which prints out the "A" and "B" characters and modifies the memory, as required for the migration test.
Message-Id: <[email protected]>
--- tests/Makefile.include | 1 + tests/Makefile.include.orig | 1025 ++++++++++++++++++++++++++ tests/migration-test.c | 23 + tests/migration-test.c.orig | 780 ++++++++++++++++++++ tests/migration/s390x-a-b-rebuild.sh | 42 ++ tests/migration/s390x-a-b.c | 35 + tests/migration/s390x-a-b.h | 427 +++++++++++ 7 files changed, 2333 insertions(+) create mode 100644 tests/Makefile.include.orig create mode 100644 tests/migration-test.c.orig create mode 100755 tests/migration/s390x-a-b-rebuild.sh create mode 100644 tests/migration/s390x-a-b.c create mode 100644 tests/migration/s390x-a-b.h
tests/Makefile.include +1 -0
@@ -403,6 +403,7 @@ check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF) check-qtest-s390x-y += tests/drive_del-test$(EXESUF) check-qtest-s390x-y += tests/virtio-ccw-test$(EXESUF) check-qtest-s390x-y += tests/cpu-plug-test$(EXESUF) +check-qtest-s390x-y += tests/migration-test$(EXESUF) check-qtest-generic-y += tests/machine-none-test$(EXESUF) check-qtest-generic-y += tests/qom-test$(EXESUF)
tests/Makefile.include.orig new file +1025 -0
1,025 lines not on this page · raw message
tests/migration-test.c +23 -0
@@ -93,6 +93,18 @@ static void init_bootfile_x86(const char *bootpath)fclose (bootfile); } +#include "tests/migration/s390x-a-b.h" + +static void init_bootfile_s390x (const char *bootpath) +{ +FILE *bootfile =fopen (bootpath,"wb" ); +size_t len =sizeof (s390x_a_b_elf); + + g_assert_cmpint(fwrite(s390x_a_b_elf, len, 1, bootfile), ==, 1); +fclose (bootfile); +} + +/* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's
@@ -451,6 +463,17 @@ static int test_migrate_start(QTestState **from, QTestState **to," -serial file:%s/dest_serial" " -incoming %s" , accel, tmpfs, uri); + }else if (g_str_equal (arch,"s390x" )) { +init_bootfile_s390x (bootpath); + cmd_src =g_strdup_printf ("-machine accel=%s -m 128M" +" -name source,debug-threads=on" +" -serial file:%s/src_serial -bios %s" , + accel, tmpfs, bootpath); + cmd_dst =g_strdup_printf ("-machine accel=%s -m 128M" +" -name target,debug-threads=on" +" -serial file:%s/dest_serial -bios %s" +" -incoming %s" , + accel, tmpfs, bootpath, uri); }else {g_assert_not_reached (); }
tests/migration-test.c.orig new file +780 -0
780 lines not on this page · raw message
tests/migration/s390x-a-b-rebuild.sh new file +42 -0
42 lines not on this page · raw message
tests/migration/s390x-a-b.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* S390 guest code used in migration tests +* +* Copyright 2018 Thomas Huth, Red Hat Inc. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#define LOADPARM_LEN 8/* Needed for sclp.h */ + +#include <libc.h> +#include <sclp.h> + +char stack[0x8000] __attribute__((aligned(4096))); + +#define START_ADDRESS (1024 * 1024) +#define END_ADDRESS (100 * 1024 * 1024) + +void main (void ) +{ +unsigned long addr; + +sclp_setup (); +sclp_print ("A" ); + +while (1 ) { +for (addr =START_ADDRESS ; addr <END_ADDRESS ; addr +=4096 ) { + *(volatile char *)addr +=1 ;/* Change pages */ + } +sclp_print ("B" ); + } +}
tests/migration/s390x-a-b.h new file +427 -0
427 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 11 lines · Juan Quintela
The following changes since commit
19b599f7664b2ebfd0f405fb79c14dd241557452:Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-08-27-v2' into staging (2018-08-27 16:44:20 +0100)
are available in the Git repository at:
git://github.com/juanquintela/qemu.gittags/migration/20180903for you to fetch changes up to
a28652cd4c138e9ed5d7dd9f7d10e3562f89ccac:Add a hint message to loadvm and exits on failure (2018-09-03 19:50:42 +0200)
Nack myself. This is included on the following migration pull.
Later, Juan