1. 16 7月, 2014 1 次提交
  2. 15 7月, 2014 18 次提交
  3. 14 7月, 2014 21 次提交
    • P
      serial-pci: remove memory regions from BAR before destroying them · 7497bce6
      Paolo Bonzini 提交于
      Otherwise, hot-unplug of pci-serial-2x trips the assertion
      in memory_region_destroy:
      
          (qemu) device_del gg
          (qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021: memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
          Aborted (core dumped)
      Reported-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7497bce6
    • P
      virtio-scsi: fix with -M pc-i440fx-2.0 · 1f4e6a06
      Paolo Bonzini 提交于
      Right now starting a machine with virtio-scsi and a <= 2.0 machine type
      fails with:
      
          qemu-system-x86_64: -device virtio-scsi-pci: Property .any_layout not found
      
      This is because the any_layout bit was actually never set after
      virtio-scsi was changed to support arbitrary layout for virtio buffers.
      
      (This was just a cleanup and a preparation for virtio 1.0; no guest
      actually checks the bit, but the new request parsing algorithms are
      tested even with old guest).
      Reported-by: NDavid Gilbert <dgilbert@redhat.com>
      Reviewed-by: NDavid Gilbert <dgilbert@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1f4e6a06
    • K
      serial: change retry logic to avoid concurrency · f702e62a
      Kirill Batuzov 提交于
      Whenever serial_xmit fails to transmit a byte it adds a watch that would
      call it again when the "line" becomes ready. This results in a retry
      chain:
        serial_xmit -> add_watch -> serial_xmit
      Each chain is able to transmit one character, and for every character
      passed to serial by the guest driver a new chain is spawned.
      
      The problem lays with the fact that a new chain is spawned even when
      there is one already waiting on the watch. So there can be several retry
      chains waiting concurrently on one "line". Every chain tries to transmit
      current character, so character order is not messed up. But also every
      chain increases retry counter (tsr_retry). If there are enough
      concurrent chains this counter will hit MAX_XMIT_RETRY value and
      the character will be dropped.
      
      To reproduce this bug you need to feed serial output to some program
      consuming it slowly enough. A python script from bug #1335444
      description is an example of such program.
      
      This commit changes retry logic in the following way to avoid
      concurrency: instead of spawning a new chain for each character being
      transmitted spawn only one and make it transmit characters until FIFO is
      empty.
      
      The change consists of two parts:
       - add a do {} while () loop in serial_xmit (diff is a bit erratic
         for this part, diff -w will show actual change),
       - do not call serial_xmit from serial_ioport_write if there is one
         waiting on the watch already.
      
      This should fix another issue causing bug #1335444.
      Signed-off-by: NKirill Batuzov <batuzovk@ispras.ru>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f702e62a
    • P
      qemu-char: fix deadlock with "-monitor pty" · 7b3621f4
      Paolo Bonzini 提交于
      qemu_chr_be_generic_open cannot be called with the write lock taken,
      because it calls client code that may call qemu_chr_fe_write.  This
      actually happens for the monitor:
      
          0x00007ffff27dbf79 in __GI_raise (sig=sig@entry=6)
          0x00007ffff27df388 in __GI_abort ()
          0x00005555555ef489 in error_exit (err=<optimized out>, msg=msg@entry=0x5555559796d0 <__func__.5959> "qemu_mutex_lock")
          0x00005555558f9080 in qemu_mutex_lock (mutex=mutex@entry=0x555556248a30)
          0x0000555555713936 in qemu_chr_fe_write (s=0x555556248a30, buf=buf@entry=0x5555563d8870 "QEMU 2.0.90 monitor - type 'help' for more information\r\n", len=56)
          0x00005555556217fd in monitor_flush_locked (mon=mon@entry=0x555556251fd0)
          0x0000555555621a12 in monitor_flush_locked (mon=0x555556251fd0)
          monitor_puts (mon=mon@entry=0x555556251fd0, str=0x55555634bfa7 "", str@entry=0x55555634bf70 "QEMU 2.0.90 monitor - type 'help' for more information\n")
          0x0000555555624359 in monitor_vprintf (mon=0x555556251fd0, fmt=<optimized out>, ap=<optimized out>)
          0x0000555555624414 in monitor_printf (mon=<optimized out>, fmt=fmt@entry=0x5555559105a0 "QEMU %s monitor - type 'help' for more information\n")
          0x0000555555629806 in monitor_event (opaque=0x555556251fd0, event=<optimized out>)
          0x000055555571343c in qemu_chr_be_generic_open (s=0x555556248a30)
      
      To avoid this, defer the call to an idle callback, which will be
      called as soon as the main loop is re-entered.  In order to simplify
      the cleanup and do it in one place only, change pty_chr_close to
      call pty_chr_state.
      
      To reproduce, run with "-monitor pty", then try to read from the
      slave /dev/pts/FOO that it creates.
      
      Fixes: 9005b2a7Reported-by: NLi Liang <liangx.z.li@intel.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7b3621f4
    • P
      Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging · 7a6d04e7
      Peter Maydell 提交于
      Block patches for 2.1.0-rc2 (v2)
      
      # gpg: Signature made Mon 14 Jul 2014 11:04:12 BST using RSA key ID C88F2FD6
      # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
      
      * remotes/kevin/tags/for-upstream: (22 commits)
        ide: Treat read/write beyond end as invalid
        virtio-blk: Treat read/write beyond end as invalid
        virtio-blk: Bypass error action and I/O accounting on invalid r/w
        virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
        dma-helpers: Fix too long qiov
        qtest: fix vhost-user-test compilation with old GLib
        tests: Fix unterminated string output visitor enum human string
        AioContext: do not rely on aio_poll(ctx, true) result to end a loop
        virtio-blk: embed VirtQueueElement in VirtIOBlockReq
        virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement
        dataplane: do not free VirtQueueElement in vring_push()
        virtio-blk: avoid dataplane VirtIOBlockReq early free
        block: Assert qiov length matches request length
        qed: Make qiov match request size until backing file EOF
        qcow2: Make qiov match request size until backing file EOF
        block: Make qiov match the request size until EOF
        AioContext: speed up aio_notify
        test-aio: fix GSource-based timer test
        block: drop aio functions that operate on the main AioContext
        block: prefer aio_poll to qemu_aio_wait
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      7a6d04e7
    • P
      Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20140714' into staging · c15a34ed
      Peter Maydell 提交于
      A s390x/kvm bugfix for missing floating point register synchronization.
      
      # gpg: Signature made Mon 14 Jul 2014 08:21:54 BST using RSA key ID C6F02FAF
      # gpg: Can't check signature: public key not found
      
      * remotes/cohuck/tags/s390x-20140714:
        s390x/kvm: synchronize guest floating point registers
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      c15a34ed
    • M
      ide: Treat read/write beyond end as invalid · 58ac3211
      Markus Armbruster 提交于
      The block layer fails such reads and writes just fine.  However, they
      then get treated like valid operations that fail: the error action
      gets executed.  Unwanted; reporting the error to the guest is the only
      sensible action.
      
      Reject them before passing them to the block layer.  This bypasses the
      error action and I/O accounting.  Not quite correct for DMA, because
      DMA can fail after some success, and when that happens, the part that
      succeeded isn't counted.  Tolerable, because I/O accounting is an
      inconsistent mess anyway.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      58ac3211
    • M
      virtio-blk: Treat read/write beyond end as invalid · 3c2daac0
      Markus Armbruster 提交于
      The block layer fails such reads and writes just fine.  However, they
      then get treated like valid operations that fail: the error action
      gets executed.  Unwanted; reporting the error to the guest is the only
      sensible action.
      
      Reject them before passing them to the block layer.  This bypasses the
      error action and I/O accounting.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      3c2daac0
    • M
      virtio-blk: Bypass error action and I/O accounting on invalid r/w · 42e38c1f
      Markus Armbruster 提交于
      When a device model's I/O operation fails, we execute the error
      action.  This lets layers above QEMU implement thin provisioning, or
      attempt to correct errors before they reach the guest.  But when the
      I/O operation fails because it's invalid, reporting the error to the
      guest is the only sensible action.
      
      If the guest's read or write asks for an invalid sector range, fail
      the request right away, without considering the error action.  No
      change with error action BDRV_ACTION_REPORT.
      
      Furthermore, bypass I/O accounting, because we want to track only I/O
      that actually reaches the block layer.
      
      The next commit will extend "invalid sector range" to cover attempts
      to read/write beyond the end of the medium.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      42e38c1f
    • M
    • K
      dma-helpers: Fix too long qiov · 58f423fb
      Kevin Wolf 提交于
      If the size of the scatter/gather list isn't a multiple of 512, the
      number of sectors for the block layer request is rounded down, resulting
      in a qiov that doesn't match the request length. Truncate the qiov to the
      new length of the request.
      
      This fixes the IDE qtest case /x86_64/ide/bmdma/short_prdt.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      58f423fb
    • N
      qtest: fix vhost-user-test compilation with old GLib · 80504dca
      Nikolay Nikolaev 提交于
      Mising G_TIME_SPAN_SECOND definition breaks the RHEL6 compilation as GLib
      version before 2.26 does not have it. In such case just define it.
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NNikolay Nikolaev <n.nikolaev@virtualopensystems.com>
      Tested-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      80504dca
    • A
      tests: Fix unterminated string output visitor enum human string · b8864245
      Andreas Färber 提交于
      The buffer was being allocated of size string length plus two.
      Around the string two quotes were being added, but no terminating NUL.
      It was then compared using g_assert_cmpstr(), resulting in fairly random
      assertion failures:
      
       ERROR:tests/test-string-output-visitor.c:213:test_visitor_out_enum: assertion failed (str == str_human): ("\"value1\"" == "\"value1\"\001EEEEEEEEEEEEEE\0171")
      
      There is no g_assert_cmpnstr() counterpart, so use g_strdup_printf()
      for safely assembling the string in the first place.
      
      Cc: Hu Tao <hutao@cn.fujitsu.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Suggested-by: NEric Blake <eblake@redhat.com>
      Fixes: b4900c0e tests: add human format test for string output visitor
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b8864245
    • P
      AioContext: do not rely on aio_poll(ctx, true) result to end a loop · acfb23ad
      Paolo Bonzini 提交于
      Currently, whenever aio_poll(ctx, true) has completed all pending
      work it returns true *and* the next call to aio_poll(ctx, true)
      will not block.
      
      This invariant has its roots in qemu_aio_flush()'s implementation
      as "while (qemu_aio_wait()) {}".  However, qemu_aio_flush() does
      not exist anymore and bdrv_drain_all() is implemented differently;
      and this invariant is complicated to maintain and subtly different
      from the return value of GMainLoop's g_main_context_iteration.
      
      All calls to aio_poll(ctx, true) except one are guarded by a
      while() loop checking for a request to be incomplete, or a
      BlockDriverState to be idle.  The one remaining call (in
      iothread.c) uses this to delay the aio_context_release/acquire
      pair until the AioContext is quiescent, however:
      
      - we can do the same just by using non-blocking aio_poll,
        similar to how vl.c invokes main_loop_wait
      
      - it is buggy, because it does not ensure that the AioContext
        is released between an aio_notify and the next time the
        iothread goes to sleep.  This leads to hangs when stopping
        the dataplane thread.
      
      In the end, these semantics are a bad match for the current
      users of AioContext.  So modify that one exception in iothread.c,
      which also fixes the hangs, as well as the testcase so that
      it use the same idiom as the actual QEMU code.
      Reported-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Tested-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      acfb23ad
    • S
      virtio-blk: embed VirtQueueElement in VirtIOBlockReq · f897bf75
      Stefan Hajnoczi 提交于
      The memory allocation between hw/block/virtio-blk.c,
      hw/block/dataplane/virtio-blk.c, and hw/virtio/dataplane/vring.c is
      messy.  Structs are allocated in different files than they are freed in.
      This is risky and makes memory leaks easier.
      
      Embed VirtQueueElement in VirtIOBlockReq to reduce the amount of memory
      allocation we need to juggle.  This also makes vring.c and virtio.c
      slightly more similar.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f897bf75
    • S
      virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement · 869d66af
      Stefan Hajnoczi 提交于
      In commit de6c8042 ("virtio-blk: Avoid
      zeroing every request structure") we avoided the 40 KB memset when
      allocating VirtIOBlockReq.
      
      The memset was reintroduced in commit
      671ec3f0 ("virtio-blk: Convert
      VirtIOBlockReq.elem to pointer").
      
      It must be fixed again to avoid a performance regression.
      
      Cc: Fam Zheng <famz@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      869d66af
    • S
      dataplane: do not free VirtQueueElement in vring_push() · abd76425
      Stefan Hajnoczi 提交于
      VirtQueueElement is allocated in vring_pop() so it seems to make sense
      that vring_push() should free it.  Alas, virtio-blk frees
      VirtQueueElement itself in virtio_blk_free_request().
      
      This patch solves a double-free assertion in glib's g_slice_free().
      
      Rename vring_free_element() to vring_unmap_element() since it no longer
      frees the VirtQueueElement.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Tested-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      abd76425
    • S
      virtio-blk: avoid dataplane VirtIOBlockReq early free · 0a21ea32
      Stefan Hajnoczi 提交于
      VirtIOBlockReq is freed later by virtio_blk_free_request() in
      hw/block/virtio-blk.c.  Remove this extraneous g_slice_free().
      
      This patch fixes the following segfault:
      
        0x00005555556373af in virtio_blk_rw_complete (opaque=0x5555565ff5e0, ret=0) at hw/block/virtio-blk.c:99
        99          bdrv_acct_done(req->dev->bs, &req->acct);
        (gdb) print req
        $1 = (VirtIOBlockReq *) 0x5555565ff5e0
        (gdb) print req->dev
        $2 = (VirtIOBlock *) 0x0
        (gdb) bt
        #0  0x00005555556373af in virtio_blk_rw_complete (opaque=0x5555565ff5e0, ret=0) at hw/block/virtio-blk.c:99
        #1  0x0000555555840ebe in bdrv_co_em_bh (opaque=0x5555566152d0) at block.c:4675
        #2  0x000055555583de77 in aio_bh_poll (ctx=ctx@entry=0x5555563a8150) at async.c:81
        #3  0x000055555584b7a7 in aio_poll (ctx=0x5555563a8150, blocking=blocking@entry=true) at aio-posix.c:188
        #4  0x00005555556e520e in iothread_run (opaque=0x5555563a7fd8) at iothread.c:41
        #5  0x00007ffff42ba124 in start_thread () from /usr/lib/libpthread.so.0
        #6  0x00007ffff16d14bd in clone () from /usr/lib/libc.so.6
      Reported-by: NMax Reitz <mreitz@redhat.com>
      Cc: Fam Zheng <famz@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Tested-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0a21ea32
    • K
      block: Assert qiov length matches request length · 8eb029c2
      Kevin Wolf 提交于
      At least raw-posix relies on this because it can allocate bounce buffers
      based on the request length, but access it using all of the qiov entries
      later.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      8eb029c2
    • K
      qed: Make qiov match request size until backing file EOF · f06ee3d4
      Kevin Wolf 提交于
      If a QED image has a shorter backing file and a read request to
      unallocated clusters goes across EOF of the backing file, the backing
      file sees a shortened request and the rest is filled with zeros.
      However, the original too long qiov was used with the shortened request.
      
      This patch makes the qiov size match the request size, avoiding a
      potential buffer overflow in raw-posix.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      f06ee3d4
    • K
      qcow2: Make qiov match request size until backing file EOF · 44deba5a
      Kevin Wolf 提交于
      If a qcow2 image has a shorter backing file and a read request to
      unallocated clusters goes across EOF of the backing file, the backing
      file sees a shortened request and the rest is filled with zeros.
      However, the original too long qiov was used with the shortened request.
      
      This patch makes the qiov size match the request size, avoiding a
      potential buffer overflow in raw-posix.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      44deba5a