You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.1 KiB
59 lines
2.1 KiB
From fec618a3fdcc88fa50089edb5748a6554ac49070 Mon Sep 17 00:00:00 2001 |
|
From: Maxime Coquelin <maxime.coquelin@redhat.com> |
|
Date: Wed, 13 Dec 2017 09:51:06 +0100 |
|
Subject: [PATCH 1/6] vhost: prevent features to be changed while device is |
|
running |
|
|
|
As section 2.2 of the Virtio spec states about features |
|
negotiation: |
|
"During device initialization, the driver reads this and tells |
|
the device the subset that it accepts. The only way to |
|
renegotiate is to reset the device." |
|
|
|
This patch implements a check to prevent illegal features change |
|
while the device is running. |
|
|
|
One exception is the VHOST_F_LOG_ALL feature bit, which is enabled |
|
when live-migration is initiated. But this feature is not negotiated |
|
with the Virtio driver, but directly with the Vhost master. |
|
|
|
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> |
|
Acked-by: Laszlo Ersek <lersek@redhat.com> |
|
Acked-by: Yuanhan Liu <yliu@fridaylinux.org> |
|
(cherry picked from commit 07f8db29b8833378dd506f3e197319f8b669aed9) |
|
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> |
|
--- |
|
dpdk-17.11/lib/librte_vhost/vhost_user.c | 17 ++++++++++++++++- |
|
1 file changed, 16 insertions(+), 1 deletion(-) |
|
|
|
diff --git a/dpdk-17.11/lib/librte_vhost/vhost_user.c b/dpdk-17.11/lib/librte_vhost/vhost_user.c |
|
index f4c7ce462..545dbcb2b 100644 |
|
--- a/dpdk-17.11/lib/librte_vhost/vhost_user.c |
|
+++ b/dpdk-17.11/lib/librte_vhost/vhost_user.c |
|
@@ -183,7 +183,22 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) |
|
return -1; |
|
} |
|
|
|
- if ((dev->flags & VIRTIO_DEV_RUNNING) && dev->features != features) { |
|
+ if (dev->flags & VIRTIO_DEV_RUNNING) { |
|
+ if (dev->features == features) |
|
+ return 0; |
|
+ |
|
+ /* |
|
+ * Error out if master tries to change features while device is |
|
+ * in running state. The exception being VHOST_F_LOG_ALL, which |
|
+ * is enabled when the live-migration starts. |
|
+ */ |
|
+ if ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) { |
|
+ RTE_LOG(ERR, VHOST_CONFIG, |
|
+ "(%d) features changed while device is running.\n", |
|
+ dev->vid); |
|
+ return -1; |
|
+ } |
|
+ |
|
if (dev->notify_ops->features_changed) |
|
dev->notify_ops->features_changed(dev->vid, features); |
|
} |
|
-- |
|
2.14.3 |
|
|
|
|