]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20180604' into...
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 4 Jun 2018 11:54:00 +0000 (12:54 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 4 Jun 2018 11:54:00 +0000 (12:54 +0100)
migration/next for 20180604

# gpg: Signature made Mon 04 Jun 2018 05:14:24 BST
# gpg:                using RSA key F487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>"
# gpg:                 aka "Juan Quintela <quintela@trasno.org>"
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* remotes/juanquintela/tags/migration/20180604:
  migration: not wait RDMA_CM_EVENT_DISCONNECTED event after rdma_disconnect
  migration: remove unnecessary variables len in QIOChannelRDMA
  migration: Don't activate block devices if using -S
  migration: discard non-migratable RAMBlocks
  migration: introduce decompress-error-check

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
1  2 
exec.c
hw/arm/virt.c
migration/ram.c
migration/savevm.c

diff --combined exec.c
index f3fa4e9117f3aafcbca1bc0637c9fdd2ff3ab519,af90e914cf4a5b5e585b5783e898f40673d7a59d..f6645ede0c234ba3f3c8af6a95e6c5c73e6c536b
--- 1/exec.c
--- 2/exec.c
+++ b/exec.c
@@@ -104,6 -104,9 +104,9 @@@ static MemoryRegion io_mem_unassigned
   * (Set during postcopy)
   */
  #define RAM_UF_ZEROPAGE (1 << 3)
+ /* RAM can be migrated */
+ #define RAM_MIGRATABLE (1 << 4)
  #endif
  
  #ifdef TARGET_PAGE_BITS_VARY
@@@ -1130,7 -1133,6 +1133,7 @@@ void cpu_abort(CPUState *cpu, const cha
          struct sigaction act;
          sigfillset(&act.sa_mask);
          act.sa_handler = SIG_DFL;
 +        act.sa_flags = 0;
          sigaction(SIGABRT, &act, NULL);
      }
  #endif
@@@ -1839,6 -1841,21 +1842,21 @@@ void qemu_ram_set_uf_zeroable(RAMBlock 
      rb->flags |= RAM_UF_ZEROPAGE;
  }
  
+ bool qemu_ram_is_migratable(RAMBlock *rb)
+ {
+     return rb->flags & RAM_MIGRATABLE;
+ }
+ void qemu_ram_set_migratable(RAMBlock *rb)
+ {
+     rb->flags |= RAM_MIGRATABLE;
+ }
+ void qemu_ram_unset_migratable(RAMBlock *rb)
+ {
+     rb->flags &= ~RAM_MIGRATABLE;
+ }
  /* Called with iothread lock held.  */
  void qemu_ram_set_idstr(RAMBlock *new_block, const char *name, DeviceState *dev)
  {
@@@ -3894,6 -3911,26 +3912,26 @@@ int qemu_ram_foreach_block(RAMBlockIter
      return ret;
  }
  
+ int qemu_ram_foreach_migratable_block(RAMBlockIterFunc func, void *opaque)
+ {
+     RAMBlock *block;
+     int ret = 0;
+     rcu_read_lock();
+     RAMBLOCK_FOREACH(block) {
+         if (!qemu_ram_is_migratable(block)) {
+             continue;
+         }
+         ret = func(block->idstr, block->host, block->offset,
+                    block->used_length, opaque);
+         if (ret) {
+             break;
+         }
+     }
+     rcu_read_unlock();
+     return ret;
+ }
  /*
   * Unmap pages of memory from start to start+length such that
   * they a) read as 0, b) Trigger whatever fault mechanism
diff --combined hw/arm/virt.c
index 3aa19b2935d7920b832c2970350228a006fb909a,b2a67a4c00d50b97a65bd5449f7e2c540b95847d..f0a4fa004cdf9818f519316ebf4899236406f5c3
@@@ -38,6 -38,7 +38,6 @@@
  #include "hw/vfio/vfio-amd-xgbe.h"
  #include "hw/devices.h"
  #include "net/net.h"
 -#include "sysemu/block-backend.h"
  #include "sysemu/device_tree.h"
  #include "sysemu/numa.h"
  #include "sysemu/sysemu.h"
@@@ -1692,6 -1693,9 +1692,9 @@@ static void machvirt_machine_init(void
  }
  type_init(machvirt_machine_init);
  
+ #define VIRT_COMPAT_2_12 \
+     HW_COMPAT_2_12
  static void virt_2_12_instance_init(Object *obj)
  {
      VirtMachineState *vms = VIRT_MACHINE(obj);
  
  static void virt_machine_2_12_options(MachineClass *mc)
  {
+     SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_12);
  }
  DEFINE_VIRT_MACHINE_AS_LATEST(2, 12)
  
diff --combined migration/ram.c
index f4e29cadc6703e1c7c01dd04d9cc012ac822dea1,290b281446753e34df454bf840adafdeef79a92c..a500015a2f1a8b72236f58e1a30d68f1a1d3c88c
@@@ -41,7 -41,7 +41,7 @@@
  #include "migration/misc.h"
  #include "qemu-file.h"
  #include "postcopy-ram.h"
 -#include "migration/page_cache.h"
 +#include "page_cache.h"
  #include "qemu/error-report.h"
  #include "qapi/error.h"
  #include "qapi/qapi-events-migration.h"
@@@ -51,7 -51,7 +51,7 @@@
  #include "exec/target_page.h"
  #include "qemu/rcu_queue.h"
  #include "migration/colo.h"
 -#include "migration/block.h"
 +#include "block.h"
  #include "sysemu/sysemu.h"
  #include "qemu/uuid.h"
  #include "savevm.h"
@@@ -157,11 -157,16 +157,16 @@@ out
      return ret;
  }
  
+ /* Should be holding either ram_list.mutex, or the RCU lock. */
+ #define RAMBLOCK_FOREACH_MIGRATABLE(block)             \
+     RAMBLOCK_FOREACH(block)                            \
+         if (!qemu_ram_is_migratable(block)) {} else
  static void ramblock_recv_map_init(void)
  {
      RAMBlock *rb;
  
-     RAMBLOCK_FOREACH(rb) {
+     RAMBLOCK_FOREACH_MIGRATABLE(rb) {
          assert(!rb->receivedmap);
          rb->receivedmap = bitmap_new(rb->max_length >> qemu_target_page_bits());
      }
@@@ -1078,6 -1083,10 +1083,10 @@@ unsigned long migration_bitmap_find_dir
      unsigned long *bitmap = rb->bmap;
      unsigned long next;
  
+     if (!qemu_ram_is_migratable(rb)) {
+         return size;
+     }
      if (rs->ram_bulk_stage && start > 0) {
          next = start + 1;
      } else {
@@@ -1123,7 -1132,7 +1132,7 @@@ uint64_t ram_pagesize_summary(void
      RAMBlock *block;
      uint64_t summary = 0;
  
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          summary |= block->page_size;
      }
  
@@@ -1147,7 -1156,7 +1156,7 @@@ static void migration_bitmap_sync(RAMSt
  
      qemu_mutex_lock(&rs->bitmap_mutex);
      rcu_read_lock();
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          migration_bitmap_sync_range(rs, block, 0, block->used_length);
      }
      rcu_read_unlock();
@@@ -1786,6 -1795,11 +1795,11 @@@ static int ram_save_host_page(RAMState 
      size_t pagesize_bits =
          qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS;
  
+     if (!qemu_ram_is_migratable(pss->block)) {
+         error_report("block %s should not be migrated !", pss->block->idstr);
+         return 0;
+     }
      do {
          /* Check the pages is dirty and if it is send it */
          if (!migration_bitmap_clear_dirty(rs, pss->block, pss->page)) {
@@@ -1884,7 -1898,7 +1898,7 @@@ uint64_t ram_bytes_total(void
      uint64_t total = 0;
  
      rcu_read_lock();
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          total += block->used_length;
      }
      rcu_read_unlock();
@@@ -1939,7 -1953,7 +1953,7 @@@ static void ram_save_cleanup(void *opaq
       */
      memory_global_dirty_log_stop();
  
-     QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          g_free(block->bmap);
          block->bmap = NULL;
          g_free(block->unsentmap);
@@@ -2002,7 -2016,7 +2016,7 @@@ void ram_postcopy_migrated_memory_relea
  {
      struct RAMBlock *block;
  
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          unsigned long *bitmap = block->bmap;
          unsigned long range = block->used_length >> TARGET_PAGE_BITS;
          unsigned long run_start = find_next_zero_bit(bitmap, range, 0);
@@@ -2080,7 -2094,7 +2094,7 @@@ static int postcopy_each_ram_send_disca
      struct RAMBlock *block;
      int ret;
  
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          PostcopyDiscardState *pds =
              postcopy_discard_send_init(ms, block->idstr);
  
@@@ -2288,7 -2302,7 +2302,7 @@@ int ram_postcopy_send_discard_bitmap(Mi
      rs->last_sent_block = NULL;
      rs->last_page = 0;
  
-     QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          unsigned long pages = block->used_length >> TARGET_PAGE_BITS;
          unsigned long *bitmap = block->bmap;
          unsigned long *unsentmap = block->unsentmap;
@@@ -2447,7 -2461,7 +2461,7 @@@ static void ram_list_init_bitmaps(void
  
      /* Skip setting bitmap if there is no RAM */
      if (ram_bytes_total()) {
-         QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
+         RAMBLOCK_FOREACH_MIGRATABLE(block) {
              pages = block->max_length >> TARGET_PAGE_BITS;
              block->bmap = bitmap_new(pages);
              bitmap_set(block->bmap, 0, pages);
@@@ -2563,7 -2577,7 +2577,7 @@@ static int ram_save_setup(QEMUFile *f, 
  
      qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
  
-     RAMBLOCK_FOREACH(block) {
+     RAMBLOCK_FOREACH_MIGRATABLE(block) {
          qemu_put_byte(f, strlen(block->idstr));
          qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
          qemu_put_be64(f, block->used_length);
@@@ -2807,6 -2821,11 +2821,11 @@@ static inline RAMBlock *ram_block_from_
          return NULL;
      }
  
+     if (!qemu_ram_is_migratable(block)) {
+         error_report("block %s should not be migrated !", id);
+         return NULL;
+     }
      return block;
  }
  
@@@ -2881,7 -2900,7 +2900,7 @@@ static void *do_data_decompress(void *o
  
              ret = qemu_uncompress_data(&param->stream, des, pagesize,
                                         param->compbuf, len);
-             if (ret < 0) {
+             if (ret < 0 && migrate_get_current()->decompress_error_check) {
                  error_report("decompress data failed");
                  qemu_file_set_error(decomp_file, ret);
              }
@@@ -3049,7 -3068,7 +3068,7 @@@ static int ram_load_cleanup(void *opaqu
      xbzrle_load_cleanup();
      compress_threads_load_cleanup();
  
-     RAMBLOCK_FOREACH(rb) {
+     RAMBLOCK_FOREACH_MIGRATABLE(rb) {
          g_free(rb->receivedmap);
          rb->receivedmap = NULL;
      }
@@@ -3311,7 -3330,10 +3330,10 @@@ static int ram_load(QEMUFile *f, void *
                  length = qemu_get_be64(f);
  
                  block = qemu_ram_block_by_name(id);
-                 if (block) {
+                 if (block && !qemu_ram_is_migratable(block)) {
+                     error_report("block %s should not be migrated !", id);
+                     ret = -EINVAL;
+                 } else if (block) {
                      if (length != block->used_length) {
                          Error *local_err = NULL;
  
diff --combined migration/savevm.c
index da724c52f2d0604720268b40a6237d265b8bd970,a68a9ac635eb9304d648a1f0ab0169d351638316..c2f34ffc7cd7df031d203daa8e34f4fce7943810
@@@ -55,7 -55,6 +55,7 @@@
  #include "io/channel-buffer.h"
  #include "io/channel-file.h"
  #include "sysemu/replay.h"
 +#include "qjson.h"
  
  #ifndef ETH_P_RARP
  #define ETH_P_RARP 0x8035
@@@ -2689,11 -2688,13 +2689,13 @@@ void vmstate_register_ram(MemoryRegion 
  {
      qemu_ram_set_idstr(mr->ram_block,
                         memory_region_name(mr), dev);
+     qemu_ram_set_migratable(mr->ram_block);
  }
  
  void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
  {
      qemu_ram_unset_idstr(mr->ram_block);
+     qemu_ram_unset_migratable(mr->ram_block);
  }
  
  void vmstate_register_ram_global(MemoryRegion *mr)