[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/51] vhost-user: Fix the virtio features negotiation flaw
From: |
Michael S. Tsirkin |
Subject: |
[PULL 14/51] vhost-user: Fix the virtio features negotiation flaw |
Date: |
Thu, 5 Jan 2023 04:15:02 -0500 |
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
This patch aims to fix unexpected negotiation features for
vhost-user netdev interface.
When openvswitch reconnect Qemu after an unexpected disconnection
and Qemu therefore start the vhost_dev, acked_features field in
vhost_dev is initialized with value fetched from acked_features
field in NetVhostUserState, which should be up-to-date at that
moment but Qemu could not make it actually during the time window
of virtio features negotiation.
So we save the acked_features right after being configured by
guest virtio driver so it can be used to restore acked_features
field in vhost_dev correctly.
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Signed-off-by: Liuxiangdong <liuxiangdong5@huawei.com>
Message-Id:
<b9f8cf5561a79ea65ea38960e5a5e6d3707eef0a.1671627406.git.huangy81@chinatelecom.cn>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/net/vhost_net.h | 2 ++
hw/net/vhost_net-stub.c | 5 +++++
hw/net/vhost_net.c | 9 +++++++++
hw/net/virtio-net.c | 6 ++++++
4 files changed, 22 insertions(+)
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 40b9a40074..dfb13756cd 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -52,4 +52,6 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev,
NetClientState *nc,
int vq_index);
int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
int vq_index);
+
+void vhost_net_save_acked_features(NetClientState *nc);
#endif
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
index 9f7daae99c..66ed5f0b98 100644
--- a/hw/net/vhost_net-stub.c
+++ b/hw/net/vhost_net-stub.c
@@ -113,3 +113,8 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev,
NetClientState *nc,
{
return 0;
}
+
+void vhost_net_save_acked_features(NetClientState *nc)
+{
+
+}
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 043058ff43..984b130e8f 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -144,6 +144,15 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net)
return net->dev.acked_features;
}
+void vhost_net_save_acked_features(NetClientState *nc)
+{
+#ifdef CONFIG_VHOST_NET_USER
+ if (nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+ vhost_user_save_acked_features(nc);
+ }
+#endif
+}
+
static int vhost_net_get_fd(NetClientState *backend)
{
switch (backend->info->type) {
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 122eac25ee..b342d66160 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -984,6 +984,12 @@ static void virtio_net_set_features(VirtIODevice *vdev,
uint64_t features)
continue;
}
vhost_net_ack_features(get_vhost_net(nc->peer), features);
+
+ /*
+ * keep acked_features in NetVhostUserState up-to-date so it
+ * can't miss any features configured by guest virtio driver.
+ */
+ vhost_net_save_acked_features(nc->peer);
}
if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) {
--
MST
- [PULL 04/51] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa, (continued)
- [PULL 04/51] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa, Michael S. Tsirkin, 2023/01/05
- [PULL 05/51] hw/acpi/Kconfig: Rename ACPI_X86_ICH to ACPI_ICH9, Michael S. Tsirkin, 2023/01/05
- [PULL 06/51] hw/acpi/Kconfig: Add missing dependencies to ACPI_ICH9, Michael S. Tsirkin, 2023/01/05
- [PULL 07/51] hw/acpi/Kconfig: Do not needlessly build TYPE_PIIX4_PM in non-PC/Malta machines, Michael S. Tsirkin, 2023/01/05
- [PULL 08/51] hw/acpi/Kconfig: Add missing dependencies to ACPI_PIIX4, Michael S. Tsirkin, 2023/01/05
- [PULL 09/51] hw/isa/Kconfig: Add missing dependency to VT82C686, Michael S. Tsirkin, 2023/01/05
- [PULL 10/51] i386, mips: Resolve redundant ACPI and APM dependencies, Michael S. Tsirkin, 2023/01/05
- [PULL 11/51] hw/ppc/Kconfig: Remove unused dependencies from PEGASOS2, Michael S. Tsirkin, 2023/01/05
- [PULL 12/51] vhost-user: Refactor vhost acked features saving, Michael S. Tsirkin, 2023/01/05
- [PULL 13/51] vhost-user: Refactor the chr_closed_bh, Michael S. Tsirkin, 2023/01/05
- [PULL 14/51] vhost-user: Fix the virtio features negotiation flaw,
Michael S. Tsirkin <=
- [PULL 16/51] virtio-pci: decouple notifier from interrupt process, Michael S. Tsirkin, 2023/01/05
- [PULL 17/51] virtio-pci: decouple the single vector from the interrupt process, Michael S. Tsirkin, 2023/01/05
- [PULL 15/51] virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX, Michael S. Tsirkin, 2023/01/05
- [PULL 18/51] vhost: introduce new VhostOps vhost_set_config_call, Michael S. Tsirkin, 2023/01/05
- [PULL 20/51] virtio: add support for configure interrupt, Michael S. Tsirkin, 2023/01/05
- [PULL 23/51] virtio-mmio: add support for configure interrupt, Michael S. Tsirkin, 2023/01/05
- [PULL 19/51] vhost-vdpa: add support for config interrupt, Michael S. Tsirkin, 2023/01/05
- [PULL 21/51] vhost: add support for configure interrupt, Michael S. Tsirkin, 2023/01/05
- [PULL 22/51] virtio-net: add support for configure interrupt, Michael S. Tsirkin, 2023/01/05
- [PULL 24/51] virtio-pci: add support for configure interrupt, Michael S. Tsirkin, 2023/01/05