qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 6/6] virtio-blk: release reference to RAM's m


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 6/6] virtio-blk: release reference to RAM's memoryRegion
Date: Fri, 3 May 2013 12:09:27 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, May 03, 2013 at 10:45:22AM +0800, Liu Ping Fan wrote:
> From: Liu Ping Fan <address@hidden>
> 
> virtio-blk will unref RAM's memoryRegion when the io-req has been
> done. So we can avoid to call bdrv_drain_all() when RAM hot unplug.
> 
> Signed-off-by: Liu Ping Fan <address@hidden>
> ---
>  hw/block/dataplane/virtio-blk.c |   51 +++++++++++++++++++++++++++++---------
>  1 files changed, 39 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
> index 3bb57d1..047e1df 100644
> --- a/hw/block/dataplane/virtio-blk.c
> +++ b/hw/block/dataplane/virtio-blk.c
> @@ -35,6 +35,8 @@ enum {
>  
>  typedef struct {
>      struct iocb iocb;               /* Linux AIO control block */
> +    MemoryRegion *mrs[VRING_MAX];
> +    int mrs_cnt;
>      QEMUIOVector *inhdr;            /* iovecs for virtio_blk_inhdr */
>      unsigned int head;              /* vring descriptor index */
>      struct iovec *bounce_iov;       /* used if guest buffers are unaligned */
> @@ -121,6 +123,10 @@ static void complete_request(struct iocb *iocb, ssize_t 
> ret, void *opaque)
>       * transferred plus the status bytes.
>       */
>      vring_push(&s->vring, req->head, len + sizeof(hdr));
> +    while (--req->mrs_cnt >= 0) {
> +        memory_region_unref(req->mrs[req->mrs_cnt]);
> +    }

The vring has the property that every virtqueue element popped will be
pushed back.

Therefore it might be nicer to hide the MemoryRegion unref inside
vring_push().  The user wouldn't have to know about MemoryRegion -
that's especially nice since there are other devices besides virtio-blk
(like virtio-net) that would need to be modified if we use the current
approach.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]