All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: liuhaiwei <liuhaiwei9699@126.com>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com
Subject: Re: [PATCH 1/3] virtio-net: fix max vring buf size when set ring num
Date: Mon, 19 Sep 2022 06:21:54 -0400	[thread overview]
Message-ID: <20220919062020-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220919093915.33003-1-liuhaiwei9699@126.com>

On Mon, Sep 19, 2022 at 05:39:13AM -0400, liuhaiwei wrote:

Pls write a commit log. Explain what is this patch fixing
and why this is the correct fix.


> Signed-off-by: liuhaiwei <liuhaiwei9699@126.com>

Please use your full first and last name.
No anonymous contributions.

> ---
>  hw/virtio/virtio.c         | 10 +++++++---
>  include/hw/virtio/virtio.h |  1 +
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 5d607aeaa0..d93c20d747 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2286,13 +2286,17 @@ void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc,
>  
>  void virtio_queue_set_num(VirtIODevice *vdev, int n, int num)
>  {
> +    int vq_max_size = VIRTQUEUE_MAX_SIZE;
> +    if (!strcmp(vdev->name, "virtio-net")) {
> +        vq_max_size = VIRTIO_NET_VQ_MAX_SIZE;
> +    }
> +


Any less ugly ways to do this?

>      /* Don't allow guest to flip queue between existent and
>       * nonexistent states, or to set it to an invalid size.
>       */
>      if (!!num != !!vdev->vq[n].vring.num ||
> -        num > VIRTQUEUE_MAX_SIZE ||
> -        num < 0) {
> -        return;
> +        num > vq_max_size || num < 0) {
> +	    return;
>      }
>      vdev->vq[n].vring.num = num;
>  }
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index db1c0ddf6b..1f4d2eb5d7 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -50,6 +50,7 @@ size_t virtio_feature_get_config_size(const VirtIOFeature *features,
>  typedef struct VirtQueue VirtQueue;
>  
>  #define VIRTQUEUE_MAX_SIZE 1024
> +#define VIRTIO_NET_VQ_MAX_SIZE (4096)



>  
>  typedef struct VirtQueueElement
>  {
> -- 
> 2.27.0



      parent reply	other threads:[~2022-09-19 10:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19  9:39 [PATCH 1/3] virtio-net: fix max vring buf size when set ring num liuhaiwei
2022-09-19  9:39 ` [PATCH 2/3] virtio-net: update the default and max of rx/tx_queue_size liuhaiwei
2022-09-19 10:22   ` Michael S. Tsirkin
2022-09-19  9:39 ` [PATCH 3/3] virtio-net: set the max of queue size to 4096 liuhaiwei
2022-09-19 10:23   ` Michael S. Tsirkin
2022-09-19 10:21 ` Michael S. Tsirkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919062020-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=liuhaiwei9699@126.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.