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.


hooking checkpoints into vmm execution
[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
44 #include <palacios/vmm_util.h>
45
46
47 static void * debug_open_chkpt(char * url, chkpt_mode_t mode) {
48    
49     if (mode == LOAD) {
50         V3_Print("Cannot load from debug store\n");
51         return NULL;
52     }
53
54     V3_Print("Opening Checkpoint: %s\n", url);
55
56     return (void *)1;
57 }
58
59
60
61 static int debug_close_chkpt(void * store_data) {
62     V3_Print("Closing Checkpoint\n");
63     return 0;
64 }
65
66 static void * debug_open_ctx(void * store_data, 
67                              void * parent_ctx, 
68                              char * name) {
69     V3_Print("[%s]\n", name);
70     return (void *)1;
71 }
72
73 static int debug_close_ctx(void * store_data, void * ctx) {
74     V3_Print("[CLOSE]\n"); 
75     return 0;
76 }
77
78 static int debug_save(void * store_data, void * ctx, 
79                       char * tag, uint64_t len, void * buf) {
80     V3_Print("%s:\n", tag);
81
82     if (len > 100) {
83         len = 100;
84     }
85
86     v3_dump_mem(buf, len);
87     
88     return 0;
89 }
90
91 static int debug_load(void * store_data, void * ctx, 
92                                   char * tag, uint64_t len, void * buf) {
93     V3_Print("Loading not supported !!!\n");
94     return 0;
95 }
96
97
98 static struct chkpt_interface debug_store = {
99     .name = "DEBUG",
100     .open_chkpt = debug_open_chkpt,
101     .close_chkpt = debug_close_chkpt,
102     .open_ctx = debug_open_ctx, 
103     .close_ctx = debug_close_ctx,
104     .save = debug_save,
105     .load = debug_load
106 };
107
108 register_chkpt_store(debug_store);
109
110
111
112
113 #ifdef V3_CONFIG_KEYED_STREAMS
114 #include <interfaces/vmm_keyed_stream.h>
115
116 static void * keyed_stream_open_chkpt(char * url, chkpt_mode_t mode) {
117     if (mode == SAVE) {
118         return v3_keyed_stream_open(url, V3_KS_WR_ONLY_CREATE);
119     } else if (mode == LOAD) {
120         return v3_keyed_stream_open(url, V3_KS_RD_ONLY);
121     }
122
123     // Shouldn't get here
124     return NULL;
125 }
126
127
128
129 static int keyed_stream_close_chkpt(void * store_data) {
130     v3_keyed_stream_t stream = store_data;
131
132     v3_keyed_stream_close(stream);
133
134     return 0;
135 }
136
137 static void * keyed_stream_open_ctx(void * store_data, 
138                                     void * parent_ctx, 
139                                     char * name) {
140     v3_keyed_stream_t stream = store_data;
141
142     return v3_keyed_stream_open_key(stream, name);
143 }
144
145 static int keyed_stream_close_ctx(void * store_data, void * ctx) {
146     v3_keyed_stream_t stream = store_data;
147
148     v3_keyed_stream_close_key(stream, ctx);
149
150     return 0;
151 }
152
153 static int keyed_stream_save(void * store_data, void * ctx, 
154                                   char * tag, uint64_t len, void * buf) {
155     return v3_keyed_stream_write_key(store_data, ctx, buf, len);
156 }
157
158 static int keyed_stream_load(void * store_data, void * ctx, 
159                                   char * tag, uint64_t len, void * buf) {
160     return v3_keyed_stream_read_key(store_data, ctx, buf, len);
161 }
162
163
164 static struct chkpt_interface keyed_stream_store = {
165     .name = "KEYED_STREAM",
166     .open_chkpt = keyed_stream_open_chkpt,
167     .close_chkpt = keyed_stream_close_chkpt,
168     .open_ctx = keyed_stream_open_ctx, 
169     .close_ctx = keyed_stream_close_ctx,
170     .save = keyed_stream_save,
171     .load = keyed_stream_load
172 };
173
174 register_chkpt_store(keyed_stream_store);
175
176
177
178 #endif
179
180
181
182
183
184
185
186 #endif