[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 06/29] virtio-net: Honor VIRTIO_CONFIG_S_DEVICE_STOPPED
From: |
Eugenio Pérez |
Subject: |
[RFC v3 06/29] virtio-net: Honor VIRTIO_CONFIG_S_DEVICE_STOPPED |
Date: |
Wed, 19 May 2021 18:28:40 +0200 |
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)
--
2.27.0
- [RFC v3 00/29] vDPA software assisted live migration, Eugenio Pérez, 2021/05/19
- [RFC v3 01/29] virtio: Add virtio_queue_is_host_notifier_enabled, Eugenio Pérez, 2021/05/19
- [RFC v3 02/29] vhost: Save masked_notifier state, Eugenio Pérez, 2021/05/19
- [RFC v3 03/29] vhost: Add VhostShadowVirtqueue, Eugenio Pérez, 2021/05/19
- [RFC v3 05/29] virtio: Add VIRTIO_F_QUEUE_STATE, Eugenio Pérez, 2021/05/19
- [RFC v3 04/29] vhost: Add x-vhost-enable-shadow-vq qmp, Eugenio Pérez, 2021/05/19
- [RFC v3 06/29] virtio-net: Honor VIRTIO_CONFIG_S_DEVICE_STOPPED,
Eugenio Pérez <=
- [RFC v3 07/29] vhost: Route guest->host notification through shadow virtqueue, Eugenio Pérez, 2021/05/19
- [RFC v3 08/29] vhost: Route host->guest notification through shadow virtqueue, Eugenio Pérez, 2021/05/19
- [RFC v3 09/29] vhost: Avoid re-set masked notifier in shadow vq, Eugenio Pérez, 2021/05/19
- [RFC v3 10/29] virtio: Add vhost_shadow_vq_get_vring_addr, Eugenio Pérez, 2021/05/19
- [RFC v3 11/29] vhost: Add vhost_vring_pause operation, Eugenio Pérez, 2021/05/19
- [RFC v3 12/29] vhost: add vhost_kernel_vring_pause, Eugenio Pérez, 2021/05/19
- [RFC v3 13/29] vhost: Add vhost_get_iova_range operation, Eugenio Pérez, 2021/05/19