mirror of
https://github.com/qemu/qemu.git
synced 2025-01-20 20:43:26 +08:00
Add check for cache size smaller than page size
Signed-off-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
f6c6483b25
commit
c91e681a55
@ -178,6 +178,10 @@ static struct {
|
||||
|
||||
int64_t xbzrle_cache_resize(int64_t new_size)
|
||||
{
|
||||
if (new_size < TARGET_PAGE_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (XBZRLE.cache != NULL) {
|
||||
return cache_resize(XBZRLE.cache, new_size / TARGET_PAGE_SIZE) *
|
||||
TARGET_PAGE_SIZE;
|
||||
|
10
migration.c
10
migration.c
@ -469,6 +469,7 @@ void qmp_migrate_cancel(Error **errp)
|
||||
void qmp_migrate_set_cache_size(int64_t value, Error **errp)
|
||||
{
|
||||
MigrationState *s = migrate_get_current();
|
||||
int64_t new_size;
|
||||
|
||||
/* Check for truncation */
|
||||
if (value != (size_t)value) {
|
||||
@ -477,7 +478,14 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
s->xbzrle_cache_size = xbzrle_cache_resize(value);
|
||||
new_size = xbzrle_cache_resize(value);
|
||||
if (new_size < 0) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
|
||||
"is smaller than page size");
|
||||
return;
|
||||
}
|
||||
|
||||
s->xbzrle_cache_size = new_size;
|
||||
}
|
||||
|
||||
int64_t qmp_query_migrate_cache_size(Error **errp)
|
||||
|
Loading…
Reference in New Issue
Block a user