qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC v3 06/29] virtio-net: Honor VIRTIO_CONFIG_S_DEVICE_STOPPED


From: Jason Wang
Subject: Re: [RFC v3 06/29] virtio-net: Honor VIRTIO_CONFIG_S_DEVICE_STOPPED
Date: Wed, 26 May 2021 09:10:22 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2


在 2021/5/26 上午9:06, Jason Wang 写道:

在 2021/5/20 上午12:28, Eugenio Pérez 写道:
So the guest can stop and start net device. It implements the RFC
https://lists.oasis-open.org/archives/virtio-comment/202012/msg00027.html

To stop (as "pause") the device is required to migrate status and vring
addresses between device and SVQ.

This is a WIP commit: as with VIRTIO_F_QUEUE_STATE, is introduced in
virtio_config.h before of even proposing for the kernel, with no feature
flag, and, with no checking in the device. It also needs a modified
vp_vdpa driver that supports to set and retrieve status.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
  include/standard-headers/linux/virtio_config.h | 2 ++
  hw/net/virtio-net.c                            | 4 +++-
  2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/standard-headers/linux/virtio_config.h b/include/standard-headers/linux/virtio_config.h
index 59fad3eb45..b3f6b1365d 100644
--- a/include/standard-headers/linux/virtio_config.h
+++ b/include/standard-headers/linux/virtio_config.h
@@ -40,6 +40,8 @@
  #define VIRTIO_CONFIG_S_DRIVER_OK    4
  /* Driver has finished configuring features */
  #define VIRTIO_CONFIG_S_FEATURES_OK    8
+/* Device is stopped */
+#define VIRTIO_CONFIG_S_DEVICE_STOPPED 32
  /* Device entered invalid state, driver must reset it */
  #define VIRTIO_CONFIG_S_NEEDS_RESET    0x40
  /* We've given up on this device. */
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 96a3cc8357..2d3caea289 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -198,7 +198,9 @@ static bool virtio_net_started(VirtIONet *n, uint8_t status)
  {
      VirtIODevice *vdev = VIRTIO_DEVICE(n);
      return (status & VIRTIO_CONFIG_S_DRIVER_OK) &&
-        (n->status & VIRTIO_NET_S_LINK_UP) && vdev->vm_running;
+        (!(n->status & VIRTIO_CONFIG_S_DEVICE_STOPPED)) &&
+        (n->status & VIRTIO_NET_S_LINK_UP) &&
+        vdev->vm_running;
  }
    static void virtio_net_announce_notify(VirtIONet *net)


It looks to me this is only the part of pause.


And even for pause, I don't see anything that prevents rx/tx from being executed? (E.g virtio_net_handle_tx_bh or virtio_net_handle_rx).

Thanks


We still need the resume?

Thanks






reply via email to

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