1. 23 9月, 2016 1 次提交
    • F
      util: Add UUID API · cea25275
      Fam Zheng 提交于
      A number of different places across the code base use CONFIG_UUID. Some
      of them are soft dependency, some are not built if libuuid is not
      available, some come with dummy fallback, some throws runtime error.
      
      It is hard to maintain, and hard to reason for users.
      
      Since UUID is a simple standard with only a small number of operations,
      it is cleaner to have a central support in libqemuutil. This patch adds
      qemu_uuid_* functions that all uuid users in the code base can
      rely on. Except for qemu_uuid_generate which is new code, all other
      functions are just copy from existing fallbacks from other files.
      
      Note that qemu_uuid_parse is moved without updating the function
      signature to use QemuUUID, to keep this patch simple.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Message-Id: <1474432046-325-2-git-send-email-famz@redhat.com>
      cea25275
  2. 21 9月, 2016 1 次提交
  3. 19 9月, 2016 1 次提交
  4. 13 9月, 2016 2 次提交
    • P
      vl: remove unnecessary duplicate call to tpm_cleanup · bc82585a
      Paolo Bonzini 提交于
      tpm_cleanup is called from main() and also registered with atexit from
      tpm_init.  The function only visits the tpm_backends linked list, and the
      atexit registration happens right after tpm_init fills in the list from
      -tpmdev options.  Therefore, the direct call is unnecessary.  Remove it.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      bc82585a
    • F
      iothread: Stop threads before main() quits · dce8921b
      Fam Zheng 提交于
      Right after main_loop ends, we release various things but keep iothread
      alive. The latter is not prepared to the sudden change of resources.
      
      Specifically, after bdrv_close_all(), virtio-scsi dataplane get a
      surprise at the empty BlockBackend:
      
      (gdb) bt
          at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:543
          at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:577
      
      It is because the d->conf.blk->root is set to NULL, then
      blk_get_aio_context() returns qemu_aio_context, whereas s->ctx is still
      pointing to the iothread:
      
          hw/scsi/virtio-scsi.c:543:
      
          if (s->dataplane_started) {
              assert(blk_get_aio_context(d->conf.blk) == s->ctx);
          }
      
      To fix this, let's stop iothreads before doing bdrv_close_all().
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1473326931-9699-1-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      dce8921b
  5. 06 9月, 2016 1 次提交
    • E
      vl: Delay initialization of memory backends · 6546d0db
      Eduardo Habkost 提交于
      Initialization of memory backends may take a while when
      prealloc=yes is used, depending on their size. Initializing
      memory backends before chardevs may delay the creation of monitor
      sockets, and trigger timeouts on management software that waits
      until the monitor socket is created by QEMU. See, for example,
      the bug report at:
      https://bugzilla.redhat.com/show_bug.cgi?id=1371211
      
      In addition to that, allocating memory before calling
      configure_accelerator() breaks the tcg_enabled() checks at
      memory_region_init_*().
      
      This patch fixes those problems by adding "memory-backend-*"
      classes to the delayed-initialization list.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      6546d0db
  6. 11 8月, 2016 1 次提交
  7. 08 8月, 2016 2 次提交
    • M
      audio: clean up before monitor clean up · a384c205
      Marc-André Lureau 提交于
      Since aa5cb7f5, the chardevs are being cleaned up when leaving qemu,
      before the atexit() handlers. audio_cleanup() may use the monitor to
      notify of changes. For compatibility reasons, let's clean up audio
      before the monitor so it keeps emitting monitor events.
      
      The audio_atexit() function is made idempotent (so it can be called
      multiple times), and renamed to audio_cleanup(). Since coreaudio
      backend is using a 'isAtexit' code path, change it to check
      audio_is_cleaning_up() instead, so the path is taken during normal
      exit.
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20160801112343.29082-3-marcandre.lureau@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      a384c205
    • M
      monitor: fix crash when leaving qemu with spice audio · 2ef45716
      Marc-André Lureau 提交于
      Since aa5cb7f5, the chardevs are being cleaned up when leaving
      qemu. However, the monitor has still references to them, which may
      lead to crashes when running atexit() and trying to send monitor
      events:
      
       #0  0x00007fffdb18f6f5 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
       #1  0x00007fffdb1912fa in __GI_abort () at abort.c:89
       #2  0x0000555555c263e7 in error_exit (err=22, msg=0x555555d47980 <__func__.13537> "qemu_mutex_lock") at util/qemu-thread-posix.c:39
       #3  0x0000555555c26488 in qemu_mutex_lock (mutex=0x5555567a2420) at util/qemu-thread-posix.c:66
       #4  0x00005555558c52db in qemu_chr_fe_write (s=0x5555567a2420, buf=0x55555740dc40 "{\"timestamp\": {\"seconds\": 1470041716, \"microseconds\": 989699}, \"event\": \"SPICE_DISCONNECTED\", \"data\": {\"server\": {\"port\": \"5900\", \"family\": \"ipv4\", \"host\": \"127.0.0.1\"}, \"client\": {\"port\": \"40272\", \"f"..., len=240) at qemu-char.c:280
       #5  0x0000555555787cad in monitor_flush_locked (mon=0x5555567bd9e0) at /home/elmarco/src/qemu/monitor.c:311
       #6  0x0000555555787e46 in monitor_puts (mon=0x5555567bd9e0, str=0x5555567a44ef "") at /home/elmarco/src/qemu/monitor.c:353
       #7  0x00005555557880fe in monitor_json_emitter (mon=0x5555567bd9e0, data=0x5555567c73a0) at /home/elmarco/src/qemu/monitor.c:401
       #8  0x00005555557882d2 in monitor_qapi_event_emit (event=QAPI_EVENT_SPICE_DISCONNECTED, qdict=0x5555567c73a0) at /home/elmarco/src/qemu/monitor.c:472
       #9  0x000055555578838f in monitor_qapi_event_queue (event=QAPI_EVENT_SPICE_DISCONNECTED, qdict=0x5555567c73a0, errp=0x7fffffffca88) at /home/elmarco/src/qemu/monitor.c:497
       #10 0x0000555555c15541 in qapi_event_send_spice_disconnected (server=0x5555571139d0, client=0x5555570d0db0, errp=0x5555566c0428 <error_abort>) at qapi-event.c:1038
       #11 0x0000555555b11bc6 in channel_event (event=3, info=0x5555570d6c00) at ui/spice-core.c:248
       #12 0x00007fffdcc9983a in adapter_channel_event (event=3, info=0x5555570d6c00) at reds.c:120
       #13 0x00007fffdcc99a25 in reds_handle_channel_event (reds=0x5555567a9d60, event=3, info=0x5555570d6c00) at reds.c:324
       #14 0x00007fffdcc7d4c4 in main_dispatcher_self_handle_channel_event (self=0x5555567b28b0, event=3, info=0x5555570d6c00) at main-dispatcher.c:175
       #15 0x00007fffdcc7d5b1 in main_dispatcher_channel_event (self=0x5555567b28b0, event=3, info=0x5555570d6c00) at main-dispatcher.c:194
       #16 0x00007fffdcca7674 in reds_stream_push_channel_event (s=0x5555570d9910, event=3) at reds-stream.c:354
       #17 0x00007fffdcca749b in reds_stream_free (s=0x5555570d9910) at reds-stream.c:323
       #18 0x00007fffdccb5dad in snd_disconnect_channel (channel=0x5555576a89a0) at sound.c:229
       #19 0x00007fffdccb9e57 in snd_detach_common (worker=0x555557739720) at sound.c:1589
       #20 0x00007fffdccb9f0e in snd_detach_playback (sin=0x5555569fe3f8) at sound.c:1602
       #21 0x00007fffdcca3373 in spice_server_remove_interface (sin=0x5555569fe3f8) at reds.c:3387
       #22 0x00005555558ff6e2 in line_out_fini (hw=0x5555569fe370) at audio/spiceaudio.c:152
       #23 0x00005555558f909e in audio_atexit () at audio/audio.c:1754
       #24 0x00007fffdb1941e8 in __run_exit_handlers (status=0, listp=0x7fffdb5175d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
       #25 0x00007fffdb194235 in __GI_exit (status=<optimized out>) at exit.c:104
       #26 0x00007fffdb17b738 in __libc_start_main (main=0x5555558d7874 <main>, argc=67, argv=0x7fffffffcf48, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffcf38) at ../csu/libc-start.c:323
      
      Add a monitor_cleanup() functions to remove all the monitors before
      cleaning up the chardev. Note that we are "losing" some events that
      used to be sent during atexit().
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20160801112343.29082-2-marcandre.lureau@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      2ef45716
  8. 27 7月, 2016 1 次提交
  9. 19 7月, 2016 1 次提交
  10. 13 7月, 2016 2 次提交
    • M
      char: do not use atexit cleanup handler · aa5cb7f5
      Marc-André Lureau 提交于
      It turns out qemu is calling exit() in various places from various
      threads without taking much care of resources state. The atexit()
      cleanup handlers cannot easily destroy resources that are in use (by
      the same thread or other).
      
      Since c1111a24, TCG arm guests run into the following abort() when
      running tests, the chardev mutex is locked during the write, so
      qemu_mutex_destroy() returns an error:
      
       #0  0x00007fffdbb806f5 in raise () at /lib64/libc.so.6
       #1  0x00007fffdbb822fa in abort () at /lib64/libc.so.6
       #2  0x00005555557616fe in error_exit (err=<optimized out>, msg=msg@entry=0x555555c38c30 <__func__.14622> "qemu_mutex_destroy")
           at /home/drjones/code/qemu/util/qemu-thread-posix.c:39
       #3  0x0000555555b0be20 in qemu_mutex_destroy (mutex=mutex@entry=0x5555566aa0e0) at /home/drjones/code/qemu/util/qemu-thread-posix.c:57
       #4  0x00005555558aab00 in qemu_chr_free_common (chr=0x5555566aa0e0) at /home/drjones/code/qemu/qemu-char.c:4029
       #5  0x00005555558b05f9 in qemu_chr_delete (chr=<optimized out>) at /home/drjones/code/qemu/qemu-char.c:4038
       #6  0x00005555558b05f9 in qemu_chr_delete (chr=<optimized out>) at /home/drjones/code/qemu/qemu-char.c:4044
       #7  0x00005555558b062c in qemu_chr_cleanup () at /home/drjones/code/qemu/qemu-char.c:4557
       #8  0x00007fffdbb851e8 in __run_exit_handlers () at /lib64/libc.so.6
       #9  0x00007fffdbb85235 in  () at /lib64/libc.so.6
       #10 0x00005555558d1b39 in testdev_write (testdev=0x5555566aa0a0) at /home/drjones/code/qemu/backends/testdev.c:71
       #11 0x00005555558d1b39 in testdev_write (chr=<optimized out>, buf=0x7fffc343fd9a "", len=0) at /home/drjones/code/qemu/backends/testdev.c:95
       #12 0x00005555558adced in qemu_chr_fe_write (s=0x5555566aa0e0, buf=buf@entry=0x7fffc343fd98 "0q", len=len@entry=2) at /home/drjones/code/qemu/qemu-char.c:282
      
      Instead of using a atexit() handler, only run the chardev cleanup as
      initially proposed at the end of main(), where there are less chances
      (hic) of conflicts or other races.
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reported-by: NAndrew Jones <drjones@redhat.com>
      Message-Id: <20160704153823.16879-1-marcandre.lureau@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      aa5cb7f5
    • P
      net: do not use atexit for cleanup · 8caf911d
      Paolo Bonzini 提交于
      This will be necessary in the next patch, which stops using atexit for
      character devices; without it, vhost-user and the redirector filter
      will cause a use-after-free.  Relying on the ordering of atexit calls
      is also brittle, even now that both the network and chardev
      subsystems are using atexit.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8caf911d
  11. 08 7月, 2016 2 次提交
  12. 04 7月, 2016 1 次提交
  13. 29 6月, 2016 3 次提交
  14. 27 6月, 2016 1 次提交
  15. 20 6月, 2016 4 次提交
    • M
      log: Fix qemu_set_log_filename() error handling · daa76aa4
      Markus Armbruster 提交于
      When qemu_set_log_filename() detects an invalid file name, it reports
      an error, closes the log file (if any), and starts logging to stderr
      (unless daemonized or nothing is being logged).
      
      This is wrong.  Asking for an invalid log file on the command line
      should be fatal.  Asking for one in the monitor should fail without
      messing up an existing logfile.
      
      Fix by converting qemu_set_log_filename() to Error.  Pass it
      &error_fatal, except for hmp_logfile report errors.
      
      This also permits testing without a subprocess, so do that.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1466011636-6112-4-git-send-email-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      daa76aa4
    • M
      log: Fix qemu_set_dfilter_ranges() error reporting · bd6fee9f
      Markus Armbruster 提交于
      g_error() is not an acceptable way to report errors to the user:
      
          $ qemu-system-x86_64 -dfilter 1000+0
      
          ** (process:17187): ERROR **: Failed to parse range in: 1000+0
          Trace/breakpoint trap (core dumped)
      
      g_assert() isn't, either:
      
          $ qemu-system-x86_64 -dfilter 1000x+64
          **
          ERROR:/work/armbru/qemu/util/log.c:180:qemu_set_dfilter_ranges: assertion failed: (e == range_op)
          Aborted (core dumped)
      
      Convert qemu_set_dfilter_ranges() to Error.  Rework its deeply nested
      control flow.  Touch up the error messages.  Call it with
      &error_fatal.
      
      This also permits testing without a subprocess, so do that.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1466011636-6112-3-git-send-email-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      bd6fee9f
    • E
      coccinelle: Remove unnecessary variables for function return value · 9be38598
      Eduardo Habkost 提交于
      Use Coccinelle script to replace 'ret = E; return ret' with
      'return E'. The script will do the substitution only when the
      function return type and variable type are the same.
      
      Manual fixups:
      
      * audio/audio.c: coding style of "read (...)" and "write (...)"
      * block/qcow2-cluster.c: wrap line to make it shorter
      * block/qcow2-refcount.c: change indentation of wrapped line
      * target-tricore/op_helper.c: fix coding style of
        "remainder|quotient"
      * target-mips/dsp_helper.c: reverted changes because I don't
        want to argue about checkpatch.pl
      * ui/qemu-pixman.c: fix line indentation
      * block/rbd.c: restore blank line between declarations and
        statements
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [Unused Coccinelle rule name dropped along with a redundant comment;
      whitespace touched up in block/qcow2-cluster.c; stale commit message
      paragraph deleted]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9be38598
    • M
      vl: Error messages need to go to stderr, fix some · da002526
      Markus Armbruster 提交于
      We print a few fatal error messages to stdout instead of stderr.
      Reproducer:
      
          $ qemu-system-x86_64 -g 1024x768
          Option g not supported for this target
          $ qemu-system-x86_64 -g 1024x768 >/dev/null
      
      Fix by printing them with error_report().  This also improves the messages.
      The above one becomes
      
          qemu-system-x86_64: -g 1024x768: Option not supported for this target
      
      Reported-by: Tobi {github.com/tobimensch}
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1464683498-28779-1-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      da002526
  16. 17 6月, 2016 3 次提交
  17. 13 6月, 2016 1 次提交
  18. 07 6月, 2016 2 次提交
  19. 01 6月, 2016 1 次提交
  20. 24 5月, 2016 1 次提交
  21. 23 5月, 2016 1 次提交
  22. 21 5月, 2016 7 次提交