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

[Xen-changelog] [xen master] tmem: Use 'struct xen_tmem_oid' in tmem_handle and move it to sysctl header.



commit 880699a8bd4046b6cbd08a35949cbd1092db4248
Author:     Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
AuthorDate: Mon Aug 31 11:13:50 2015 -0400
Commit:     Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
CommitDate: Wed Sep 2 08:48:12 2015 -0400

    tmem: Use 'struct xen_tmem_oid' in tmem_handle and move it to sysctl header.
    
    Instead of the three member uint64_t structure.
    
    The structure is used by the control stack for
    XEN_SYSCTL_TMEM_OP_SAVE_GET_NEXT_[PAGE|INV] only so
    moving it to the sysctl header.
    
    Also modified tmemc_save_get_next_page to deal with
    the new type - and converted some of the on-stack
    usage of the array to use an pointer.
    
    Further work will be to make the xen_sysctl_tmem_op have
    an union with proper type for the two: ..GET_NEXT_[PAGE|INV]
    operations.
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 tools/libxc/xc_tmem.c       |    6 +++---
 xen/common/tmem.c           |   12 ++++++------
 xen/include/public/sysctl.h |   11 +++++++++++
 xen/include/public/tmem.h   |    6 ------
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c
index 558d2ea..8f4c0cc 100644
--- a/tools/libxc/xc_tmem.c
+++ b/tools/libxc/xc_tmem.c
@@ -304,7 +304,7 @@ int xc_tmem_save(xc_interface *xch,
                 } else {
                     /* page list terminator */
                     h = (struct tmem_handle *)buf;
-                    h->oid[0] = h->oid[1] = h->oid[2] = -1L;
+                    h->oid.oid[0] = h->oid.oid[1] = h->oid.oid[2] = -1L;
                     if ( write_exact(io_fd, &h->oid, sizeof(h->oid)) )
                         return -1;
                     break;
@@ -341,8 +341,8 @@ int xc_tmem_save_extra(xc_interface *xch, int dom, int 
io_fd, int field_marker)
         if ( write_exact(io_fd, &handle.index, sizeof(handle.index)) )
             return -1;
         count++;
-        checksum += handle.pool_id + handle.oid[0] + handle.oid[1] +
-                    handle.oid[2] + handle.index;
+        checksum += handle.pool_id + handle.oid.oid[0] + handle.oid.oid[1] +
+                    handle.oid.oid[2] + handle.index;
     }
     if ( count )
             DPRINTF("needed %d tmem invalidates, check=%d\n",count,checksum);
diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index c5edab4..e454259 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -2434,7 +2434,7 @@ static int tmemc_save_get_next_page(int cli_id, uint32_t 
pool_id,
     struct tmem_pool *pool = (client == NULL || pool_id >= 
MAX_POOLS_PER_DOMAIN)
                    ? NULL : client->pools[pool_id];
     struct tmem_page_descriptor *pgp;
-    struct xen_tmem_oid oid;
+    struct xen_tmem_oid *oid;
     int ret = 0;
     struct tmem_handle h;
 
@@ -2466,10 +2466,10 @@ static int tmemc_save_get_next_page(int cli_id, 
uint32_t pool_id,
     pgp = list_entry((&pool->cur_pgp->us.pool_pers_pages)->next,
                          struct tmem_page_descriptor,us.pool_pers_pages);
     pool->cur_pgp = pgp;
-    oid = pgp->us.obj->oid;
+    oid = &pgp->us.obj->oid;
     h.pool_id = pool_id;
-    BUILD_BUG_ON(sizeof(h.oid) != sizeof(oid));
-    memcpy(h.oid, oid.oid, sizeof(h.oid));
+    BUILD_BUG_ON(sizeof(h.oid) != sizeof(*oid));
+    memcpy(&(h.oid), oid, sizeof(h.oid));
     h.index = pgp->index;
     if ( copy_to_guest(guest_handle_cast(buf, void), &h, 1) )
     {
@@ -2477,7 +2477,7 @@ static int tmemc_save_get_next_page(int cli_id, uint32_t 
pool_id,
         goto out;
     }
     guest_handle_add_offset(buf, sizeof(h));
-    ret = do_tmem_get(pool, &oid, pgp->index, 0, buf);
+    ret = do_tmem_get(pool, oid, pgp->index, 0, buf);
 
 out:
     spin_unlock(&pers_lists_spinlock);
@@ -2517,7 +2517,7 @@ static int tmemc_save_get_next_inv(int cli_id, 
tmem_cli_va_param_t buf,
     }
     h.pool_id = pgp->pool_id;
     BUILD_BUG_ON(sizeof(h.oid) != sizeof(pgp->inv_oid));
-    memcpy(h.oid, pgp->inv_oid.oid, sizeof(h.oid));
+    memcpy(&(h.oid), &(pgp->inv_oid), sizeof(h.oid));
     h.index = pgp->index;
     ret = 1;
     if ( copy_to_guest(guest_handle_cast(buf, void), &h, 1) )
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 3bdf0e1..0cacacc 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -738,6 +738,17 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_psr_cat_op_t);
 #define XEN_SYSCTL_TMEM_OP_RESTORE_PUT_PAGE       32
 #define XEN_SYSCTL_TMEM_OP_RESTORE_FLUSH_PAGE     33
 
+/*
+ * XEN_SYSCTL_TMEM_OP_SAVE_GET_NEXT_[PAGE|INV] override the 'buf' in
+ * xen_sysctl_tmem_op with this structure - sometimes with an extra
+ * page tackled on.
+ */
+struct tmem_handle {
+    uint32_t pool_id;
+    uint32_t index;
+    xen_tmem_oid_t oid;
+};
+
 struct xen_sysctl_tmem_op {
     uint32_t cmd;       /* IN: XEN_SYSCTL_TMEM_OP_* . */
     int32_t pool_id;    /* IN: 0 by default unless _SAVE_*, RESTORE_* .*/
diff --git a/xen/include/public/tmem.h b/xen/include/public/tmem.h
index 913566a..2d805fb 100644
--- a/xen/include/public/tmem.h
+++ b/xen/include/public/tmem.h
@@ -109,12 +109,6 @@ struct tmem_op {
 };
 typedef struct tmem_op tmem_op_t;
 DEFINE_XEN_GUEST_HANDLE(tmem_op_t);
-
-struct tmem_handle {
-    uint32_t pool_id;
-    uint32_t index;
-    uint64_t oid[3];
-};
 #endif
 
 #endif /* __XEN_PUBLIC_TMEM_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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