1. 07 11月, 2018 1 次提交
  2. 19 10月, 2018 3 次提交
  3. 03 10月, 2018 6 次提交
  4. 29 8月, 2018 1 次提交
  5. 28 8月, 2018 1 次提交
  6. 24 8月, 2018 5 次提交
    • P
      cpus: allow cpu_get_ticks out of BQL · f2a4ad6d
      Paolo Bonzini 提交于
      Because of cpu_ticks_prev, we cannot use a seqlock.  But then the conversion
      is even easier. :)
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f2a4ad6d
    • P
      cpus: protect TimerState writes with a spinlock · 94377115
      Paolo Bonzini 提交于
      In the next patch, we will need to write cpu_ticks_offset from any
      thread, even outside the BQL.  Currently, it is protected by the BQL
      just because cpu_enable_ticks and cpu_disable_ticks happen to hold it,
      but the critical sections are well delimited and it's easy to remove
      the BQL dependency.
      
      Add a spinlock that matches vm_clock_seqlock, and hold it when writing
      to the TimerState.  This also lets us fix cpu_update_icount when 64-bit
      atomics are not available.
      
      Fields of TiemrState are reordered to avoid padding.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      94377115
    • P
      cpus: protect all icount computation with seqlock · c1ff073c
      Paolo Bonzini 提交于
      Move the icount->ns computation to cpu_get_icount, and make
      cpu_get_icount_locked return the raw value.  This makes the
      atomic_read__nocheck safe, because it now happens always inside a
      seqlock and any torn reads will be retried.  qemu_icount_bias and
      icount_time_shift also need to be accessed with atomics.  At the
      same time, however, you don't need atomic_read within the writer,
      because no concurrent writes are possible.
      
      The fix to vmstate lets us keep the struct nicely packed.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c1ff073c
    • E
      qom: convert the CPU list to RCU · 068a5ea0
      Emilio G. Cota 提交于
      Iterating over the list without using atomics is undefined behaviour,
      since the list can be modified concurrently by other threads (e.g.
      every time a new thread is created in user-mode).
      
      Fix it by implementing the CPU list as an RCU QTAILQ. This requires
      a little bit of extra work to traverse list in reverse order (see
      previous patch), but other than that the conversion is trivial.
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <20180819091335.22863-12-cota@braap.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      068a5ea0
    • E
      qsp: track BQL callers explicitly · cb764d06
      Emilio G. Cota 提交于
      The BQL is acquired via qemu_mutex_lock_iothread(), which makes
      the profiler assign the associated wait time (i.e. most of
      BQL wait time) entirely to that function. This loses the original
      call site information, which does not help diagnose BQL contention.
      Fix it by tracking the callers explicitly.
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cb764d06
  7. 23 6月, 2018 1 次提交
  8. 22 6月, 2018 1 次提交
  9. 09 5月, 2018 2 次提交
    • C
      cpus: tcg: fix never exiting loop on unplug · 54961aac
      Cédric Le Goater 提交于
      Commit 9b0605f9 ("cpus: tcg: unregister thread with RCU, fix
      exiting of loop on unplug") changed the exit condition of the loop in
      the vCPU thread function but forgot to remove the beginning 'while (1)'
      statement. The resulting code :
      
      	while (1) {
      	...
      	} while (!cpu->unplug || cpu_can_run(cpu));
      
      is a sequence of two distinct two while() loops, the first not exiting
      in case of an unplug event.
      
      Remove the first while (1) to fix CPU unplug.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Message-Id: <20180425131828.15604-1-clg@kaod.org>
      Cc: qemu-stable@nongnu.org
      Fixes: 9b0605f9Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      54961aac
    • M
      cpus: Fix event order on resume of stopped guest · f056158d
      Markus Armbruster 提交于
      When resume of a stopped guest immediately runs into block device
      errors, the BLOCK_IO_ERROR event is sent before the RESUME event.
      
      Reproducer:
      
      1. Create a scratch image
         $ dd if=/dev/zero of=scratch.img bs=1M count=100
      
         Size doesn't actually matter.
      
      2. Prepare blkdebug configuration:
      
         $ cat >blkdebug.conf <<EOF
         [inject-error]
         event = "write_aio"
         errno = "5"
         EOF
      
         Note that errno 5 is EIO.
      
      3. Run a guest with an additional scratch disk, i.e. with additional
         arguments
         -drive if=none,id=scratch-drive,format=raw,werror=stop,file=blkdebug:blkdebug.conf:scratch.img
         -device virtio-blk-pci,id=scratch,drive=scratch-drive
      
         The blkdebug part makes all writes to the scratch drive fail with
         EIO.  The werror=stop pauses the guest on write errors.
      
      4. Connect to the QMP socket e.g. like this:
         $ socat UNIX:/your/qmp/socket READLINE,history=$HOME/.qmp_history,prompt='QMP> '
      
         Issue QMP command 'qmp_capabilities':
         QMP> { "execute": "qmp_capabilities" }
      
      5. Boot the guest.
      
      6. In the guest, write to the scratch disk, e.g. like this:
      
         # dd if=/dev/zero of=/dev/vdb count=1
      
         Do double-check the device specified with of= is actually the
         scratch device!
      
      7. Issue QMP command 'cont':
         QMP> { "execute": "cont" }
      
      After step 6, I get a BLOCK_IO_ERROR event followed by a STOP event.  Good.
      
      After step 7, I get BLOCK_IO_ERROR, then RESUME, then STOP.  Not so
      good; I'd expect RESUME, then BLOCK_IO_ERROR, then STOP.
      
      The funny event order confuses libvirt: virsh -r domstate DOMAIN
      --reason reports "paused (unknown)" rather than "paused (I/O error)".
      
      The culprit is vm_prepare_start().
      
          /* Ensure that a STOP/RESUME pair of events is emitted if a
           * vmstop request was pending.  The BLOCK_IO_ERROR event, for
           * example, according to documentation is always followed by
           * the STOP event.
           */
          if (runstate_is_running()) {
              qapi_event_send_stop(&error_abort);
              res = -1;
          } else {
              replay_enable_events();
              cpu_enable_ticks();
              runstate_set(RUN_STATE_RUNNING);
              vm_state_notify(1, RUN_STATE_RUNNING);
          }
      
          /* We are sending this now, but the CPUs will be resumed shortly later */
          qapi_event_send_resume(&error_abort);
          return res;
      
      When resuming a stopped guest, we take the else branch before we get
      to sending RESUME.  vm_state_notify() runs virtio_vmstate_change(),
      among other things.  This restarts I/O, triggering the BLOCK_IO_ERROR
      event.
      
      Reshuffle vm_prepare_start() to send the RESUME event earlier.
      
      Fixes RHBZ 1566153.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180423084518.2426-1-armbru@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f056158d
  10. 04 5月, 2018 2 次提交
    • L
      qapi: discriminate CpuInfoFast on SysEmuTarget, not CpuInfoArch · daa9d2bc
      Laszlo Ersek 提交于
      Add a new field @target (of type @SysEmuTarget) to the output of the
      @query-cpus-fast command, which provides more information about the
      emulation target than the field @arch (of type @CpuInfoArch). Make @target
      the new discriminator for the @CpuInfoFast return structure. Keep @arch
      for compatibility.
      
      Cc: "Daniel P. Berrange" <berrange@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20180427192852.15013-5-lersek@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      daa9d2bc
    • L
      qapi: fill in CpuInfoFast.arch in query-cpus-fast · 96054f56
      Laszlo Ersek 提交于
      * Commit ca230ff3 added the @arch field to @CpuInfoFast, but it failed
        to set the new field in qmp_query_cpus_fast(), when TARGET_S390X was not
        defined. The updated @query-cpus-fast example in "qapi-schema.json"
        showed "arch":"x86" only because qmp_query_cpus_fast() calls g_malloc0()
        to allocate @CpuInfoFast, and the CPU_INFO_ARCH_X86 enum constant is
        generated with value 0.
      
        All @arch values other than @s390 implied the @CpuInfoOther sub-struct
        for @CpuInfoFast -- at the time of writing the patch --, thus no fields
        other than @arch needed to be set when TARGET_S390X was not defined. Set
        @arch now, by copying the corresponding assignments from
        qmp_query_cpus().
      
      * Commit 25fa194b added the @riscv enum constant to @CpuInfoArch (used
        in both @CpuInfo and @CpuInfoFast -- the return types of the @query-cpus
        and @query-cpus-fast commands, respectively), and assigned, in both
        return structures, the @CpuInfoRISCV sub-structure to the new enum
        value.
      
        However, qmp_query_cpus_fast() would not populate either the @arch field
        or the @CpuInfoRISCV sub-structure, when TARGET_RISCV was defined; only
        qmp_query_cpus() would.
      
        Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and
        populate only the @arch field in qmp_query_cpus_fast(). Getting CPU
        state without interrupting KVM is an exceptional thing that only S390X
        does currently. Quoting Cornelia Huck <cohuck@redhat.com>, "s390x is
        exceptional in that it has state in QEMU that is actually interesting
        for upper layers and can be retrieved without performance penalty". See
        also
        <https://www.redhat.com/archives/libvir-list/2018-February/msg00121.html>.
      
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Viktor VM Mihajlovski <mihajlov@linux.vnet.ibm.com>
      Cc: qemu-stable@nongnu.org
      Fixes: ca230ff3
      Fixes: 25fa194bSigned-off-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NCornelia Huck <cohuck@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180427192852.15013-2-lersek@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      96054f56
  11. 10 4月, 2018 1 次提交
  12. 13 3月, 2018 1 次提交
  13. 09 3月, 2018 1 次提交
    • S
      vl: introduce vm_shutdown() · 4486e89c
      Stefan Hajnoczi 提交于
      Commit 00d09fdb ("vl: pause vcpus before
      stopping iothreads") and commit dce8921b
      ("iothread: Stop threads before main() quits") tried to work around the
      fact that emulation was still active during termination by stopping
      iothreads.  They suffer from race conditions:
      1. virtio_scsi_handle_cmd_vq() racing with iothread_stop_all() hits the
         virtio_scsi_ctx_check() assertion failure because the BDS AioContext
         has been modified by iothread_stop_all().
      2. Guest vq kick racing with main loop termination leaves a readable
         ioeventfd that is handled by the next aio_poll() when external
         clients are enabled again, resulting in unwanted emulation activity.
      
      This patch obsoletes those commits by fully disabling emulation activity
      when vcpus are stopped.
      
      Use the new vm_shutdown() function instead of pause_all_vcpus() so that
      vm change state handlers are invoked too.  Virtio devices will now stop
      their ioeventfds, preventing further emulation activity after vm_stop().
      
      Note that vm_stop(RUN_STATE_SHUTDOWN) cannot be used because it emits a
      QMP STOP event that may affect existing clients.
      
      It is no longer necessary to call replay_disable_events() directly since
      vm_shutdown() does so already.
      
      Drop iothread_stop_all() since it is no longer used.
      
      Cc: Fam Zheng <famz@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20180307144205.20619-5-stefanha@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4486e89c
  14. 07 3月, 2018 1 次提交
  15. 06 3月, 2018 3 次提交
  16. 03 3月, 2018 2 次提交
    • M
      qapi: Empty out qapi-schema.json · 112ed241
      Markus Armbruster 提交于
      The previous commit improved compile time by including less of the
      generated QAPI headers.  This is impossible for stuff defined directly
      in qapi-schema.json, because that ends up in headers that that pull in
      everything.
      
      Move everything but include directives from qapi-schema.json to new
      sub-module qapi/misc.json, then include just the "misc" shard where
      possible.
      
      It's possible everywhere, except:
      
      * monitor.c needs qmp-command.h to get qmp_init_marshal()
      
      * monitor.c, ui/vnc.c and the generated qapi-event-FOO.c need
        qapi-event.h to get enum QAPIEvent
      
      Perhaps we'll get rid of those some other day.
      
      Adding a type to qapi/migration.json now recompiles some 120 instead
      of 2300 out of 5100 objects.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-25-armbru@redhat.com>
      [eblake: rebase to master]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      112ed241
    • M
      Include less of the generated modular QAPI headers · 9af23989
      Markus Armbruster 提交于
      In my "build everything" tree, a change to the types in
      qapi-schema.json triggers a recompile of about 4800 out of 5100
      objects.
      
      The previous commit split up qmp-commands.h, qmp-event.h, qmp-visit.h,
      qapi-types.h.  Each of these headers still includes all its shards.
      Reduce compile time by including just the shards we actually need.
      
      To illustrate the benefits: adding a type to qapi/migration.json now
      recompiles some 2300 instead of 4800 objects.  The next commit will
      improve it further.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-24-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      [eblake: rebase to master]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      9af23989
  17. 26 2月, 2018 3 次提交
  18. 09 2月, 2018 2 次提交
  19. 07 2月, 2018 3 次提交