Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


keyed stream interface fixes
[palacios.git] / palacios / src / palacios / vmm_chkpt_stores.h
1 /*
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2011, Jack Lange <jacklange@cs.pitt.edu> 
11  * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jacklange@cs.pitt.edu> 
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #ifndef __VMM_CHKPT_STORES_H__
21 #define __VMM_CHKPT_STORES_H__
22
23 //#include <palacios/vmm_types.h>
24
25 /*
26  * This is a place holder to ensure that the _v3_extensions section gets created by gcc
27  */
28 static struct {} null_store __attribute__((__used__))                   \
29     __attribute__((unused, __section__ ("_v3_chkpt_stores"),            \
30                    aligned(sizeof(addr_t))));
31
32
33 #define register_chkpt_store(store)                                     \
34     static struct chkpt_interface * _v3_store_##store                   \
35     __attribute__((used))                                               \
36         __attribute__((unused, __section__("_v3_chkpt_stores"),         \
37                        aligned(sizeof(addr_t))))                        \
38         = &store;
39
40
41
42
43 #ifdef V3_CONFIG_KEYED_STREAMS
44 #include <interfaces/vmm_keyed_stream.h>
45
46 static void * keyed_stream_open_chkpt(char * url, chkpt_mode_t mode) {
47     if (mode == SAVE) {
48         return v3_keyed_stream_open(url, V3_KS_WR_ONLY_CREATE);
49     } else if (mode == LOAD) {
50         return v3_keyed_stream_open(url, V3_KS_RD_ONLY);
51     }
52
53     // Shouldn't get here
54     return NULL;
55 }
56
57
58
59 static int keyed_stream_close_chkpt(void * store_data) {
60     v3_keyed_stream_t stream = store_data;
61
62     v3_keyed_stream_close(stream);
63
64     return 0;
65 }
66
67 static void * keyed_stream_open_ctx(void * store_data, 
68                                     void * parent_ctx, 
69                                     char * name) {
70     v3_keyed_stream_t stream = store_data;
71
72     return v3_keyed_stream_open_key(stream, name);
73 }
74
75 static int keyed_stream_close_ctx(void * store_data, void * ctx) {
76     v3_keyed_stream_t stream = store_data;
77
78     v3_keyed_stream_close_key(stream, ctx);
79
80     return 0;
81 }
82
83 static int keyed_stream_save(void * store_data, void * ctx, 
84                                   char * tag, uint64_t len, void * buf) {
85     return v3_keyed_stream_write_key(store_data, ctx, buf, len);
86 }
87
88 static int keyed_stream_load(void * store_data, void * ctx, 
89                                   char * tag, uint64_t len, void * buf) {
90     return v3_keyed_stream_read_key(store_data, ctx, buf, len);
91 }
92
93
94 static struct chkpt_interface keyed_stream_store = {
95     .name = "KEYED_STREAM",
96     .open_chkpt = keyed_stream_open_chkpt,
97     .close_chkpt = keyed_stream_close_chkpt,
98     .open_ctx = keyed_stream_open_ctx, 
99     .close_ctx = keyed_stream_close_ctx,
100     .save = keyed_stream_save,
101     .load = keyed_stream_load
102 };
103
104 register_chkpt_store(keyed_stream_store);
105
106
107
108 #endif
109
110
111
112
113
114
115 #endif