[Qemu-devel] [PATCH v3 16/16] postcopy: Add extra check for COPY function

Dr. David Alan Gilbert (git) posted 16 patches 8 years, 11 months ago
[Qemu-devel] [PATCH v3 16/16] postcopy: Add extra check for COPY function
Posted by Dr. David Alan Gilbert (git) 8 years, 11 months ago
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

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>
---
 migration/postcopy-ram.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 102fb61..effbeb6 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -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;
 }
-- 
2.9.3


Re: [Qemu-devel] [PATCH v3 16/16] postcopy: Add extra check for COPY function
Posted by Laurent Vivier 8 years, 11 months ago
On 24/02/2017 19:28, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> 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>
> ---
>  migration/postcopy-ram.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> index 102fb61..effbeb6 100644
> --- a/migration/postcopy-ram.c
> +++ b/migration/postcopy-ram.c
> @@ -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;
>  }
> 
Reviewed-by: Laurent Vivier <lvivier@redhat.com>