WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-4.0-testing] hvm save: Move some inline functions i

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] hvm save: Move some inline functions into common/hvm/save.c
From: Xen patchbot-4.0-testing <patchbot@xxxxxxx>
Date: Fri, 08 Apr 2011 14:00:09 +0100
Delivery-date: Fri, 08 Apr 2011 06:03:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1302187138 -3600
# Node ID 04607fe48f184466623ad506c6cb1f8807fbfa55
# Parent  f35545142043bca259369522153d68b192892b32
hvm save: Move some inline functions into common/hvm/save.c

Signed-off-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   22523:6dda9f988ef3
xen-unstable date:        Wed Dec 15 10:15:45 2010 +0000
---


diff -r f35545142043 -r 04607fe48f18 xen/common/hvm/save.c
--- a/xen/common/hvm/save.c     Sat Apr 02 16:09:21 2011 +0100
+++ b/xen/common/hvm/save.c     Thu Apr 07 15:38:58 2011 +0100
@@ -244,6 +244,63 @@
     /* Not reached */
 }
 
+int _hvm_init_entry(struct hvm_domain_context *h,
+                    uint16_t tc, uint16_t inst, uint32_t len)
+{
+    struct hvm_save_descriptor *d 
+        = (struct hvm_save_descriptor *)&h->data[h->cur];
+    if ( h->size - h->cur < len + sizeof (*d) )
+    {
+        gdprintk(XENLOG_WARNING,
+                 "HVM save: no room for %"PRIu32" + %u bytes "
+                 "for typecode %"PRIu16"\n",
+                 len, (unsigned) sizeof (*d), tc);
+        return -1;
+    }
+    d->typecode = tc;
+    d->instance = inst;
+    d->length = len;
+    h->cur += sizeof(*d);
+    return 0;
+}
+
+void _hvm_write_entry(struct hvm_domain_context *h,
+                      void *src, uint32_t src_len)
+{
+    memcpy(&h->data[h->cur], src, src_len);
+    h->cur += src_len;
+}
+
+int _hvm_check_entry(struct hvm_domain_context *h, 
+                     uint16_t type, uint32_t len)
+{
+    struct hvm_save_descriptor *d 
+        = (struct hvm_save_descriptor *)&h->data[h->cur];
+    if ( len + sizeof (*d) > h->size - h->cur)
+    {
+        gdprintk(XENLOG_WARNING, 
+                 "HVM restore: not enough data left to read %u bytes "
+                 "for type %u\n", len, type);
+        return -1;
+    }    
+    if ( (type != d->typecode) || (len != d->length) )
+    {
+        gdprintk(XENLOG_WARNING, 
+                 "HVM restore mismatch: expected type %u length %u, "
+                 "saw type %u length %u\n", type, len, d->typecode, d->length);
+        return -1;
+    }
+    h->cur += sizeof(*d);
+    return 0;
+}
+
+void _hvm_read_entry(struct hvm_domain_context *h,
+                     void *dest, uint32_t dest_len)
+{
+    memcpy(dest, &h->data[h->cur], dest_len);
+    h->cur += dest_len;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r f35545142043 -r 04607fe48f18 xen/include/xen/hvm/save.h
--- a/xen/include/xen/hvm/save.h        Sat Apr 02 16:09:21 2011 +0100
+++ b/xen/include/xen/hvm/save.h        Thu Apr 07 15:38:58 2011 +0100
@@ -30,77 +30,39 @@
 } hvm_domain_context_t;
 
 /* Marshalling an entry: check space and fill in the header */
-static inline int _hvm_init_entry(struct hvm_domain_context *h,
-                                  uint16_t tc, uint16_t inst, uint32_t len)
-{
-    struct hvm_save_descriptor *d 
-        = (struct hvm_save_descriptor *)&h->data[h->cur];
-    if ( h->size - h->cur < len + sizeof (*d) )
-    {
-        gdprintk(XENLOG_WARNING,
-                 "HVM save: no room for %"PRIu32" + %u bytes "
-                 "for typecode %"PRIu16"\n",
-                 len, (unsigned) sizeof (*d), tc);
-        return -1;
-    }
-    d->typecode = tc;
-    d->instance = inst;
-    d->length = len;
-    h->cur += sizeof (*d);
-    return 0;
-}
+int _hvm_init_entry(struct hvm_domain_context *h,
+                    uint16_t tc, uint16_t inst, uint32_t len);
 
 /* Marshalling: copy the contents in a type-safe way */
-#define _hvm_write_entry(_x, _h, _src) do {                     \
-    *(HVM_SAVE_TYPE(_x) *)(&(_h)->data[(_h)->cur]) = *(_src);   \
-    (_h)->cur += HVM_SAVE_LENGTH(_x);                           \
-} while (0)
+void _hvm_write_entry(struct hvm_domain_context *h,
+                      void *src, uint32_t src_len);
 
 /* Marshalling: init and copy; evaluates to zero on success */
-#define hvm_save_entry(_x, _inst, _h, _src) ({          \
-    int r;                                              \
-    r = _hvm_init_entry((_h), HVM_SAVE_CODE(_x),        \
-                        (_inst), HVM_SAVE_LENGTH(_x));  \
-    if ( r == 0 )                                       \
-        _hvm_write_entry(_x, (_h), (_src));             \
+#define hvm_save_entry(_x, _inst, _h, _src) ({                  \
+    int r;                                                      \
+    r = _hvm_init_entry((_h), HVM_SAVE_CODE(_x),                \
+                        (_inst), HVM_SAVE_LENGTH(_x));          \
+    if ( r == 0 )                                               \
+        _hvm_write_entry((_h), (_src), HVM_SAVE_LENGTH(_x));    \
     r; })
 
 /* Unmarshalling: test an entry's size and typecode and record the instance */
-static inline int _hvm_check_entry(struct hvm_domain_context *h, 
-                                   uint16_t type, uint32_t len)
-{
-    struct hvm_save_descriptor *d 
-        = (struct hvm_save_descriptor *)&h->data[h->cur];
-    if ( len + sizeof (*d) > h->size - h->cur)
-    {
-        gdprintk(XENLOG_WARNING, 
-                 "HVM restore: not enough data left to read %u bytes "
-                 "for type %u\n", len, type);
-        return -1;
-    }    
-    if ( type != d->typecode || len != d->length )
-    {
-        gdprintk(XENLOG_WARNING, 
-                 "HVM restore mismatch: expected type %u length %u, "
-                 "saw type %u length %u\n", type, len, d->typecode, d->length);
-        return -1;
-    }
-    h->cur += sizeof (*d);
-    return 0;
-}
+int _hvm_check_entry(struct hvm_domain_context *h, 
+                     uint16_t type, uint32_t len);
 
 /* Unmarshalling: copy the contents in a type-safe way */
-#define _hvm_read_entry(_x, _h, _dst) do {                      \
-    *(_dst) = *(HVM_SAVE_TYPE(_x) *) (&(_h)->data[(_h)->cur]);  \
-    (_h)->cur += HVM_SAVE_LENGTH(_x);                           \
-} while (0)
+void _hvm_read_entry(struct hvm_domain_context *h,
+                     void *dest, uint32_t dest_len);
 
-/* Unmarshalling: check, then copy. Evaluates to zero on success. */
-#define hvm_load_entry(_x, _h, _dst) ({                                 \
-    int r;                                                              \
-    r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), HVM_SAVE_LENGTH(_x)); \
-    if ( r == 0 )                                                       \
-        _hvm_read_entry(_x, (_h), (_dst));                              \
+/*
+ * Unmarshalling: check, then copy. Evaluates to zero on success. This load
+ * function requires the save entry to be the same size as the dest structure.
+ */
+#define hvm_load_entry(_x, _h, _dst) ({                                    \
+    int r;                                                                 \
+    r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x), HVM_SAVE_LENGTH(_x));    \
+    if ( r == 0 )                                                          \
+        _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH(_x));                \
     r; })
 
 /* Unmarshalling: what is the instance ID of the next entry? */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] hvm save: Move some inline functions into common/hvm/save.c, Xen patchbot-4 . 0-testing <=