Blame SOURCES/0001-vhost-prevent-features-to-be-changed-while-device-is.patch

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