migration pull 2017-09-06

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJZsEDbAAoJEAUWMx68W/3nxcwQAKNhcpoAKbcwQn5s9aOcR1Nd
 9pTV/5ucfPI9rMo0cC1JKgVoJVhx1rXwyVuohC/+jZBLHjgTrN8yivo4WLiCEyFx
 0DH4v1Lp/cnvhpNOUisda17lD9Josroi0GF13bbjvyKnyCnOOTEDwn/3YJZdwH2u
 AkWVS+WwRPPqmqHfvjUiEfDyO8SXpk635eoHqLVrS1I5+uykPKxSqJAwZmEGnf5Y
 y+k+VnIq1pVRt/6C/mw4tm1ZVjzeKm77AGMlnMIAvT9/n5TfolMlpSha9RG86avf
 4QgJIA5duaWNj8Kt7LsnGmBUKndNgY2eFDV3IJA9ke5x9FkrO3S02W4LT1/4N4MU
 P/art2z+jtKWVzxvdmz9S1fEKnmE44ULCbLJRVucoK5lYEgDdAfapO6Duq/hf+JW
 jWeaiNlF/oJrMZH89HdJt25iGYBcYuwg1vc6QlGMQ0zHzFYw2xV2z3V3raHUUQD8
 74iJeSM7O2oVTzgfeOBNpKVpVqQLPEY2B9vK8slZtUNsiziQjaWufuzYfn7Mi7kU
 JZ29vfLx+3mK6Ateq/diQgHuJsWxM2LDe2DlhwBgmSjEFzWK/q8Eg/AzX+O4xDvv
 Kd5KVpc+N7nFwiWRScplibPgFmzSHzAack8Kwi5s1JPj63kJcuR56hWQaJ9d4uA7
 k5SN9mduPLVP2zkDGH53
 =lrj8
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170906a' into staging

migration pull 2017-09-06

# gpg: Signature made Wed 06 Sep 2017 19:39:23 BST
# gpg:                using RSA key 0x0516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20170906a:
  migration: dump str in migrate_set_state trace
  snapshot/tests: Try loadvm twice
  migration: Reset rather than destroy main_thread_load_event
  runstate/migrate: Two more transitions
  host-utils: Simplify pow2ceil()
  host-utils: Proactively fix pow2floor(), switch to unsigned
  xbzrle: Drop unused cache_resize()
  migration: Report when bdrv_inactivate_all fails

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-09-07 15:26:06 +01:00
commit 7794b34e63
9 changed files with 39 additions and 89 deletions

View File

@ -369,27 +369,35 @@ static inline bool is_power_of_2(uint64_t value)
return !(value & (value - 1));
}
/* round down to the nearest power of 2*/
static inline int64_t pow2floor(int64_t value)
/**
* Return @value rounded down to the nearest power of two or zero.
*/
static inline uint64_t pow2floor(uint64_t value)
{
if (!is_power_of_2(value)) {
value = 0x8000000000000000ULL >> clz64(value);
}
return value;
}
/* round up to the nearest power of 2 (0 if overflow) */
static inline uint64_t pow2ceil(uint64_t value)
{
uint8_t nlz = clz64(value);
if (is_power_of_2(value)) {
return value;
}
if (!nlz) {
if (!value) {
/* Avoid undefined shift by 64 */
return 0;
}
return 1ULL << (64 - nlz);
return 0x8000000000000000ull >> clz64(value);
}
/*
* Return @value rounded up to the nearest power of two modulo 2^64.
* This is *zero* for @value > 2^63, so be careful.
*/
static inline uint64_t pow2ceil(uint64_t value)
{
int n = clz64(value - 1);
if (!n) {
/*
* @value - 1 has no leading zeroes, thus @value - 1 >= 2^63
* Therefore, either @value == 0 or @value > 2^63.
* If it's 0, return 1, else return 0.
*/
return !value;
}
return 0x8000000000000000ull >> (n - 1);
}
/**

View File

@ -166,7 +166,7 @@ void migration_incoming_state_destroy(void)
mis->from_src_file = NULL;
}
qemu_event_destroy(&mis->main_thread_load_event);
qemu_event_reset(&mis->main_thread_load_event);
}
static void migrate_generate_event(int new_state)
@ -913,8 +913,9 @@ void qmp_migrate_start_postcopy(Error **errp)
void migrate_set_state(int *state, int old_state, int new_state)
{
assert(new_state < MIGRATION_STATUS__MAX);
if (atomic_cmpxchg(state, old_state, new_state) == old_state) {
trace_migrate_set_state(new_state);
trace_migrate_set_state(MigrationStatus_str(new_state));
migrate_generate_event(new_state);
}
}

View File

@ -178,59 +178,3 @@ int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
return 0;
}
int64_t cache_resize(PageCache *cache, int64_t new_num_pages)
{
PageCache *new_cache;
int64_t i;
CacheItem *old_it, *new_it;
g_assert(cache);
/* cache was not inited */
if (cache->page_cache == NULL) {
return -1;
}
/* same size */
if (pow2floor(new_num_pages) == cache->max_num_items) {
return cache->max_num_items;
}
new_cache = cache_init(new_num_pages, cache->page_size);
if (!(new_cache)) {
DPRINTF("Error creating new cache\n");
return -1;
}
/* move all data from old cache */
for (i = 0; i < cache->max_num_items; i++) {
old_it = &cache->page_cache[i];
if (old_it->it_addr != -1) {
/* check for collision, if there is, keep MRU page */
new_it = cache_get_by_addr(new_cache, old_it->it_addr);
if (new_it->it_data && new_it->it_age >= old_it->it_age) {
/* keep the MRU page */
g_free(old_it->it_data);
} else {
if (!new_it->it_data) {
new_cache->num_items++;
}
g_free(new_it->it_data);
new_it->it_data = old_it->it_data;
new_it->it_age = old_it->it_age;
new_it->it_addr = old_it->it_addr;
}
}
}
g_free(cache->page_cache);
cache->page_cache = new_cache->page_cache;
cache->max_num_items = new_cache->max_num_items;
cache->num_items = new_cache->num_items;
g_free(new_cache);
return cache->max_num_items;
}

View File

@ -72,15 +72,4 @@ uint8_t *get_cached_data(const PageCache *cache, uint64_t addr);
int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
uint64_t current_age);
/**
* cache_resize: resize the page cache. In case of size reduction the extra
* pages will be freed
*
* Returns -1 on error new cache size on success
*
* @cache pointer to the PageCache struct
* @num_pages: new page cache size (in pages)
*/
int64_t cache_resize(PageCache *cache, int64_t num_pages);
#endif

View File

@ -1157,6 +1157,8 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,
* bdrv_invalidate_cache_all() on the other end won't fail. */
ret = bdrv_inactivate_all();
if (ret) {
error_report("%s: bdrv_inactivate_all() failed (%d)",
__func__, ret);
qemu_file_set_error(f, ret);
return ret;
}

View File

@ -80,7 +80,7 @@ ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: start: 0
# migration/migration.c
await_return_path_close_on_source_close(void) ""
await_return_path_close_on_source_joining(void) ""
migrate_set_state(int new_state) "new state %d"
migrate_set_state(const char *new_state) "new state %s"
migrate_fd_cleanup(void) ""
migrate_fd_error(const char *error_desc) "error=%s"
migrate_fd_cancel(void) ""

View File

@ -78,7 +78,7 @@ for extra_args in \
# Give qemu some time to boot before saving the VM state
{ sleep 1; printf "savevm 0\nquit\n"; } | _qemu $extra_args
# Now try to continue from that VM state (this should just work)
echo quit | _qemu $extra_args -loadvm 0
{ sleep 1; printf "loadvm 0\nloadvm 0\nquit\n"; } | _qemu $extra_args -S
done
# success, all done

View File

@ -7,6 +7,8 @@ QEMU X.Y.Z monitor - type 'help' for more information
(qemu) savevm 0
(qemu) quit
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) loadvm 0
(qemu) loadvm 0
(qemu) quit
=== Saving and reloading a VM state to/from a qcow2 image (-object iothread,id=iothread0 -set device.hba0.iothread=iothread0) ===
@ -16,5 +18,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
(qemu) savevm 0
(qemu) quit
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) loadvm 0
(qemu) loadvm 0
(qemu) quit
*** done

2
vl.c
View File

@ -621,6 +621,7 @@ static const RunStateTransition runstate_transitions_def[] = {
{ RUN_STATE_PAUSED, RUN_STATE_RUNNING },
{ RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE },
{ RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE },
{ RUN_STATE_PAUSED, RUN_STATE_PRELAUNCH },
{ RUN_STATE_PAUSED, RUN_STATE_COLO},
@ -633,6 +634,7 @@ static const RunStateTransition runstate_transitions_def[] = {
{ RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE },
{ RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING },
{ RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED },
{ RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE },
{ RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH },
{ RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO},