qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] virtio: add a way to disable a queue


From: Jason Wang
Subject: Re: [PATCH 1/2] virtio: add a way to disable a queue
Date: Mon, 2 Aug 2021 12:50:08 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0


在 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 via email to

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