[PATCH v1 23/24] s390/vfio-ap: Disallow blocking migration in progress

Anthony Krowiak posted 23 patches 1 week, 1 day ago
[PATCH v1 23/24] s390/vfio-ap: Disallow blocking migration in progress
Posted by Anthony Krowiak 1 week, 1 day ago
The sysfs 'migratable' attribute allows a system administrator to enable or
block live guest migration. If an attempt to block migration is attempted
while a migration is in already in progress, the migration will complete
leaving the system administrator believing that it was blocked. To prevent
this scenario, the operation will fail with the
"Device or resource busy" (-EBUSY) error if a migration is in progress.

Signed-off-by: Anthony Krowiak <akrowiak@linux.ibm.com>
---
 drivers/s390/crypto/vfio_ap_ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 1ff9994bd7ec..c8d454e52665 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -1853,6 +1853,12 @@ static ssize_t migratable_store(struct device *dev, struct device_attribute *att
 		goto out_unlock;
 	}
 
+	if (!migratable && matrix_mdev->migratable &&
+	    vfio_ap_migration_in_progress(matrix_mdev)) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
 	matrix_mdev->migratable = migratable;
 
 	if (matrix_mdev->migratable)
-- 
2.52.0