[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v1 09/12] tmem: Check version and maxpools when XEN_SYSCTL_TMEM_SET_CLIENT_INFO



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@xxxxxxxxxx>

---
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>

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(-)

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 {
-- 
2.4.11


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.