1. 18 6月, 2019 5 次提交
  2. 12 6月, 2019 2 次提交
  3. 15 5月, 2019 1 次提交
  4. 01 5月, 2019 1 次提交
    • D
      hmp: gva2gpa debug command · 574d9693
      Dr. David Alan Gilbert 提交于
      Add a gva2gpa command purely for debug which performs
      address translation on the gva, the existing gpa2hva
      command can then also be used to find it in the qemu
      userspace; e.g.
      
      (qemu) info registers
      .... RSP=ffffffff81c03e98
      ....
      (qemu) gva2gpa 0xffffffff81c03e98
      gpa: 0x1c03e98
      (qemu) gpa2hva 0x1c03e98
      Host virtual address for 0x1c03e98 (pc.ram) is 0x7f0599a03e98
      (qemu) x/10x 0xffffffff81c03e98
      ffffffff81c03e98: 0x81c03eb8 0xffffffff 0x8101ea3f 0xffffffff
      ffffffff81c03ea8: 0x81d27b00 0xffffffff 0x00000000 0x00000000
      ffffffff81c03eb8: 0x81c03ec8 0xffffffff
      
      gdb -p ...qemu...
      (gdb) x/10x 0x7f0599a03e98
      0x7f0599a03e98:	0x81c03eb8	0xffffffff	0x8101ea3f	0xffffffff
      0x7f0599a03ea8:	0x81d27b00	0xffffffff	0x00000000	0x00000000
      0x7f0599a03eb8:	0x81c03ec8	0xffffffff
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20190412152652.827-1-dgilbert@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      574d9693
  5. 19 4月, 2019 11 次提交
  6. 18 3月, 2019 1 次提交
  7. 11 3月, 2019 1 次提交
  8. 26 2月, 2019 1 次提交
  9. 18 2月, 2019 7 次提交
  10. 05 2月, 2019 1 次提交
    • P
      monitor: do not use QTAILQ_FOREACH_SAFE across critical sections · 82e870ba
      Paolo Bonzini 提交于
      monitor_qmp_requests_pop_any_with_lock cannot modify the monitor list
      concurrently with monitor_cleanup, since the dispatch bottom half
      runs in the main thread, but anyway it is a bit ugly to keep
      "next" live across critical sections of monitor_lock and Coverity
      complains (CID 1397072).
      
      Replace QTAILQ_FOREACH_SAFE with a while loop and QTAILQ_FIRST,
      it is cleaner and more future-proof.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      82e870ba
  11. 24 1月, 2019 1 次提交
    • M
      qapi: Eliminate indirection through qmp_event_get_func_emit() · a9529100
      Markus Armbruster 提交于
      The qapi_event_send_FOO() functions emit events like this:
      
          QMPEventFuncEmit emit;
      
          emit = qmp_event_get_func_emit();
          if (!emit) {
              return;
          }
      
          qmp = qmp_event_build_dict("FOO");
          [put event arguments into @qmp...]
      
          emit(QAPI_EVENT_FOO, qmp);
      
      The value of qmp_event_get_func_emit() depends only on the program:
      
      * In qemu-system-FOO, it's always monitor_qapi_event_queue.
      
      * In tests/test-qmp-event, it's always event_test_emit.
      
      * In all other programs, it's always null.
      
      This is exactly the kind of dependence the linker is supposed to
      resolve; we don't actually need an indirection.
      
      Note that things would fall apart if we linked more than one QAPI
      schema into a single program: each set of qapi_event_send_FOO() uses
      its own event enumeration, yet they share a single emit function.
      Which takes the event enumeration as an argument.  Which one if
      there's more than one?
      
      More seriously: how does this work even now?  qemu-system-FOO wants
      QAPIEvent, and passes a function taking that to
      qmp_event_set_func_emit().  test-qmp-event wants test_QAPIEvent, and
      passes a function taking that to qmp_event_set_func_emit().
      
      It works by type trickery, of course:
      
          typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict);
      
          void qmp_event_set_func_emit(QMPEventFuncEmit emit);
      
          QMPEventFuncEmit qmp_event_get_func_emit(void);
      
      We use unsigned instead of the enumeration type.  Relies on both
      enumerations boiling down to unsigned, which happens to be true for
      the compilers we use.
      
      Clean this up as follows:
      
      * Generate qapi_event_send_FOO() that call PREFIX_qapi_event_emit()
        instead of the value of qmp_event_set_func_emit().
      
      * Generate a prototype for PREFIX_qapi_event_emit() into
        qapi-events.h.
      
      * PREFIX_ is empty for qapi/qapi-schema.json, and test_ for
        tests/qapi-schema/qapi-schema-test.json.  It's qga_ for
        qga/qapi-schema.json, and doc-good- for
        tests/qapi-schema/doc-good.json, but those don't define any events.
      
      * Rename monitor_qapi_event_queue() to qapi_event_emit() instead of
        passing it to qmp_event_set_func_emit().  This takes care of
        qemu-system-FOO.
      
      * Rename event_test_emit() to test_qapi_event_emit() instead of
        passing it to qmp_event_set_func_emit().  This takes care of
        tests/test-qmp-event.
      
      * Add a qapi_event_emit() that does nothing to stubs/monitor.c.  This
        takes care of all other programs that link code emitting QMP events.
      
      * Drop qmp_event_set_func_emit(), qmp_event_get_func_emit().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20181218182234.28876-3-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      [Commit message typos fixed]
      a9529100
  12. 11 1月, 2019 1 次提交
    • P
      qemu/queue.h: leave head structs anonymous unless necessary · b58deb34
      Paolo Bonzini 提交于
      Most list head structs need not be given a name.  In most cases the
      name is given just in case one is going to use QTAILQ_LAST, QTAILQ_PREV
      or reverse iteration, but this does not apply to lists of other kinds,
      and even for QTAILQ in practice this is only rarely needed.  In addition,
      we will soon reimplement those macros completely so that they do not
      need a name for the head struct.  So clean up everything, not giving a
      name except in the rare case where it is necessary.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b58deb34
  13. 14 12月, 2018 3 次提交
  14. 12 12月, 2018 4 次提交
    • P
      monitor: Remove "x-oob", offer capability "oob" unconditionally · 8258292e
      Peter Xu 提交于
      Out-of-band command execution was introduced in commit cf869d53.
      Unfortunately, we ran into a regression, and had to turn it into an
      experimental option for 2.12 (commit be933ffc).
      
        http://lists.gnu.org/archive/html/qemu-devel/2018-03/msg06231.html
      
      The regression has since been fixed (commit 951702f3 "monitor: bind
      dispatch bh to iohandler context").  A thorough re-review of OOB
      commands led to a few more issues, which have also been addressed.
      
      This patch partly reverts be933ffc (monitor: new parameter "x-oob"),
      and makes QMP monitors again offer capability "oob" whenever they can
      provide it, i.e. when the monitor's character device is capable of
      running in an I/O thread.
      
      Some trivial touch-up in the test code is required to make sure qmp-test
      won't break.
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <20181009062718.1914-4-peterx@redhat.com>
      [Conflict with "monitor: check if chardev can switch gcontext for OOB"
      resolved, commit message updated]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      8258292e
    • P
      monitor: Suspend monitor instead dropping commands · 9ab84470
      Peter Xu 提交于
      When a QMP client sends in-band commands more quickly that we can
      process them, we can either queue them without limit (QUEUE), drop
      commands when the queue is full (DROP), or suspend receiving commands
      when the queue is full (SUSPEND).  None of them is ideal:
      
      * QUEUE lets a misbehaving client make QEMU eat memory without bounds.
      Not such a hot idea.
      
      * With DROP, the client has to cope with dropped in-band commands.  To
      inform the client, we send a COMMAND_DROPPED event then.  The event is
      flawed by design in two ways: it's ambiguous (see commit d621cfe0),
      and it brings back the "eat memory without bounds" problem.
      
      * With SUSPEND, the client has to manage the flow of in-band commands to
      keep the monitor available for out-of-band commands.
      
      We currently DROP.  Switch to SUSPEND.
      
      Managing the flow of in-band commands to keep the monitor available for
      out-of-band commands isn't really hard: just count the number of
      "outstanding" in-band commands (commands sent minus replies received),
      and if it exceeds the limit, hold back additional ones until it drops
      below the limit again.
      
      Note that we need to be careful pairing the suspend with a resume, or
      else the monitor will hang, possibly forever.  And here since we need to
      make sure both:
      
           (1) popping request from the req queue, and
           (2) reading length of the req queue
      
      will be in the same critical section, we let the pop function take the
      corresponding queue lock when there is a request, then we release the
      lock from the caller.
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <20181009062718.1914-2-peterx@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9ab84470
    • M
      monitor: avoid potential dead-lock when cleaning up · 34f1f3e0
      Marc-André Lureau 提交于
      When a monitor is connected to a Spice chardev, the monitor cleanup
      can dead-lock:
      
       #0  0x00007f43446637fd in __lll_lock_wait () at /lib64/libpthread.so.0
       #1  0x00007f434465ccf4 in pthread_mutex_lock () at /lib64/libpthread.so.0
       #2  0x0000556dd79f22ba in qemu_mutex_lock_impl (mutex=0x556dd81c9220 <monitor_lock>, file=0x556dd7ae3648 "/home/elmarco/src/qq/monitor.c", line=645) at /home/elmarco/src/qq/util/qemu-thread-posix.c:66
       #3  0x0000556dd7431bd5 in monitor_qapi_event_queue (event=QAPI_EVENT_SPICE_DISCONNECTED, qdict=0x556dd9abc850, errp=0x7fffb7bbddd8) at /home/elmarco/src/qq/monitor.c:645
       #4  0x0000556dd79d476b in qapi_event_send_spice_disconnected (server=0x556dd98ee760, client=0x556ddaaa8560, errp=0x556dd82180d0 <error_abort>) at qapi/qapi-events-ui.c:149
       #5  0x0000556dd7870fc1 in channel_event (event=3, info=0x556ddad1b590) at /home/elmarco/src/qq/ui/spice-core.c:235
       #6  0x00007f434560a6bb in reds_handle_channel_event (reds=<optimized out>, event=3, info=0x556ddad1b590) at reds.c:316
       #7  0x00007f43455f393b in main_dispatcher_self_handle_channel_event (info=0x556ddad1b590, event=3, self=0x556dd9a7d8c0) at main-dispatcher.c:197
       #8  0x00007f43455f393b in main_dispatcher_channel_event (self=0x556dd9a7d8c0, event=event@entry=3, info=0x556ddad1b590) at main-dispatcher.c:197
       #9  0x00007f4345612833 in red_stream_push_channel_event (s=s@entry=0x556ddae2ef40, event=event@entry=3) at red-stream.c:414
       #10 0x00007f434561286b in red_stream_free (s=0x556ddae2ef40) at red-stream.c:388
       #11 0x00007f43455f9ddc in red_channel_client_finalize (object=0x556dd9bb21a0) at red-channel-client.c:347
       #12 0x00007f434b5f9fb9 in g_object_unref () at /lib64/libgobject-2.0.so.0
       #13 0x00007f43455fc212 in red_channel_client_push (rcc=0x556dd9bb21a0) at red-channel-client.c:1341
       #14 0x0000556dd76081ba in spice_port_set_fe_open (chr=0x556dd9925e20, fe_open=0) at /home/elmarco/src/qq/chardev/spice.c:241
       #15 0x0000556dd796d74a in qemu_chr_fe_set_open (be=0x556dd9a37c00, fe_open=0) at /home/elmarco/src/qq/chardev/char-fe.c:340
       #16 0x0000556dd796d4d9 in qemu_chr_fe_set_handlers (b=0x556dd9a37c00, fd_can_read=0x0, fd_read=0x0, fd_event=0x0, be_change=0x0, opaque=0x0, context=0x0, set_open=true) at /home/elmarco/src/qq/chardev/char-fe.c:280
       #17 0x0000556dd796d359 in qemu_chr_fe_deinit (b=0x556dd9a37c00, del=false) at /home/elmarco/src/qq/chardev/char-fe.c:233
       #18 0x0000556dd7432240 in monitor_data_destroy (mon=0x556dd9a37c00) at /home/elmarco/src/qq/monitor.c:786
       #19 0x0000556dd743b968 in monitor_cleanup () at /home/elmarco/src/qq/monitor.c:4683
       #20 0x0000556dd75ce776 in main (argc=3, argv=0x7fffb7bbe458, envp=0x7fffb7bbe478) at /home/elmarco/src/qq/vl.c:4660
      
      Because spice code tries to emit a "disconnected" signal on the
      monitors. Fix this dead-lock by releasing the monitor lock for
      flush/destroy.
      
      monitor_lock protects mon_list, monitor_qapi_event_state and
      monitor_destroyed. monitor_flush() and monitor_data_destroy() don't
      access any of those variables.
      
      monitor_cleanup()'s loop is safe because it uses
      QTAILQ_FOREACH_SAFE(), and no further monitor can be added after
      calling monitor_cleanup() thanks to monitor_destroyed check in
      monitor_list_append().
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20181205203737.9011-8-marcandre.lureau@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      34f1f3e0
    • M
      monitor: prevent inserting new monitors after cleanup · 8dac00bb
      Marc-André Lureau 提交于
      monitor_cleanup() is one of the last things main() calls before it
      returns.  In the following patch, monitor_cleanup() will release the
      monitor_lock during flushing. There may be pending commands to insert
      new monitors, which would modify the mon_list during iteration, and
      the clean-up could thus miss those new insertions.
      
      Add a monitor_destroyed global to check if monitor_cleanup() has been
      already called. In this case, don't insert the new monitor in the
      list, but free it instead. A cleaner solution would involve the main
      thread telling other threads to terminate, waiting for their
      termination.
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20181205203737.9011-7-marcandre.lureau@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      8dac00bb