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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
14 * Author: Jack Lange <jacklange@cs.pitt.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #ifndef __VMM_CHKPT_STORES_H__
21 #define __VMM_CHKPT_STORES_H__
23 //#include <palacios/vmm_types.h>
26 * This is a place holder to ensure that the _v3_extensions section gets created by gcc
28 static struct {} null_store __attribute__((__used__)) \
29 __attribute__((unused, __section__ ("_v3_chkpt_stores"), \
30 aligned(sizeof(addr_t))));
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)))) \
43 #ifdef V3_CONFIG_KEYED_STREAMS
44 #include <interfaces/vmm_keyed_stream.h>
46 static void * keyed_stream_open_chkpt(char * url, chkpt_mode_t mode) {
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);
59 static int keyed_stream_close_chkpt(void * store_data) {
60 v3_keyed_stream_t stream = store_data;
62 v3_keyed_stream_close(stream);
67 static void * keyed_stream_open_ctx(void * store_data,
70 v3_keyed_stream_t stream = store_data;
72 return v3_keyed_stream_open_key(stream, name);
75 static int keyed_stream_close_ctx(void * store_data, void * ctx) {
76 v3_keyed_stream_t stream = store_data;
78 v3_keyed_stream_close_key(stream, ctx);
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);
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);
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
104 register_chkpt_store(keyed_stream_store);