diff mbox

[v1,09/12] tmem: Check version and maxpools when XEN_SYSCTL_TMEM_SET_CLIENT_INFO

Message ID 1475055746-22401-10-git-send-email-konrad.wilk@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Konrad Rzeszutek Wilk Sept. 28, 2016, 9:42 a.m. UTC
is called. If they are different from what the hypervisor
can support we will get the appropiate errors.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>

v1: First submission.
---
 tools/libxc/xc_tmem.c       | 1 -
 xen/common/tmem_control.c   | 6 ++++++
 xen/include/public/sysctl.h | 5 +++--
 3 files changed, 9 insertions(+), 3 deletions(-)

Comments

Wei Liu Sept. 28, 2016, 11 a.m. UTC | #1
On Wed, Sep 28, 2016 at 05:42:23AM -0400, Konrad Rzeszutek Wilk wrote:
> is called. If they are different from what the hypervisor
> can support we will get the appropiate errors.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> 
> v1: First submission.
> ---
>  tools/libxc/xc_tmem.c       | 1 -

Acked-by: Wei Liu <wei.liu2@citrix.com>
Jan Beulich Sept. 28, 2016, 12:58 p.m. UTC | #2
>>> On 28.09.16 at 11:42, <konrad.wilk@oracle.com> wrote:
> --- a/xen/common/tmem_control.c
> +++ b/xen/common/tmem_control.c
> @@ -270,6 +270,12 @@ static int __tmemc_set_var(struct client *client,
>      if ( copy_from_guest(&info, buf, 1) )
>          return -EFAULT;
>  
> +    if ( info.version != TMEM_SPEC_VERSION )
> +        return -EOPNOTSUPP;
> +
> +    if ( info.maxpools > MAX_POOLS_PER_DOMAIN )
> +        return -ERANGE;

Ah, here we go. But ...

> --- a/xen/include/public/sysctl.h
> +++ b/xen/include/public/sysctl.h
> @@ -787,8 +787,9 @@ struct tmem_handle {
>   * during migration.
>   */
>  struct tmem_client {
> -    uint32_t version;
> -    uint32_t maxpools;
> +    uint32_t version;   /* If mismatched we will get XEN_ENOSPC. */
> +    uint32_t maxpools;  /* If greater than what hypervisor supports, will get
> +                           XEN_ERANGE. */

... while the latter comment matches the code, the former doesn't.

Jan
diff mbox

Patch

diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c
index cb0dfa1..7873674 100644
--- a/tools/libxc/xc_tmem.c
+++ b/tools/libxc/xc_tmem.c
@@ -383,7 +383,6 @@  int xc_tmem_restore(xc_interface *xch, int dom, int io_fd)
 
     if ( read_exact(io_fd, &info, sizeof(info)) )
         return -1;
-    /* FIXME check here to ensure no version mismatch or maxpools mismatch */
     if ( xc_tmem_control(xch,0,XEN_SYSCTL_TMEM_OP_RESTORE_BEGIN,dom,0,0,NULL) < 0 )
         return -1;
 
diff --git a/xen/common/tmem_control.c b/xen/common/tmem_control.c
index 942d4c9..6f1de9d 100644
--- a/xen/common/tmem_control.c
+++ b/xen/common/tmem_control.c
@@ -270,6 +270,12 @@  static int __tmemc_set_var(struct client *client,
     if ( copy_from_guest(&info, buf, 1) )
         return -EFAULT;
 
+    if ( info.version != TMEM_SPEC_VERSION )
+        return -EOPNOTSUPP;
+
+    if ( info.maxpools > MAX_POOLS_PER_DOMAIN )
+        return -ERANGE;
+
     if ( info.weight != client->info.weight )
     {
         old_weight = client->info.weight;
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 52898a7..36e2fd8 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -787,8 +787,9 @@  struct tmem_handle {
  * during migration.
  */
 struct tmem_client {
-    uint32_t version;
-    uint32_t maxpools;
+    uint32_t version;   /* If mismatched we will get XEN_ENOSPC. */
+    uint32_t maxpools;  /* If greater than what hypervisor supports, will get
+                           XEN_ERANGE. */
     union {             /* See TMEM_CLIENT_[COMPRESS,FROZEN] */
         uint32_t raw;
         struct {