arch_init: support resizing on incoming migration
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 17 Nov 2014 15:55:43 +0000 (17:55 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 8 Jan 2015 11:17:54 +0000 (13:17 +0200)
If block used_length does not match, try to resize it.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
arch_init.c

index 106f46e6239f2f61473eea5fd1f15dcb2b261a58..cfedbf08af3754af5151a348c2594c783d917fc5 100644 (file)
@@ -1086,11 +1086,14 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
 
                 QTAILQ_FOREACH(block, &ram_list.blocks, next) {
                     if (!strncmp(id, block->idstr, sizeof(id))) {
-                        if (block->used_length != length) {
-                            error_report("Length mismatch: %s: 0x" RAM_ADDR_FMT
-                                         " in != 0x" RAM_ADDR_FMT, id, length,
-                                         block->used_length);
-                            ret =  -EINVAL;
+                        if (length != block->used_length) {
+                            Error *local_err = NULL;
+
+                            ret = qemu_ram_resize(block->offset, length, &local_err);
+                            if (local_err) {
+                                error_report("%s", error_get_pretty(local_err));
+                                error_free(local_err);
+                            }
                         }
                         break;
                     }