qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>,
	Jens Freimann <jfreimann@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 1/2] virtio: add a way to disable a queue
Date: Mon, 2 Aug 2021 12:50:08 +0800	[thread overview]
Message-ID: <c9b273fb-797b-4810-bb4c-d99d5173fe6c@redhat.com> (raw)
In-Reply-To: <20210729191910.317114-2-lvivier@redhat.com>


在 2021/7/30 上午3:19, Laurent Vivier 写道:
> Add virtio_queue_disable()/virtio_queue_enable() to disable/enable a queue
> by setting vring.num to 0 (or num_default).
> This is needed to be able to disable a guest driver from the host side


I suspect this won't work correclty for vhost.

And I believe we should only do this after the per queue 
enabling/disabling is supported by the spec.

(only MMIO support that AFAIK)

Thanks


>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>   include/hw/virtio/virtio.h |  2 ++
>   hw/virtio/virtio.c         | 10 ++++++++++
>   2 files changed, 12 insertions(+)
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 8bab9cfb7507..6a3f71b4cd88 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -251,6 +251,8 @@ void virtio_config_modern_writel(VirtIODevice *vdev,
>                                    uint32_t addr, uint32_t data);
>   void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr);
>   hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n);
> +void virtio_queue_enable(VirtIODevice *vdev, int n);
> +void virtio_queue_disable(VirtIODevice *vdev, int n);
>   void virtio_queue_set_num(VirtIODevice *vdev, int n, int num);
>   int virtio_queue_get_num(VirtIODevice *vdev, int n);
>   int virtio_queue_get_max_num(VirtIODevice *vdev, int n);
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 874377f37a70..fa5228c1a2d6 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2244,6 +2244,16 @@ void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc,
>       virtio_init_region_cache(vdev, n);
>   }
>   
> +void virtio_queue_disable(VirtIODevice *vdev, int n)
> +{
> +    vdev->vq[n].vring.num = 0;
> +}
> +
> +void virtio_queue_enable(VirtIODevice *vdev, int n)
> +{
> +    vdev->vq[n].vring.num = vdev->vq[n].vring.num_default;
> +}
> +
>   void virtio_queue_set_num(VirtIODevice *vdev, int n, int num)
>   {
>       /* Don't allow guest to flip queue between existent and



  reply	other threads:[~2021-08-02  4:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 19:19 [PATCH 0/2] virtio: failover: allow to keep the VFIO device rather than the virtio-net one Laurent Vivier
2021-07-29 19:19 ` [PATCH 1/2] virtio: add a way to disable a queue Laurent Vivier
2021-08-02  4:50   ` Jason Wang [this message]
2021-08-02  8:42     ` Laurent Vivier
2021-08-06  6:25       ` Jason Wang
2021-08-06  7:27         ` Laurent Vivier
2021-08-09  3:01           ` Jason Wang
2021-08-09 16:12             ` Laurent Vivier
2021-07-29 19:19 ` [PATCH 2/2] virtio: failover: define the default device to use in case of error Laurent Vivier

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=c9b273fb-797b-4810-bb4c-d99d5173fe6c@redhat.com \
    --to=jasowang@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).