Skip to content
Snippets Groups Projects
  1. May 14, 2019
    • Wei Yang's avatar
      migration/ram.c: fix typos in comments · a5f7b1a6
      Wei Yang authored
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190510233729.15554-1-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      a5f7b1a6
    • Yury Kotov's avatar
      migration: Fix use-after-free during process exit · fd392cfa
      Yury Kotov authored
      
      It fixes heap-use-after-free which was found by clang's ASAN.
      
      Control flow of this use-after-free:
      main_thread:
          * Got SIGTERM and completes main loop
          * Calls migration_shutdown
            - migrate_fd_cancel (so, migration_thread begins to complete)
            - object_unref(OBJECT(current_migration));
      
      migration_thread:
          * migration_iteration_finish -> schedule cleanup bh
          * object_unref(OBJECT(s)); (Now, current_migration is freed)
          * exits
      
      main_thread:
          * Calls vm_shutdown -> drain bdrvs -> main loop
            -> cleanup_bh -> use after free
      
      If you want to reproduce, these couple of sleeps will help:
      vl.c:4613:
           migration_shutdown();
      +    sleep(2);
      migration.c:3269:
      +    sleep(1);
           trace_migration_thread_after_loop();
           migration_iteration_finish(s);
      
      Original output:
      qemu-system-x86_64: terminating on signal 15 from pid 31980 (<unknown process>)
      =================================================================
      ==31958==ERROR: AddressSanitizer: heap-use-after-free on address 0x61900001d210
        at pc 0x555558a535ca bp 0x7fffffffb190 sp 0x7fffffffb188
      READ of size 8 at 0x61900001d210 thread T0 (qemu-vm-0)
          #0 0x555558a535c9 in migrate_fd_cleanup migration/migration.c:1502:23
          #1 0x5555594fde0a in aio_bh_call util/async.c:90:5
          #2 0x5555594fe522 in aio_bh_poll util/async.c:118:13
          #3 0x555559524783 in aio_poll util/aio-posix.c:725:17
          #4 0x555559504fb3 in aio_wait_bh_oneshot util/aio-wait.c:71:5
          #5 0x5555573bddf6 in virtio_blk_data_plane_stop
            hw/block/dataplane/virtio-blk.c:282:5
          #6 0x5555589d5c09 in virtio_bus_stop_ioeventfd hw/virtio/virtio-bus.c:246:9
          #7 0x5555589e9917 in virtio_pci_stop_ioeventfd hw/virtio/virtio-pci.c:287:5
          #8 0x5555589e22bf in virtio_pci_vmstate_change hw/virtio/virtio-pci.c:1072:9
          #9 0x555557628931 in virtio_vmstate_change hw/virtio/virtio.c:2257:9
          #10 0x555557c36713 in vm_state_notify vl.c:1605:9
          #11 0x55555716ef53 in do_vm_stop cpus.c:1074:9
          #12 0x55555716eeff in vm_shutdown cpus.c:1092:12
          #13 0x555557c4283e in main vl.c:4617:5
          #14 0x7fffdfdb482f in __libc_start_main
            (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
          #15 0x555556ecb118 in _start (x86_64-softmmu/qemu-system-x86_64+0x1977118)
      
      0x61900001d210 is located 144 bytes inside of 952-byte region
        [0x61900001d180,0x61900001d538)
      freed by thread T6 (live_migration) here:
          #0 0x555556f76782 in __interceptor_free
            /tmp/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:124:3
          #1 0x555558d5fa94 in object_finalize qom/object.c:618:9
          #2 0x555558d57651 in object_unref qom/object.c:1068:9
          #3 0x555558a55588 in migration_thread migration/migration.c:3272:5
          #4 0x5555595393f2 in qemu_thread_start util/qemu-thread-posix.c:502:9
          #5 0x7fffe057f6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
      
      previously allocated by thread T0 (qemu-vm-0) here:
          #0 0x555556f76b03 in __interceptor_malloc
            /tmp/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:146:3
          #1 0x7ffff6ee37b8 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f7b8)
          #2 0x555558d58031 in object_new qom/object.c:640:12
          #3 0x555558a31f21 in migration_object_init migration/migration.c:139:25
          #4 0x555557c41398 in main vl.c:4320:5
          #5 0x7fffdfdb482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      
      Thread T6 (live_migration) created by T0 (qemu-vm-0) here:
          #0 0x555556f5f0dd in pthread_create
            /tmp/final/llvm.src/projects/compiler-rt/lib/asan/asan_interceptors.cc:210:3
          #1 0x555559538cf9 in qemu_thread_create util/qemu-thread-posix.c:539:11
          #2 0x555558a53304 in migrate_fd_connect migration/migration.c:3332:5
          #3 0x555558a72bd8 in migration_channel_connect migration/channel.c:92:5
          #4 0x555558a6ef87 in exec_start_outgoing_migration migration/exec.c:42:5
          #5 0x555558a4f3c2 in qmp_migrate migration/migration.c:1922:9
          #6 0x555558bb4f6a in qmp_marshal_migrate qapi/qapi-commands-migration.c:607:5
          #7 0x555559363738 in do_qmp_dispatch qapi/qmp-dispatch.c:131:5
          #8 0x555559362a15 in qmp_dispatch qapi/qmp-dispatch.c:174:11
          #9 0x5555571bac15 in monitor_qmp_dispatch monitor.c:4124:11
          #10 0x55555719a22d in monitor_qmp_bh_dispatcher monitor.c:4207:9
          #11 0x5555594fde0a in aio_bh_call util/async.c:90:5
          #12 0x5555594fe522 in aio_bh_poll util/async.c:118:13
          #13 0x5555595201e0 in aio_dispatch util/aio-posix.c:460:5
          #14 0x555559503553 in aio_ctx_dispatch util/async.c:261:5
          #15 0x7ffff6ede196 in g_main_context_dispatch
            (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4a196)
      
      SUMMARY: AddressSanitizer: heap-use-after-free migration/migration.c:1502:23
        in migrate_fd_cleanup
      Shadow bytes around the buggy address:
        0x0c327fffb9f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c327fffba00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c327fffba10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c327fffba20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0c327fffba30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      =>0x0c327fffba40: fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c327fffba50: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c327fffba60: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c327fffba70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c327fffba80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c327fffba90: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable: 00
        Partially addressable: 01 02 03 04 05 06 07
        Heap left redzone: fa
        Freed heap region: fd
        Stack left redzone: f1
        Stack mid redzone: f2
        Stack right redzone: f3
        Stack after return: f5
        Stack use after scope: f8
        Global redzone: f9
        Global init order: f6
        Poisoned by user: f7
        Container overflow: fc
        Array cookie: ac
        Intra object redzone: bb
        ASan internal: fe
        Left alloca redzone: ca
        Right alloca redzone: cb
        Shadow gap: cc
      ==31958==ABORTING
      
      Signed-off-by: default avatarYury Kotov <yury-kotov@yandex-team.ru>
      Message-Id: <20190408113343.2370-1-yury-kotov@yandex-team.ru>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
        Fixed up comment formatting
      fd392cfa
    • Wei Yang's avatar
      migration/savevm: wrap into qemu_loadvm_state_header() · 16015d32
      Wei Yang authored
      
      On source side, we have qemu_savevm_state_header() to send related data,
      while on the receiving side those steps are scattered in
      qemu_loadvm_state().
      
      This patch wrap those related steps into qemu_loadvm_state_header() to
      make it friendly to read.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190424004700.12766-5-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      16015d32
    • Wei Yang's avatar
      migration/savevm: load_header before load_setup · 9e14b849
      Wei Yang authored
      
      In migration_thread() and qemu_savevm_state(), we savevm_state in
      following sequence:
      
          qemu_savevm_state_header(f);
          qemu_savevm_state_setup(f);
      
      Then it would be more proper to loadvm_state in the save sequence.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190424004700.12766-4-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      9e14b849
    • Wei Yang's avatar
      migration/savevm: remove duplicate check of migration_is_blocked · 5351e69a
      Wei Yang authored
      
      Current call flow of save_snapshot is:
      
        save_snapshot
          migration_is_blocked
            qemu_savevm_state
              migration_is_blocked
      
      Since qemu_savevm_state is only called in save_snapshot, this means
      migration_is_blocked has been already checked.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190424004700.12766-2-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      5351e69a
    • Yi Wang's avatar
      migration: update comments of migration bitmap · 4633456c
      Yi Wang authored
      
      Since the ram bitmap and the unsent bitmap are split by RAMBlock
      in commit 6b6712ef, it's better to update the comments about them.
      
      Signed-off-by: default avatarYi Wang <wang.yi59@zte.com.cn>
      Message-Id: <1555311089-18610-1-git-send-email-wang.yi59@zte.com.cn>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      4633456c
    • Wei Yang's avatar
      migration/ram.c: start of migration_bitmap_sync_range is always 0 · bf212979
      Wei Yang authored
      
      We can eliminate to pass 0.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190430034412.12935-2-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      bf212979
    • Zhang Chen's avatar
      qemu-option.hx: Update missed parameter for colo-compare · 5aede7f4
      Zhang Chen authored
      
      We missed the iothread related args in this file.
      This patch is used to fix this issue.
      
      Signed-off-by: default avatarZhang Chen <chen.zhang@intel.com>
      Message-Id: <20190426090730.2691-4-chen.zhang@intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      5aede7f4
    • Zhang Chen's avatar
      migration/colo.h: Remove obsolete codes · 9c16abcb
      Zhang Chen authored
      
      Signed-off-by: default avatarZhang Chen <chen.zhang@intel.com>
      Message-Id: <20190426090730.2691-3-chen.zhang@intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      9c16abcb
    • Zhang Chen's avatar
      migration/colo.c: Remove redundant input parameter · c0913d1d
      Zhang Chen authored
      
      The colo_do_failover no need the input parameter.
      
      Signed-off-by: default avatarZhang Chen <chen.zhang@intel.com>
      Message-Id: <20190426090730.2691-2-chen.zhang@intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      c0913d1d
    • Cole Robinson's avatar
      migration: savevm: fix error code with migration blockers · aded9dfa
      Cole Robinson authored
      
      The only caller that checks the error code is looking for != 0,
      so returning false is incorrect.
      
      Fixes: 5aaac467 "migration: savevm: consult migration blockers"
      
      Signed-off-by: default avatarCole Robinson <crobinso@redhat.com>
      Message-Id: <b991a4d0e6c4253bc08b2794c6084be55fc72e1d.1554851834.git.crobinso@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      aded9dfa
    • Wei Yang's avatar
      vmstate: check subsection_found is enough · f2dd7edd
      Wei Yang authored
      
      subsection_found is true implies vmdesc is not NULL.
      
      This patch remove the additional check on vmdesc and rename
      subsection_found to vmdesc_has_subsections to make it more self-explain.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      
      Message-Id: <20190403011016.12549-1-richardw.yang@linux.intel.com>
      Acked-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      f2dd7edd
    • Wei Yang's avatar
      migration: remove not used field xfer_limit · 15d2d64c
      Wei Yang authored
      
      MigrationState->xfer_limit is only set to 0 in migrate_init().
      
      Remove this unnecessary field.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190326055726.10539-1-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      15d2d64c
    • Wei Yang's avatar
      migration: not necessary to check ops again · a94cd7b8
      Wei Yang authored
      
      During each iteration, se->ops is checked before each loop. So it is not
      necessary to check it again and simplify the following check a little.
      
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20190327013130.26259-1-richardw.yang@linux.intel.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      a94cd7b8
    • Peter Xu's avatar
      migration: comment VMSTATE_UNUSED*() properly · 772c6212
      Peter Xu authored
      
      It is error prone to use VMSTATE_UNUSED*() sometimes especially when
      the size of the migration stream of the field is not the same as the
      size of the structure (boolean is one example).  Comment it well so
      people will be aware of this when people want to use it.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20190329095713.14177-1-peterx@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      772c6212
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190513' into staging · e329ad2a
      Peter Maydell authored
      
      Improve code generation for vector duplication.
      Add vector expansions for shifts by non-constant scalar.
      Add vector expansions for shifts by vector.
      Add integer and vector expansions for absolute value.
      Several patches in preparation for Altivec.
      Bug fix for tcg/aarch64 vs min/max.
      
      # gpg: Signature made Tue 14 May 2019 00:58:02 BST
      # gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
      # gpg:                issuer "richard.henderson@linaro.org"
      # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
      # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F
      
      * remotes/rth/tags/pull-tcg-20190513: (31 commits)
        tcg/aarch64: Do not advertise minmax for MO_64
        target/xtensa: Use tcg_gen_abs_i32
        target/tricore: Use tcg_gen_abs_tl
        target/s390x: Use tcg_gen_abs_i64
        target/ppc: Use tcg_gen_abs_tl
        target/ppc: Use tcg_gen_abs_i32
        target/cris: Use tcg_gen_abs_tl
        target/arm: Use tcg_gen_abs_i64 and tcg_gen_gvec_abs
        tcg/aarch64: Support vector absolute value
        tcg/i386: Support vector absolute value
        tcg: Add support for vector absolute value
        tcg: Add support for integer absolute value
        tcg/i386: Support vector scalar shift opcodes
        tcg: Add gvec expanders for vector shift by scalar
        tcg/aarch64: Support vector variable shift opcodes
        tcg/i386: Support vector variable shift opcodes
        tcg: Add gvec expanders for variable shift
        tcg: Add INDEX_op_dupm_vec
        tcg/aarch64: Implement tcg_out_dupm_vec
        tcg/i386: Implement tcg_out_dupm_vec
        ...
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      e329ad2a
  2. May 13, 2019
Loading