1. 24 10月, 2016 5 次提交
  2. 13 10月, 2016 1 次提交
  3. 10 10月, 2016 2 次提交
    • D
      net: don't poke at chardev internal QemuOpts · 0a73336d
      Daniel P. Berrange 提交于
      The vhost-user & colo code is poking at the QemuOpts instance
      in the CharDriverState struct, not realizing that it is valid
      for this to be NULL. e.g. the following crash shows a codepath
      where it will be NULL:
      
       Program terminated with signal SIGSEGV, Segmentation fault.
       #0  0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
       617         QTAILQ_FOREACH(opt, &opts->head, next) {
       [Current thread is 1 (Thread 0x7f1d4970bb40 (LWP 6603))]
       (gdb) bt
       #0  0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
       #1  0x000055baf696b7da in net_vhost_parse_chardev (opts=0x55baf8ff9260, errp=0x7ffc51368e48) at net/vhost-user.c:314
       #2  0x000055baf696b985 in net_init_vhost_user (netdev=0x55baf8ff9250, name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) at net/vhost-user.c:360
       #3  0x000055baf6960216 in net_client_init1 (object=0x55baf8ff9250, is_netdev=true, errp=0x7ffc51368e48) at net/net.c:1051
       #4  0x000055baf6960518 in net_client_init (opts=0x55baf776e7e0, is_netdev=true, errp=0x7ffc51368f00) at net/net.c:1108
       #5  0x000055baf696083f in netdev_add (opts=0x55baf776e7e0, errp=0x7ffc51368f00) at net/net.c:1186
       #6  0x000055baf69608c7 in qmp_netdev_add (qdict=0x55baf7afaf60, ret=0x7ffc51368f50, errp=0x7ffc51368f48) at net/net.c:1205
       #7  0x000055baf6622135 in handle_qmp_command (parser=0x55baf77fb590, tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978
       #8  0x000055baf6a9d099 in json_message_process_token (lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19) at qobject/json-streamer.c:105
       #9  0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598, ch=125 '}', flush=false) at qobject/json-lexer.c:319
       #10 0x000055baf6abf8f2 in json_lexer_feed (lexer=0x55baf77fb598, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-lexer.c:369
       #11 0x000055baf6a9d13c in json_message_parser_feed (parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-streamer.c:124
       #12 0x000055baf66221f7 in monitor_qmp_read (opaque=0x55baf77fb530, buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994
       #13 0x000055baf6757014 in qemu_chr_be_write_impl (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
       #14 0x000055baf6757076 in qemu_chr_be_write (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
       #15 0x000055baf675b3b0 in tcp_chr_read (chan=0x55baf90244b0, cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
       #16 0x000055baf6a5d655 in qio_channel_fd_source_dispatch (source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) at io/channel-watch.c:84
       #17 0x00007f1d3e80cbbd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
       #18 0x000055baf69d3720 in glib_pollfds_poll () at main-loop.c:213
       #19 0x000055baf69d37fd in os_host_main_loop_wait (timeout=126000000) at main-loop.c:258
       #20 0x000055baf69d38ad in main_loop_wait (nonblocking=0) at main-loop.c:506
       #21 0x000055baf676587b in main_loop () at vl.c:1908
       #22 0x000055baf676d3bf in main (argc=101, argv=0x7ffc5136a6c8, envp=0x7ffc5136a9f8) at vl.c:4604
       (gdb) p opts
       $1 = (QemuOpts *) 0x0
      
      The crash occurred when attaching vhost-user net via QMP:
      
      {
          "execute": "chardev-add",
          "arguments": {
              "id": "charnet2",
              "backend": {
                  "type": "socket",
                  "data": {
                      "addr": {
                          "type": "unix",
                          "data": {
                              "path": "/var/run/openvswitch/vhost-user1"
                          }
                      },
                      "wait": false,
                      "server": false
                  }
              }
          },
          "id": "libvirt-19"
      }
      {
          "return": {
      
          },
          "id": "libvirt-19"
      }
      {
          "execute": "netdev_add",
          "arguments": {
              "type": "vhost-user",
              "chardev": "charnet2",
              "id": "hostnet2"
          },
          "id": "libvirt-20"
      }
      
      Code using chardevs should not be poking at the internals of the
      CharDriverState struct. What vhost-user wants is a chardev that is
      operating as reconnectable network service, along with the ability
      to do FD passing over the connection. The colo code simply wants
      a network service. Add a feature concept to the char drivers so
      that chardev users can query the actual features they wish to have
      supported. The QemuOpts member is removed to prevent future mistakes
      in this area.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0a73336d
    • I
      numa: reduce code duplication by adding helper numa_get_node_for_cpu() · 6bea1ddf
      Igor Mammedov 提交于
      Replace repeated pattern
      
          for (i = 0; i < nb_numa_nodes; i++) {
              if (test_bit(idx, numa_info[i].node_cpu)) {
                 ...
                 break;
      
      with a helper function to lookup numa node index for cpu.
      Suggested-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NShannon Zhao <shannon.zhao@linaro.org>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      6bea1ddf
  4. 07 10月, 2016 2 次提交
  5. 04 10月, 2016 2 次提交
    • P
      kvm-all: Pass requester ID to MSI routing functions · 767a554a
      Pavel Fedin 提交于
      Introduce global kvm_msi_use_devid flag plus associated
      kvm_msi_devid_required() macro. Passes the device ID,
      if needed, while building the MSI route entry. Device IDs are
      required by the ARM GICv3 ITS (IRQ remapping function is based on
      this information).
      Signed-off-by: NPavel Fedin <p.fedin@samsung.com>
      Signed-off-by: NEric Auger <eric.auger@redhat.com>
      Message-id: 1474616617-366-5-git-send-email-eric.auger@redhat.com
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      767a554a
    • M
      char: use a fixed idx for child muxed chr · 949055a2
      Marc-André Lureau 提交于
      mux_chr_update_read_handler() is adding a new mux_cnt each time
      mux_chr_update_read_handler() is called, it's not possible to actually
      update the "child" chr callbacks that were set previously. This may lead
      to crashes if the "child" chr is destroyed:
      
      valgrind x86_64-softmmu/qemu-system-x86_64 -chardev
      stdio,mux=on,id=char0 -mon chardev=char0,mode=control,default
      
      when quitting:
      
      ==4306== Invalid read of size 8
      ==4306==    at 0x8061D3: json_lexer_destroy (json-lexer.c:385)
      ==4306==    by 0x7E39F8: json_message_parser_destroy (json-streamer.c:134)
      ==4306==    by 0x3447F6: monitor_qmp_event (monitor.c:3908)
      ==4306==    by 0x480153: mux_chr_send_event (qemu-char.c:630)
      ==4306==    by 0x480694: mux_chr_event (qemu-char.c:734)
      ==4306==    by 0x47F1E9: qemu_chr_be_event (qemu-char.c:205)
      ==4306==    by 0x481207: fd_chr_close (qemu-char.c:1114)
      ==4306==    by 0x481659: qemu_chr_close_stdio (qemu-char.c:1221)
      ==4306==    by 0x486F07: qemu_chr_free (qemu-char.c:4146)
      ==4306==    by 0x486F97: qemu_chr_delete (qemu-char.c:4154)
      ==4306==    by 0x487E66: qemu_chr_cleanup (qemu-char.c:4678)
      ==4306==    by 0x495A98: main (vl.c:4675)
      ==4306==  Address 0x28439e90 is 112 bytes inside a block of size 240 free'd
      ==4306==    at 0x4C2CD5A: free (vg_replace_malloc.c:530)
      ==4306==    by 0x1E4CBF2D: g_free (in /usr/lib64/libglib-2.0.so.0.4800.2)
      ==4306==    by 0x344DE9: monitor_cleanup (monitor.c:4058)
      ==4306==    by 0x495A93: main (vl.c:4674)
      ==4306==  Block was alloc'd at
      ==4306==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
      ==4306==    by 0x1E4CBE18: g_malloc (in /usr/lib64/libglib-2.0.so.0.4800.2)
      ==4306==    by 0x344BF8: monitor_init (monitor.c:4021)
      ==4306==    by 0x49063C: mon_init_func (vl.c:2417)
      ==4306==    by 0x7FC6DE: qemu_opts_foreach (qemu-option.c:1116)
      ==4306==    by 0x4954E0: main (vl.c:4473)
      
      Instead, keep the "child" chr associated with a particular idx so its
      handlers can be updated and removed to avoid the crash.
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20161003094704.18087-3-marcandre.lureau@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      949055a2
  6. 29 9月, 2016 3 次提交
  7. 28 9月, 2016 1 次提交
  8. 27 9月, 2016 2 次提交
  9. 23 9月, 2016 4 次提交
    • K
      qdev-monitor: Add blk_by_qdev_id() · 9680caee
      Kevin Wolf 提交于
      This finds the BlockBackend attached to the device model identified by
      its qdev ID.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      9680caee
    • K
      block: Add blk_by_dev() · 1c89e1fa
      Kevin Wolf 提交于
      This finds a BlockBackend given the device model that is attached to it.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      1c89e1fa
    • F
      vl: Switch qemu_uuid to QemuUUID · 9c5ce8db
      Fam Zheng 提交于
      Update all qemu_uuid users as well, especially get rid of the duplicated
      low level g_strdup_printf, sscanf and snprintf calls with QEMU UUID API.
      
      Since qemu_uuid_parse is quite tangled with qemu_uuid, its switching to
      QemuUUID is done here too to keep everything in sync and avoid code
      churn.
      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-10-git-send-email-famz@redhat.com>
      9c5ce8db
    • 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
  10. 15 9月, 2016 1 次提交
  11. 14 9月, 2016 2 次提交
  12. 13 9月, 2016 1 次提交
    • 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
  13. 06 9月, 2016 5 次提交
  14. 29 7月, 2016 1 次提交
  15. 22 7月, 2016 3 次提交
  16. 20 7月, 2016 1 次提交
  17. 13 7月, 2016 2 次提交
    • X
      hostmem: detect host backend memory is being used properly · 2aece63c
      Xiao Guangrong 提交于
      Currently, we use memory_region_is_mapped() to detect if the host
      backend memory is being used. This works if the memory is directly
      mapped into guest's address space, however, it is not true for
      nvdimm as it uses aliased memory region to map the memory. This is
      why this bug can happen:
         https://bugzilla.redhat.com/show_bug.cgi?id=1352769
      
      Fix it by introduce a new filed, is_mapped, to HostMemoryBackend,
      we set/clear this filed accordingly when the device link/unlink to
      host backend memory
      Signed-off-by: NXiao Guangrong <guangrong.xiao@linux.intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2aece63c
    • 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
  18. 12 7月, 2016 2 次提交