1. 18 2月, 2019 2 次提交
    • M
      qapi: Prepare for system modules other than 'builtin' · c2e196a9
      Markus Armbruster 提交于
      The next commit wants to generate qapi-emit-events.{c.h}.  To enable
      that, extend QAPISchemaModularCVisitor to support additional "system
      modules", i.e. modules that don't correspond to a (user-defined) QAPI
      schema module.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20190214152251.2073-5-armbru@redhat.com>
      c2e196a9
    • M
      qapi: Clean up modular built-in code generation a bit · dcac6471
      Markus Armbruster 提交于
      We neglect to call .visit_module() for the special module we use for
      built-ins.  Harmless, but clean it up anyway.  The
      tests/qapi-schema/*.out now show the built-in module as 'module None'.
      
      Subclasses of QAPISchemaModularCVisitor need to ._add_module() this
      special module to enable code generation for built-ins.  When this
      hasn't been done, QAPISchemaModularCVisitor.visit_module() does
      nothing for the special module.  That looks like built-ins could
      accidentally be generated into the wrong module when a subclass
      neglects to call ._add_module().  Can't happen, because built-ins are
      all visited before any other module.  But that's non-obvious.  Switch
      off code generation explicitly.
      
      Rename QAPISchemaModularCVisitor._begin_module() to
      ._begin_user_module().
      
      New QAPISchemaModularCVisitor._is_builtin_module(), for clarity.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20190214152251.2073-4-armbru@redhat.com>
      dcac6471
  2. 12 2月, 2019 1 次提交
  3. 09 2月, 2019 2 次提交
  4. 06 2月, 2019 1 次提交
  5. 05 2月, 2019 2 次提交
  6. 04 2月, 2019 1 次提交
  7. 01 2月, 2019 1 次提交
    • A
      qtest.py: Wait for the result of qtest commands · a5df73ba
      Alberto Garcia 提交于
      The cmd() method of the QEMUQtestProtocol class sends a qtest command
      to QEMU but doesn't wait for the return message ("OK", "FAIL", "ERR").
      Because of this, it can return control to the caller before the
      command has actually finished.
      
      In cases like clock_step or clock_set this means that cmd() can return
      before all the timers triggered by the clock change have been fired.
      This can be fixed by making cmd() wait for the output of the qtest
      command.
      
      This fixes iotests 093 and 136, which are flaky since commit
      8258292e when the machine is under heavy workload.
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a5df73ba
  8. 31 1月, 2019 1 次提交
  9. 29 1月, 2019 1 次提交
    • P
      checkpatch: Don't emit spurious warnings about block comments · b94e809d
      Peter Maydell 提交于
      In checkpatch we attempt to check for and warn about
      block comments which start with /* or /** followed by a
      non-blank. Unfortunately a bug in the regex meant that
      we would incorrectly warn about comments starting with
      "/**" with no following text:
      
        git show 9813dc6a|./scripts/checkpatch.pl -
        WARNING: Block comments use a leading /* on a separate line
        #34: FILE: tests/libqtest.h:233:
        +/**
      
      The sequence "/\*\*?" was intended to match either "/*" or "/**",
      but Perl's semantics for '?' allow it to backtrack and try the
      "matches 0 chars" option if the "matches 1 char" choice leads to
      a failure of the rest of the regex to match.  Switch to "/\*\*?+"
      which uses what perlre(1) calls the "possessive" quantifier form:
      this means that if it matches the "/**" string it will not later
      backtrack to matching just the "/*" prefix.
      
      The other end of the regex is also wrong: it is attempting
      to check for "/* or /** followed by something that isn't
      just whitespace", but [ \t]*.+[ \t]* will match on pure
      whitespace. This is less significant but means that a line
      with just a comment-starter followed by trailing whitespace
      will generate an incorrect warning about block comment style
      as well as the correct error about trailing whitespace which
      a different checkpatch test emits.
      
      Fixes: 8c06fbdf ("scripts/checkpatch.pl: Enforce multiline comment syntax")
      Reported-by: NThomas Huth <thuth@redhat.com>
      Reported-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 20190118165050.22270-1-peter.maydell@linaro.org
      b94e809d
  10. 25 1月, 2019 2 次提交
  11. 24 1月, 2019 4 次提交
    • D
      trace: add ability to do simple printf logging via systemtap · 62dd1048
      Daniel P. Berrangé 提交于
      The dtrace systemtap trace backend for QEMU is very powerful but it is
      also somewhat unfriendly to users who aren't familiar with systemtap,
      or who don't need its power right now.
      
        stap -e "....some strange script...."
      
      The 'log' backend for QEMU by comparison is very crude but incredibly
      easy to use:
      
       $ qemu -d trace:qio* ...some args...
       23266@1547735759.137292:qio_channel_socket_new Socket new ioc=0x563a8a39d400
       23266@1547735759.137305:qio_task_new Task new task=0x563a891d0570 source=0x563a8a39d400 func=0x563a86f1e6c0 opaque=0x563a89078000
       23266@1547735759.137326:qio_task_thread_start Task thread start task=0x563a891d0570 worker=0x563a86f1ce50 opaque=0x563a891d9d90
       23273@1547735759.137491:qio_task_thread_run Task thread run task=0x563a891d0570
       23273@1547735759.137503:qio_channel_socket_connect_sync Socket connect sync ioc=0x563a8a39d400 addr=0x563a891d9d90
       23273@1547735759.138108:qio_channel_socket_connect_fail Socket connect fail ioc=0x563a8a39d400
      
      This commit introduces a way to do simple printf style logging of probe
      points using systemtap. In particular it creates another set of tapsets,
      one per emulator:
      
        /usr/share/systemtap/tapset/qemu-*-log.stp
      
      These pre-define probe functions which simply call printf() on their
      arguments. The printf() format string is taken from the normal
      trace-events files, with a little munging to the format specifiers
      to cope with systemtap's more restrictive syntax.
      
      With this you can now do
      
       $ stap -e 'probe qemu.system.x86_64.log.qio*{}'
       22806@1547735341399856820 qio_channel_socket_new Socket new ioc=0x56135d1d7c00
       22806@1547735341399862570 qio_task_new Task new task=0x56135cd66eb0 source=0x56135d1d7c00 func=0x56135af746c0 opaque=0x56135bf06400
       22806@1547735341399865943 qio_task_thread_start Task thread start task=0x56135cd66eb0 worker=0x56135af72e50 opaque=0x56135c071d70
       22806@1547735341399976816 qio_task_thread_run Task thread run task=0x56135cd66eb0
      
      We go one step further though and introduce a 'qemu-trace-stap' tool to
      make this even easier
      
       $ qemu-trace-stap run qemu-system-x86_64 'qio*'
       22806@1547735341399856820 qio_channel_socket_new Socket new ioc=0x56135d1d7c00
       22806@1547735341399862570 qio_task_new Task new task=0x56135cd66eb0 source=0x56135d1d7c00 func=0x56135af746c0 opaque=0x56135bf06400
       22806@1547735341399865943 qio_task_thread_start Task thread start task=0x56135cd66eb0 worker=0x56135af72e50 opaque=0x56135c071d70
       22806@1547735341399976816 qio_task_thread_run Task thread run task=0x56135cd66eb0
      
      This tool is clever in that it will automatically change the
      SYSTEMTAP_TAPSET env variable to point to the directory containing the
      right set of probes for the QEMU binary path you give it. This is useful
      if you have QEMU installed in /usr but are trying to test and trace a
      binary in /home/berrange/usr/qemu-git. In that case you'd do
      
       $ qemu-trace-stap run /home/berrange/usr/qemu-git/bin/qemu-system-x86_64 'qio*'
      
      And it'll make sure /home/berrange/usr/qemu-git/share/systemtap/tapset
      is used for the trace session
      
      The 'qemu-trace-stap' script takes a verbose arg so you can understand
      what it is running
      
       $ qemu-trace-stap run /home/berrange/usr/qemu-git/bin/qemu-system-x86_64 'qio*'
       Using tapset dir '/home/berrange/usr/qemu-git/share/systemtap/tapset' for binary '/home/berrange/usr/qemu-git/bin/qemu-system-x86_64'
       Compiling script 'probe qemu.system.x86_64.log.qio* {}'
       Running script, <Ctrl>-c to quit
       ...trace output...
      
      It can enable multiple probes at once
      
       $ qemu-trace-stap run qemu-system-x86_64 'qio*' 'qcrypto*' 'buffer*'
      
      By default it monitors all existing running processes and all future
      launched proceses. This can be restricted to a specific PID using the
      --pid arg
      
       $ qemu-trace-stap run --pid 2532 qemu-system-x86_64 'qio*'
      
      Finally if you can't remember what probes are valid it can tell you
      
       $ qemu-trace-stap list qemu-system-x86_64
       ahci_check_irq
       ahci_cmd_done
       ahci_dma_prepare_buf
       ahci_dma_prepare_buf_fail
       ahci_dma_rw_buf
       ahci_irq_lower
       ...snip...
      
      Or list just those matching a prefix pattern
      
       $ qemu-trace-stap list -v qemu-system-x86_64 'qio*'
       Using tapset dir '/home/berrange/usr/qemu-git/share/systemtap/tapset' for binary '/home/berrange/usr/qemu-git/bin/qemu-system-x86_64'
       Listing probes with name 'qemu.system.x86_64.log.qio*'
       qio_channel_command_abort
       qio_channel_command_new_pid
       qio_channel_command_new_spawn
       qio_channel_command_wait
       qio_channel_file_new_fd
       ...snip...
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-id: 20190123120016.4538-5-berrange@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      62dd1048
    • D
      trace: forbid use of %m in trace event format strings · 772f1b37
      Daniel P. Berrangé 提交于
      The '%m' format instructs glibc's printf()/syslog() implementation to
      insert the contents of strerror(errno). Since this is a glibc extension
      it should generally be avoided in QEMU due to need for portability to a
      variety of platforms.
      
      Even though vfio is Linux-only code that could otherwise use "%m", it
      must still be avoided in trace-events files because several of the
      backends do not use the format string and so this error information is
      invisible to them.
      
      The errno string value should be given as an explicit trace argument
      instead, making it accessible to all backends. This also allows it to
      work correctly with future patches that use the format string with
      systemtap's simple printf code.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-id: 20190123120016.4538-4-berrange@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      772f1b37
    • D
      trace: enforce that every trace-events file has a final newline · 77606363
      Daniel P. Berrangé 提交于
      When generating the trace-events-all file, the build system simply
      concatenates all the individual trace-events files. If any one of those
      files does not have a final newline, the printf format string will have
      the contents of the first line of the next file appended to it, which is
      usually a '#' comment.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-id: 20190123120016.4538-3-berrange@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      77606363
    • 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. 23 1月, 2019 1 次提交
  13. 22 1月, 2019 1 次提交
  14. 18 1月, 2019 4 次提交
  15. 15 1月, 2019 1 次提交
  16. 11 1月, 2019 9 次提交
    • P
      scripts: add script to convert multiline comments into 4-line format · 6afeb397
      Paolo Bonzini 提交于
      Since we're adding checkpatch rules to enforce 4-line multiline comment
      format, i.e. with lone /* and */, this script can be run on existing
      code so that the comment style does not become inconsistent within a
      file.
      
      The alternative to awk-in-a-shell-script could be Perl, which also
      supports -i directly, but a2p seems to have bitrotten and I didn't quite
      feel like writing this twice...
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6afeb397
    • P
      checkpatch: warn about qemu/queue.h head structs that are not typedef-ed · 50db69a1
      Paolo Bonzini 提交于
      These are just like any other struct or union, so they should have
      CamelCase typedefs.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      50db69a1
    • P
      qemu/queue.h: reimplement QTAILQ without pointer-to-pointers · 7274f01b
      Paolo Bonzini 提交于
      QTAILQ is a doubly linked list, with a pointer-to-pointer to the last
      element from the head, and the previous element from each node.
      
      But if you squint enough, QTAILQ becomes a combination of a singly-linked
      forwards list, and another singly-linked list which goes backwards and
      is circular.  This is the idea that lets QTAILQ implement reverse
      iteration: only, because the backwards list points inside the node,
      accessing the previous element needs to go two steps back and one
      forwards.
      
      What this patch does is implement it in these terms, without actually
      changing the in-memory layout at all.  The coexistence of the two lists
      is realized by making QTAILQ_HEAD and QTAILQ_ENTRY unions of the forwards
      pointer and a generic QTailQLink node.  Thq QTailQLink can walk the list in
      both directions; the union is needed so that the forwards pointer can
      have the correct type, as a sort of poor man's template.  While there
      are other ways to get the same layout without a union, this one has
      the advantage of simpler operation in the debugger, because the fields
      tqh_first and tqe_next still exist as before the patch.  Those fields are
      also used by scripts/qemugdb/mtree.py, so it's a good idea to preserve them.
      
      The advantage of the new representation is that the two-back-one-forward
      dance done by backwards accesses can be done all while operating on
      QTailQLinks.  No casting to the head struct is needed anymore because,
      even though the QTailQLink's forward pointer is a void *, we can use
      typeof to recover the correct type.  This patch only changes the
      implementation, not the interface.  The next patch will remove the head
      struct name from the backwards visit macros.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7274f01b
    • P
      qemu/queue.h: remove Q_TAILQ_{HEAD,ENTRY} · f95bb39c
      Paolo Bonzini 提交于
      These are not present for other kinds of queue, and unused.
      Zap them before more changes are made to the QTAILQ
      implementation.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f95bb39c
    • P
      test: replace gtester with a TAP driver · 9df43317
      Paolo Bonzini 提交于
      gtester is deprecated by upstream glib (see for example the announcement
      at https://blog.gtk.org/2018/07/11/news-from-glib-2-58/) and it does
      not support tests that call g_test_skip in some glib stable releases.
      
      glib suggests instead using Automake's TAP support, which gtest itself
      supports since version 2.38 (QEMU's minimum requirement is 2.40).
      We do not support Automake, but we can use Automake's code to beautify
      the TAP output.  I chose to use the Perl copy rather than the shell/awk
      one, with some changes so that it can accept TAP through stdin, in order
      to reuse Perl's TAP parsing package.  This also avoids duplicating the
      parser between tap-driver.pl and tap-merge.pl.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1543513531-1151-3-git-send-email-pbonzini@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9df43317
    • P
      checkpatch: colorize output to terminal · 1db4269f
      Paolo Bonzini 提交于
      Add optional colors to make seeing message types a bit easier.
      The default is to show them on a tty.
      
      Inspired by Linux commits 57230297116fa ("checkpatch: colorize output
      to terminal") and 737c0767758b ("checkpatch: change format of --color
      argument to --color[=WHEN]").
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      1db4269f
    • P
      checkpatch: improve handling of multiple patches or files · c182b619
      Paolo Bonzini 提交于
      Similar to how patchew output looks like for multiple patches,
      say what file or patch is being tested _before_ emitting errors.
      This is clearer to a human that scans the output from top to
      bottom.
      
      In addition, provide a truncated commit hash and subject instead of
      the full hash, and process the commits first-to-last rather than
      last-to-first.
      
      Inspired by Linux commit 0dea9f1eef86bedacad91b6f652ca1ab0d08854c
      ("checkpatch: reduce number of `git log` calls with --git", 2016-03-20).
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c182b619
    • P
      checkpatch: check Signed-off-by in --mailback mode · fd9c0cfe
      Paolo Bonzini 提交于
      Pull the test before the anticipated exits from the process sub.
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fd9c0cfe
    • P
      checkpatch: fix premature exit when no input or --mailback · 1ff7ebf3
      Paolo Bonzini 提交于
      In some cases, checkpatch's process subroutine is exiting the
      whole process.  This is wrong, just return from the subroutine
      instead.
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1ff7ebf3
  17. 18 12月, 2018 1 次提交
  18. 14 12月, 2018 5 次提交