Skip to content
Snippets Groups Projects
  1. Dec 21, 2017
  2. Dec 20, 2017
    • Paolo Bonzini's avatar
      contrib: add systemd unit files · 2ba60ec1
      Paolo Bonzini authored
      
      This lets distros standardize on how QEMU should install systemd
      services for qemu-ga and qemu-pr-helper.
      
      The qemu-ga unit file comes from Fedora, but I checked that
      Debian is using the same path for the virtio-serisal port.
      
      I would like to include this in 2.11, so that the qemu-pr-helper
      socket can be standardized across distros.  Note however that
      the files are not installed.  We can add a configure option
      in 2.12 perhaps, but it's too late now; documenting the files
      in the release notes should do.
      
      Suggested-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20171124164422.3960-1-pbonzini@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2ba60ec1
    • Paolo Bonzini's avatar
      qemu-pr-helper: miscellaneous fixes · a4a9b6ea
      Paolo Bonzini authored
      
      1) Return a generic sense if TEST UNIT READY does not provide one;
      
      2) Fix two mistakes in copying from the spec.
      
      Cc: qemu-stable@nongnu.org
      Reported-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a4a9b6ea
    • linzhecheng's avatar
      qemu-thread: fix races on threads that exit very quickly · 68a93982
      linzhecheng authored
      If we create a thread with QEMU_THREAD_DETACHED mode, QEMU may get a segfault with low probability.
      
      The backtrace is:
         #0  0x00007f46c60291d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
         #1  0x00007f46c602a8c8 in __GI_abort () at abort.c:90
         #2  0x00000000008543c9 in PAT_abort ()
         #3  0x000000000085140d in patchIllInsHandler ()
         #4  <signal handler called>
         #5  pthread_detach (th=139933037614848) at pthread_detach.c:50
         #6  0x0000000000829759 in qemu_thread_create (thread=thread@entry=0x7ffdaa8205e0, name=name@entry=0x94d94a "io-task-worker", start_routine=start_routine@entry=0x7eb9a0 <qio_task_thread_worker>,
             arg=arg@entry=0x3f5cf70, mode=mode@entry=1) at util/qemu_thread_posix.c:512
         #7  0x00000000007ebc96 in qio_task_run_in_thread (task=0x31db2c0, worker=worker@entry=0x7e7e40 <qio_channel_socket_connect_worker>, opaque=0xcd23380, destroy=0x7f1180 <qapi_free_SocketAddress>)
             at io/task.c:141
         #8  0x00000000007e7f33 in qio_channel_socket_connect_async (ioc=ioc@entry=0x626c0b0, addr=<optimized out>, callback=callback@entry=0x55e080 <qemu_chr_socket_connected>, opaque=opaque@entry=0x42862c0,
             destroy=destroy@entry=0x0) at io/channel_socket.c:194
         #9  0x000000000055bdd1 in socket_reconnect_timeout (opaque=0x42862c0) at qemu_char.c:4744
         #10 0x00007f46c72483b3 in g_timeout_dispatch () from /usr/lib64/libglib-2.0.so.0
         #11 0x00007f46c724799a in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
         #12 0x000000000076c646 in glib_pollfds_poll () at main_loop.c:228
         #13 0x000000000076c6eb in os_host_main_loop_wait (timeout=348000000) at main_loop.c:273
         #14 0x000000000076c815 in main_loop_wait (nonblocking=nonblocking@entry=0) at main_loop.c:521
         #15 0x000000000056a511 in main_loop () at vl.c:2076
         #16 0x0000000000420705 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4940
      
      The cause of this problem is a glibc bug; for more information, see
      https://sourceware.org/bugzilla/show_bug.cgi?id=19951
      
      .
      The solution for this bug is to use pthread_attr_setdetachstate.
      
      There is a similar issue with pthread_setname_np, which is moved
      from creating thread to created thread.
      
      Signed-off-by: default avatarlinzhecheng <linzhecheng@huawei.com>
      Message-Id: <20171128044656.10592-1-linzhecheng@huawei.com>
      Reviewed-by: default avatarFam Zheng <famz@redhat.com>
      [Simplify the code by removing qemu_thread_set_name, and free the arguments
       before invoking the start routine. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      68a93982
    • Paolo Bonzini's avatar
      memfd: fix configure test · 75e5b70e
      Paolo Bonzini authored
      
      Recent glibc added memfd_create in sys/mman.h.  This conflicts with
      the definition in util/memfd.c:
      
          /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration
      
      Fix the configure test, and remove the sys/memfd.h inclusion since the
      file actually does not exist---it is a typo in the memfd_create(2) man
      page.
      
      Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      75e5b70e
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/armbru/tags/pull-cmdline-2017-12-18-v2' into staging · 200780a3
      Peter Maydell authored
      
      Command line patches for 2017-12-18
      
      # gpg: Signature made Wed 20 Dec 2017 08:11:57 GMT
      # gpg:                using RSA key 0x3870B400EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
      
      * remotes/armbru/tags/pull-cmdline-2017-12-18-v2:
        option: Drop unused get_param_value(), get_next_param_value()
        option: Remove shadowing opt decl from qemu_opt_print()
        qemu-options: Belatedly document --watchdog-action inject-nmi
        qemu-options: Polish section "Character device options"
        qemu-options: Polish section "TPM device options"
        qemu-options: Add missing -iscsi Texinfo documentation
        qemu-options: Move -iscsi under "Block device options"
        qemu-options qemu-doc: Move "Device URL Syntax" to qemu-doc
        qemu-options: Fix markup of -netdev l2tpv3
        qemu-options: Remove stray colons from output of --help
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      200780a3
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging · f1faf2d5
      Peter Maydell authored
      
      Pull request
      
      v2:
       * Fixed incorrect virtio_blk_data_plane_create() local_err refactoring in
         "hw/block: Use errp directly rather than local_err" that broke virtio-blk
         over virtio-mmio [Peter]
      
      # gpg: Signature made Tue 19 Dec 2017 15:08:14 GMT
      # gpg:                using RSA key 0x9CA4ABB381AB73C8
      # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
      # gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
      # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8
      
      * remotes/stefanha/tags/block-pull-request: (23 commits)
        qemu-iotests: add 203 savevm with IOThreads test
        iothread: fix iothread_stop() race condition
        iotests: add VM.add_object()
        blockdev: add x-blockdev-set-iothread force boolean
        docs: mark nested AioContext locking as a legacy API
        block: avoid recursive AioContext acquire in bdrv_inactivate_all()
        virtio-blk: reject configs with logical block size > physical block size
        virtio-blk: make queue size configurable
        qemu-iotests: add 202 external snapshots IOThread test
        blockdev: add x-blockdev-set-iothread testing command
        iothread: add iothread_by_id() API
        block: drop unused BlockDirtyBitmapState->aio_context field
        block: don't keep AioContext acquired after internal_snapshot_prepare()
        block: don't keep AioContext acquired after blockdev_backup_prepare()
        block: don't keep AioContext acquired after drive_backup_prepare()
        block: don't keep AioContext acquired after external_snapshot_prepare()
        blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean()
        qdev: drop unused #include "sysemu/iothread.h"
        dev-storage: Fix the unusual function name
        hw/block: Use errp directly rather than local_err
        ...
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      
      # Conflicts:
      #	hw/core/qdev-properties-system.c
      f1faf2d5
    • Markus Armbruster's avatar
      option: Drop unused get_param_value(), get_next_param_value() · 3e05349d
      Markus Armbruster authored
      
      Their last user went away in commit f51074cd, "pci-hotplug-old: Has
      been dead for five major releases, bury", v2.3.0.  Remove them, as new
      code should use QemuOpts or maybe keyval_parse() instead.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171006131645.17729-1-armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      3e05349d
    • Dr. David Alan Gilbert's avatar
      option: Remove shadowing opt decl from qemu_opt_print() · da78e382
      Dr. David Alan Gilbert authored
      
      opt was declared as a separate local inside the last loop,
      shadowing the local at the top of the function.
      
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20171005190725.18712-1-dgilbert@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      da78e382
    • Markus Armbruster's avatar
      qemu-options: Belatedly document --watchdog-action inject-nmi · 7ad9270e
      Markus Armbruster authored
      
      Missed in commit 795dc6e4, v2.4.0.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-9-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      7ad9270e
    • Markus Armbruster's avatar
      qemu-options: Polish section "Character device options" · dddba068
      Markus Armbruster authored
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      CC: Marc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-8-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      dddba068
    • Markus Armbruster's avatar
      qemu-options: Polish section "TPM device options" · 2252aaf0
      Markus Armbruster authored
      
      Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-7-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      2252aaf0
    • Markus Armbruster's avatar
      qemu-options: Add missing -iscsi Texinfo documentation · 44743148
      Markus Armbruster authored
      
      Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-6-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: default avatarRonnie Sahlberg <ronniesahlberg@gmail.com>
      44743148
    • Markus Armbruster's avatar
      qemu-options: Move -iscsi under "Block device options" · 61d70487
      Markus Armbruster authored
      
      -iscsi ended up under the "Device URL Syntax" heading by a sequence of
      errors, as explained in the previous commit.  Move it under the "Block
      device options" heading.  Nothing left under "Device URL Syntax";
      drop the heading.
      
      Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-5-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: default avatarRonnie Sahlberg <ronniesahlberg@gmail.com>
      61d70487
    • Markus Armbruster's avatar
      qemu-options qemu-doc: Move "Device URL Syntax" to qemu-doc · e896d0f9
      Markus Armbruster authored
      
      Commit 0f5314a2 (v1.0) added section "Device URL Syntax" to
      qemu-options.hx.  It's enclosed in STEXI..ETEXI, thus affects only
      qemu-options.texi, not --help.  It appears as a subsection under
      section "Invocation".  Similarly, qemu.1 has it as a subsection under
      "OPTIONS".
      
      Commit f9dadc98 (v1.1.0) dropped new option -iscsi into the middle of
      this section.  No effect on qemu-options.texi.  It appears in --help
      run together with the "Bluetooth(R) options:" header.
      
      Commit c70a01e4 (v1.5.0) gives it is own heading in --help by moving
      commit 0f5314a2's DEFHEADING(Device URL Syntax:) outside STEXI..ETEXI.
      Trouble is the heading makes no sense for -iscsi.
      
      Move all of the "Device URL Syntax" Texinfo to qemu-doc.texi.  Mark it
      for inclusion in qemu.1 with '@c man begin NOTES'.  This turns it into
      a separate section outside the list of options both in qemu-doc and in
      qemu.1.
      
      There's substantial overlap with the existing qemu-doc section "Disk
      Images".  Mark with a TODO comment.
      
      Output of --help will be fixed next.
      
      Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-4-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: default avatarRonnie Sahlberg <ronniesahlberg@gmail.com>
      [Unwanted @node dropped]
      e896d0f9
    • Markus Armbruster's avatar
      qemu-options: Fix markup of -netdev l2tpv3 · 1e9a7379
      Markus Armbruster authored
      
      The table of option parameters lacks @table and @end table.  The
      parameters become items in the enclosing table of options.  Screwed up
      when l2tpv3 was added in commit 3fb69aa1.  Fix the obvious way.
      
      Cc: Jason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-3-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      1e9a7379
    • Markus Armbruster's avatar
      qemu-options: Remove stray colons from output of --help · de6b4f90
      Markus Armbruster authored
      
      Commit 43f187a5 broke --help: it put colons into blank lines.  It
      removed the colon from DEFHEADING(TITLE:) and added it back in the
      macro expansion of DEFHEADING(TITLE), so hxtool can emit "@subsection
      TITLE" more easily.  Trouble is it's added back even for the blank
      lines made with DEFHEADING().
      
      Put the colons back where they were before commit 43f187a5, and strip
      them in hxtool instead.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      CC: qemu-stable@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20171002140307.5292-2-armbru@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      de6b4f90
  3. Dec 19, 2017
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/aurel/tags/pull-target-sh4-20171218' into staging · af352675
      Peter Maydell authored
      
      Queued target/sh4 patches
      
      # gpg: Signature made Mon 18 Dec 2017 22:36:42 GMT
      # gpg:                using RSA key 0x1388C0F899E8336B
      # gpg: Good signature from "Aurelien Jarno <aurelien@aurel32.net>"
      # gpg:                 aka "Aurelien Jarno <aurelien@jarno.fr>"
      # gpg:                 aka "Aurelien Jarno <aurel32@debian.org>"
      # gpg: WARNING: This key is not certified with sufficiently trusted signatures!
      # gpg:          It is not certain that the signature belongs to the owner.
      # Primary key fingerprint: 7746 2642 A9EF 94FD 0F77  196D BA9C 7806 1DDD 8C9B
      #      Subkey fingerprint: 52BC 8695 BE34 F90A D7D4  0CB8 1388 C0F8 99E8 336B
      
      * remotes/aurel/tags/pull-target-sh4-20171218:
        target/sh4: Convert to DisasContextBase
        target/sh4: Do not singlestep after exceptions
        target/sh4: Convert to DisasJumpType
        target/sh4: Use cmpxchg for movco when parallel_cpus
        target/sh4: fix TCG leak during gusa sequence
        target/sh4: add missing tcg_temp_free() in _decode_opc()
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      af352675
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging · 03c1c09d
      Peter Maydell authored
      
      # gpg: Signature made Mon 18 Dec 2017 21:05:53 GMT
      # gpg:                using RSA key 0xBDBE7B27C0DE3057
      # gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>"
      # gpg:                 aka "Jeffrey Cody <jeff@codyprime.org>"
      # gpg:                 aka "Jeffrey Cody <codyprime@gmail.com>"
      # Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057
      
      * remotes/cody/tags/block-pull-request:
        block/curl: fix minor memory leaks
        block/curl: check error return of curl_global_init()
        block/sheepdog: code beautification
        block/sheepdog: remove spurious NULL check
        blockjob: kick jobs on set-speed
        backup: use copy_bitmap in incremental backup
        backup: simplify non-dirty bits progress processing
        backup: init copy_bitmap from sync_bitmap for incremental
        backup: move from done_bitmap to copy_bitmap
        hbitmap: add next_zero function
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      03c1c09d
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2017-12-19-1' into staging · 062fcb27
      Peter Maydell authored
      
      Merge tpm 2017/12/19 v1
      
      # gpg: Signature made Tue 19 Dec 2017 11:51:13 GMT
      # gpg:                using RSA key 0x75AD65802A0B4211
      # gpg: Good signature from "Stefan Berger <stefanb@linux.vnet.ibm.com>"
      # gpg: WARNING: This key is not certified with a trusted signature!
      # gpg:          There is no indication that the signature belongs to the owner.
      # Primary key fingerprint: B818 B9CA DF90 89C2 D5CE  C66B 75AD 6580 2A0B 4211
      
      * remotes/stefanberger/tags/pull-tpm-2017-12-19-1:
        tpm: move qdev_prop_tpm to hw/tpm/
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      062fcb27
    • Cornelia Huck's avatar
      tpm: move qdev_prop_tpm to hw/tpm/ · 89be9e99
      Cornelia Huck authored
      
      Building with --disable-tpm yields
      
      ../hw/core/qdev-properties-system.o: In function `set_tpm':
      /home/cohuck/git/qemu/hw/core/qdev-properties-system.c:274: undefined reference to `qemu_find_tpm_be'
      /home/cohuck/git/qemu/hw/core/qdev-properties-system.c:278: undefined reference to `tpm_backend_init'
      ../hw/core/qdev-properties-system.o: In function `release_tpm':
      /home/cohuck/git/qemu/hw/core/qdev-properties-system.c:291: undefined reference to `tpm_backend_reset'
      
      Move the implementation of DEFINE_PROP_TPMBE to hw/tpm/ so that it is
      only built when tpm is actually configured, and build tpm_util in every
      case.
      
      Fixes: 493b7830 ("qdev: add DEFINE_PROP_TPMBE")
      Reported-by: default avatarThomas Huth <thuth@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      89be9e99
    • Stefan Hajnoczi's avatar
      qemu-iotests: add 203 savevm with IOThreads test · 7a9dda0d
      Stefan Hajnoczi authored
      
      This test case will prevent future regressions with savevm and
      IOThreads.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-7-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      7a9dda0d
    • Stefan Hajnoczi's avatar
      iothread: fix iothread_stop() race condition · 2362a28e
      Stefan Hajnoczi authored
      
      There is a small chance that iothread_stop() hangs as follows:
      
        Thread 3 (Thread 0x7f63eba5f700 (LWP 16105)):
        #0  0x00007f64012c09b6 in ppoll () at /lib64/libc.so.6
        #1  0x000055959992eac9 in ppoll (__ss=0x0, __timeout=0x0, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/bits/poll2.h:77
        #2  0x000055959992eac9 in qemu_poll_ns (fds=<optimized out>, nfds=<optimized out>, timeout=<optimized out>) at util/qemu-timer.c:322
        #3  0x0000559599930711 in aio_poll (ctx=0x55959bdb83c0, blocking=blocking@entry=true) at util/aio-posix.c:629
        #4  0x00005595996806fe in iothread_run (opaque=0x55959bd78400) at iothread.c:59
        #5  0x00007f640159f609 in start_thread () at /lib64/libpthread.so.0
        #6  0x00007f64012cce6f in clone () at /lib64/libc.so.6
      
        Thread 1 (Thread 0x7f640b45b280 (LWP 16103)):
        #0  0x00007f64015a0b6d in pthread_join () at /lib64/libpthread.so.0
        #1  0x00005595999332ef in qemu_thread_join (thread=<optimized out>) at util/qemu-thread-posix.c:547
        #2  0x00005595996808ae in iothread_stop (iothread=<optimized out>) at iothread.c:91
        #3  0x000055959968094d in iothread_stop_iter (object=<optimized out>, opaque=<optimized out>) at iothread.c:102
        #4  0x0000559599857d97 in do_object_child_foreach (obj=obj@entry=0x55959bdb8100, fn=fn@entry=0x559599680930 <iothread_stop_iter>, opaque=opaque@entry=0x0, recurse=recurse@entry=false) at qom/object.c:852
        #5  0x0000559599859477 in object_child_foreach (obj=obj@entry=0x55959bdb8100, fn=fn@entry=0x559599680930 <iothread_stop_iter>, opaque=opaque@entry=0x0) at qom/object.c:867
        #6  0x0000559599680a6e in iothread_stop_all () at iothread.c:341
        #7  0x000055959955b1d5 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4913
      
      The relevant code from iothread_run() is:
      
        while (!atomic_read(&iothread->stopping)) {
            aio_poll(iothread->ctx, true);
      
      and iothread_stop():
      
        iothread->stopping = true;
        aio_notify(iothread->ctx);
        ...
        qemu_thread_join(&iothread->thread);
      
      The following scenario can occur:
      
      1. IOThread:
        while (!atomic_read(&iothread->stopping)) -> stopping=false
      
      2. Main loop:
        iothread->stopping = true;
        aio_notify(iothread->ctx);
      
      3. IOThread:
        aio_poll(iothread->ctx, true); -> hang
      
      The bug is explained by the AioContext->notify_me doc comments:
      
        "If this field is 0, everything (file descriptors, bottom halves,
        timers) will be re-evaluated before the next blocking poll(), thus the
        event_notifier_set call can be skipped."
      
      The problem is that "everything" does not include checking
      iothread->stopping.  This means iothread_run() will block in aio_poll()
      if aio_notify() was called just before aio_poll().
      
      This patch fixes the hang by replacing aio_notify() with
      aio_bh_schedule_oneshot().  This makes aio_poll() or g_main_loop_run()
      to return.
      
      Implementing this properly required a new bool running flag.  The new
      flag prevents races that are tricky if we try to use iothread->stopping.
      Now iothread->stopping is purely for iothread_stop() and
      iothread->running is purely for the iothread_run() thread.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-6-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      2362a28e
    • Stefan Hajnoczi's avatar
      iotests: add VM.add_object() · ccc15f7d
      Stefan Hajnoczi authored
      
      The VM.add_object() method can be used to add IOThreads or memory
      backend objects.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-5-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      ccc15f7d
    • Stefan Hajnoczi's avatar
      blockdev: add x-blockdev-set-iothread force boolean · 882e9b89
      Stefan Hajnoczi authored
      
      When a node is already associated with a BlockBackend the
      x-blockdev-set-iothread command refuses to set the IOThread.  This is to
      prevent accidentally changing the IOThread when the nodes are in use.
      
      When the nodes are created with -drive they automatically get a
      BlockBackend.  In that case we know nothing is using them yet and it's
      safe to set the IOThread.  Add a force boolean to override the check.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-4-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      882e9b89
    • Stefan Hajnoczi's avatar
      docs: mark nested AioContext locking as a legacy API · d02d8dde
      Stefan Hajnoczi authored
      
      See the patch for why nested AioContext locking is no longer allowed.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-3-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      d02d8dde
    • Paolo Bonzini's avatar
      block: avoid recursive AioContext acquire in bdrv_inactivate_all() · bd6458e4
      Paolo Bonzini authored
      
      BDRV_POLL_WHILE() does not support recursive AioContext locking.  It
      only releases the AioContext lock once regardless of how many times the
      caller has acquired it.  This results in a hang since the IOThread does
      not make progress while the AioContext is still locked.
      
      The following steps trigger the hang:
      
        $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
                             -object iothread,id=iothread0 \
                             -device virtio-scsi-pci,iothread=iothread0 \
                             -drive if=none,id=drive0,file=test.img,format=raw \
                             -device scsi-hd,drive=drive0 \
                             -drive if=none,id=drive1,file=test.img,format=raw \
                             -device scsi-hd,drive=drive1
        $ qemu-system-x86_64 ...same options... \
                             -incoming tcp::1234
        (qemu) migrate tcp:127.0.0.1:1234
        ...hang...
      
      Tested-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20171207201320.19284-2-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      bd6458e4
Loading