summaryrefslogtreecommitdiff
path: root/migration/ram.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2017-10-06 22:30:45 +0200
committerJuan Quintela <quintela@redhat.com>2017-10-23 18:03:25 +0200
commit80f8dfde97e89739d7b9edcf0afceaed3f7f2aad (patch)
treecacb98b269ad5b6f2019b59c8ea75a7079b576ed /migration/ram.c
parent8acabf69ea36a5d8c09b4015b350afb3fc3bd12f (diff)
downloadqemu-80f8dfde97e89739d7b9edcf0afceaed3f7f2aad.tar.gz
migration: Make cache_init() take an error parameter
Once there, take a total size instead of the size of the pages. We move the check that the new_size is bigger than one page from xbzrle_cache_resize(). Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Fix typo spotted by Peter Xu
Diffstat (limited to 'migration/ram.c')
-rw-r--r--migration/ram.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/migration/ram.c b/migration/ram.c
index 7c3acad029..47501460c8 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -135,22 +135,14 @@ int64_t xbzrle_cache_resize(int64_t new_size, Error **errp)
return -1;
}
- if (new_size < TARGET_PAGE_SIZE) {
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
- "is smaller than one target page size");
- return -1;
- }
-
XBZRLE_cache_lock();
if (XBZRLE.cache != NULL) {
if (pow2floor(new_size) == migrate_xbzrle_cache_size()) {
goto out_new_size;
}
- new_cache = cache_init(new_size / TARGET_PAGE_SIZE,
- TARGET_PAGE_SIZE);
+ new_cache = cache_init(new_size, TARGET_PAGE_SIZE, errp);
if (!new_cache) {
- error_setg(errp, "Error creating cache");
ret = -1;
goto out;
}
@@ -2028,6 +2020,7 @@ err:
static int ram_state_init(RAMState **rsp)
{
*rsp = g_new0(RAMState, 1);
+ Error *local_err = NULL;
qemu_mutex_init(&(*rsp)->bitmap_mutex);
qemu_mutex_init(&(*rsp)->src_page_req_mutex);
@@ -2036,12 +2029,11 @@ static int ram_state_init(RAMState **rsp)
if (migrate_use_xbzrle()) {
XBZRLE_cache_lock();
XBZRLE.zero_target_page = g_malloc0(TARGET_PAGE_SIZE);
- XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
- TARGET_PAGE_SIZE,
- TARGET_PAGE_SIZE);
+ XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(),
+ TARGET_PAGE_SIZE, &local_err);
if (!XBZRLE.cache) {
XBZRLE_cache_unlock();
- error_report("Error creating cache");
+ error_report_err(local_err);
g_free(*rsp);
*rsp = NULL;
return -1;