OSDN Git Service

postcopy: Add extra check for COPY function
authorDr. David Alan Gilbert <dgilbert@redhat.com>
Fri, 24 Feb 2017 18:28:44 +0000 (18:28 +0000)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Tue, 28 Feb 2017 11:30:24 +0000 (11:30 +0000)
As an extra sanity check, make sure the region we're registering
can perform UFFDIO_COPY;  the COPY will fail later but this
gives a cleaner failure.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20170224182844.32452-17-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
migration/postcopy-ram.c

index 102fb61..effbeb6 100644 (file)
@@ -378,6 +378,10 @@ static int ram_block_enable_notify(const char *block_name, void *host_addr,
         error_report("%s userfault register: %s", __func__, strerror(errno));
         return -1;
     }
+    if (!(reg_struct.ioctls & ((__u64)1 << _UFFDIO_COPY))) {
+        error_report("%s userfault: Region doesn't support COPY", __func__);
+        return -1;
+    }
 
     return 0;
 }