qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 3/3] vhost-user-blk: add discard/write zeroes


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 3/3] vhost-user-blk: add discard/write zeroes features support
Date: Wed, 16 Jan 2019 14:26:40 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jan 16, 2019 at 01:19:30PM +0800, Changpeng Liu wrote:
> @@ -161,6 +175,44 @@ vub_writev(VubReq *req, struct iovec *iov, uint32_t 
> iovcnt)
>      return rc;
>  }
>  
> +static int
> +vub_discard_write_zeroes(VubReq *req, struct iovec *iov, uint32_t iovcnt,
> +                         uint32_t type)
> +{
> +    struct virtio_blk_discard_write_zeroes *desc;
> +    ssize_t size;
> +    void *buf;
> +
> +    size = vub_iov_size(iov, iovcnt);
> +    if (size != sizeof(*desc)) {
> +        fprintf(stderr, "Invalid size %ld, expect %ld\n", size, 
> sizeof(*desc));
> +        return -1;
> +    }
> +    buf = g_new0(char, size);
> +    vub_iov_to_buf(iov, iovcnt, buf);

It's simpler without g_new0():

  struct virtio_blk_discard_write_zeroes desc;
  ssize_t size;

  size = vub_iov_size(iov, iovcnt);
  if (size != sizeof(desc)) {
      fprintf(stderr, "Invalid size %zd, expected %zu\n", size, sizeof(desc));
      return -1;
  }
  vub_iov_to_buf(iov, iovcnt, &desc);

  ...

Other than that:

Reviewed-by: Stefan Hajnoczi <address@hidden>

Attachment: signature.asc
Description: PGP signature


reply via email to

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