1. 01 11月, 2016 6 次提交
  2. 17 10月, 2016 10 次提交
    • L
      9pfs: fix memory leak in v9fs_write · fdfcc9ae
      Li Qiang 提交于
      If an error occurs when marshalling the transfer length to the guest, the
      v9fs_write() function doesn't free an IO vector, thus leading to a memory
      leak. This patch fixes the issue.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      [groug, rephrased the changelog]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      fdfcc9ae
    • L
      9pfs: fix memory leak in v9fs_link · 4c158678
      Li Qiang 提交于
      The v9fs_link() function keeps a reference on the source fid object. This
      causes a memory leak since the reference never goes down to 0. This patch
      fixes the issue.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      [groug, rephrased the changelog]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      4c158678
    • L
      9pfs: fix memory leak in v9fs_xattrcreate · ff55e94d
      Li Qiang 提交于
      The 'fs.xattr.value' field in V9fsFidState object doesn't consider the
      situation that this field has been allocated previously. Every time, it
      will be allocated directly. This leads to a host memory leak issue if
      the client sends another Txattrcreate message with the same fid number
      before the fid from the previous time got clunked.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      [groug, updated the changelog to indicate how the leak can occur]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      ff55e94d
    • L
      9pfs: fix information leak in xattr read · eb687602
      Li Qiang 提交于
      9pfs uses g_malloc() to allocate the xattr memory space, if the guest
      reads this memory before writing to it, this will leak host heap memory
      to the guest. This patch avoid this.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      eb687602
    • G
      virtio-9p: add reset handler · 0e44a0fd
      Greg Kurz 提交于
      Virtio devices should implement the VirtIODevice->reset() function to
      perform necessary cleanup actions and to bring the device to a quiescent
      state.
      
      In the case of the virtio-9p device, this means:
      - emptying the list of active PDUs (i.e. draining all in-flight I/O)
      - freeing all fids (i.e. close open file descriptors and free memory)
      
      That's what this patch does.
      
      The reset handler first waits for all active PDUs to complete. Since
      completion happens in the QEMU global aio context, we just have to
      loop around aio_poll() until the active list is empty.
      
      The freeing part involves some actions to be performed on the backend,
      like closing file descriptors or flushing extended attributes to the
      underlying filesystem. The virtfs_reset() function already does the
      job: it calls free_fid() for all open fids not involved in an ongoing
      I/O operation. We are sure this is the case since we have drained
      the PDU active list.
      
      The current code implements all backend accesses with coroutines, but we
      want to stay synchronous on the reset path. We can either change the
      current code to be able to run when not in coroutine context, or create
      a coroutine context and wait for virtfs_reset() to complete. This patch
      goes for the latter because it results in simpler code.
      
      Note that we also need to create a dummy PDU because it is also an API
      to pass the FsContext pointer to all backend callbacks.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      0e44a0fd
    • G
      9pfs: only free completed request if not flushed · f74e27bf
      Greg Kurz 提交于
      If a PDU has a flush request pending, the current code calls pdu_free()
      twice:
      
      1) pdu_complete()->pdu_free() with pdu->cancelled set, which does nothing
      
      2) v9fs_flush()->pdu_free() with pdu->cancelled cleared, which moves the
         PDU back to the free list.
      
      This works but it complexifies the logic of pdu_free().
      
      With this patch, pdu_complete() only calls pdu_free() if no flush request
      is pending, i.e. qemu_co_queue_next() returns false.
      
      Since pdu_free() is now supposed to be called with pdu->cancelled cleared,
      the check in pdu_free() is dropped and replaced by an assertion.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      f74e27bf
    • G
      9pfs: drop useless check in pdu_free() · 6868a420
      Greg Kurz 提交于
      Out of the three users of pdu_free(), none ever passes a NULL pointer to
      this function.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      6868a420
    • G
      9pfs: use coroutine_fn annotation in hw/9pfs/9p.[ch] · 8440e22e
      Greg Kurz 提交于
      All these functions either call the v9fs_co_* functions which have the
      coroutine_fn annotation, or pdu_complete() which calls qemu_co_queue_next().
      
      Let's mark them to make it obvious they execute in coroutine context.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      8440e22e
    • L
      9pfs: fix potential host memory leak in v9fs_read · e95c9a49
      Li Qiang 提交于
      In 9pfs read dispatch function, it doesn't free two QEMUIOVector
      object thus causing potential memory leak. This patch avoid this.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      e95c9a49
    • L
      9pfs: allocate space for guest originated empty strings · ba42ebb8
      Li Qiang 提交于
      If a guest sends an empty string paramater to any 9P operation, the current
      code unmarshals it into a V9fsString equal to { .size = 0, .data = NULL }.
      
      This is unfortunate because it can cause NULL pointer dereference to happen
      at various locations in the 9pfs code. And we don't want to check str->data
      everywhere we pass it to strcmp() or any other function which expects a
      dereferenceable pointer.
      
      This patch enforces the allocation of genuine C empty strings instead, so
      callers don't have to bother.
      
      Out of all v9fs_iov_vunmarshal() users, only v9fs_xattrwalk() checks if
      the returned string is empty. It now uses v9fs_string_size() since
      name.data cannot be NULL anymore.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      [groug, rewritten title and changelog,
       fix empty string check in v9fs_xattrwalk()]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      ba42ebb8
  3. 19 9月, 2016 1 次提交
  4. 16 9月, 2016 2 次提交
  5. 31 8月, 2016 3 次提交
  6. 13 7月, 2016 1 次提交
    • P
      coroutine: move entry argument to qemu_coroutine_create · 0b8b8753
      Paolo Bonzini 提交于
      In practice the entry argument is always known at creation time, and
      it is confusing that sometimes qemu_coroutine_enter is used with a
      non-NULL argument to re-enter a coroutine (this happens in
      block/sheepdog.c and tests/test-coroutine.c).  So pass the opaque value
      at creation time, for consistency with e.g. aio_bh_new.
      
      Mostly done with the following semantic patch:
      
      @ entry1 @
      expression entry, arg, co;
      @@
      - co = qemu_coroutine_create(entry);
      + co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry2 @
      expression entry, arg;
      identifier co;
      @@
      - Coroutine *co = qemu_coroutine_create(entry);
      + Coroutine *co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry3 @
      expression entry, arg;
      @@
      - qemu_coroutine_enter(qemu_coroutine_create(entry), arg);
      + qemu_coroutine_enter(qemu_coroutine_create(entry, arg));
      
      @ reentry @
      expression co;
      @@
      - qemu_coroutine_enter(co, NULL);
      + qemu_coroutine_enter(co);
      
      except for the aforementioned few places where the semantic patch
      stumbled (as expected) and for test_co_queue, which would otherwise
      produce an uninitialized variable warning.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0b8b8753
  7. 06 6月, 2016 5 次提交
  8. 23 3月, 2016 1 次提交
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  9. 07 2月, 2016 1 次提交
    • P
      virtio: move allocation to virtqueue_pop/vring_pop · 51b19ebe
      Paolo Bonzini 提交于
      The return code of virtqueue_pop/vring_pop is unused except to check for
      errors or 0.  We can thus easily move allocation inside the functions
      and just return a pointer to the VirtQueueElement.
      
      The advantage is that we will be able to allocate only the space that
      is needed for the actual size of the s/g list instead of the full
      VIRTQUEUE_MAX_SIZE items.  Currently VirtQueueElement takes about 48K
      of memory, and this kind of allocation puts a lot of stress on malloc.
      By cutting the size by two or three orders of magnitude, malloc can
      use much more efficient algorithms.
      
      The patch is pretty large, but changes to each device are testable
      more or less independently.  Splitting it would mostly add churn.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NCornelia Huck <cornelia.huck@de.ibm.com>
      51b19ebe
  10. 29 1月, 2016 1 次提交
    • P
      9pfs: Clean up includes · fbc04127
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1453832250-766-18-git-send-email-peter.maydell@linaro.org
      fbc04127
  11. 22 1月, 2016 1 次提交
  12. 12 1月, 2016 1 次提交
  13. 08 1月, 2016 7 次提交