If you open a key for reading, you get the read pointer set to its beginning.
You can then make repeated reads to advance the read pointer. You cannot seek.
+ Reading is done with a tag supplied, and we will match the requested tag
+ against the actual tag. If they do not match, we immediately return
+ with an error.
Writing works similarly.
void v3_keyed_stream_close_key(v3_keyed_stream_t stream, char *key);
sint64_t v3_keyed_stream_write_key(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len);
sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len);
+/* We will kill this stuff since it's now in the interface
+
#define STD_SAVE_RAW(stream,ks,x) \
do { \
if (sizeof((x)) != v3_keyed_stream_write_key((stream), (ks), &(x), sizeof((x)))) { \
#define KSTREAM_MAGIC_COOKIE 0xabcd0123
+
#define STD_SAVE_TAGGED(stream,ks,tag,size,x) \
do { \
uint32_t temp; \
#define STD_LOAD(stream,ks,x) STD_LOAD_RAW(stream,ks,x)
#endif
+*/
+
+#endif
struct v3_keyed_stream_hooks {
sint64_t (*write_key)(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len);
sint64_t (*read_key)(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len);
Select this if your host OS supports keyed streams
Palacios Checkpoint/Restore and Migration depends on this feature
-config KEYED_STREAMS_WITH_TAGS
- bool "Keyed streams will be written in verbose tagged style when std save/load macros are in use"
- default n
- depends on KEYED_STREAMS
- help
- Select this if you want the standard save and load macros
- (STD_SAVE, STD_LOAD) to write to streams in the format:
- [magic cookie][tag len][tag][data len][data] instead of the
- default format of [data]
-
config STREAM
bool "Stream support"
default n
sint64_t v3_keyed_stream_write_key(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len)
{
V3_ASSERT(keyed_stream_hooks != NULL);
V3_ASSERT(keyed_stream_hooks->write_key != NULL);
- return keyed_stream_hooks->write_key(stream,key,buf,len);
+ return keyed_stream_hooks->write_key(stream,key,tag,taglen,buf,len);
}
sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream,
v3_keyed_stream_key_t key,
+ void *tag,
+ sint64_t taglen,
void *buf,
sint64_t len)
{
V3_ASSERT(keyed_stream_hooks != NULL);
V3_ASSERT(keyed_stream_hooks->read_key != NULL);
- return keyed_stream_hooks->read_key(stream,key,buf,len);
+ return keyed_stream_hooks->read_key(stream,key,tag,taglen,buf,len);
}