From: Peter Dinda Date: Wed, 26 Dec 2012 17:07:44 +0000 (-0600) Subject: New keyed stream interface X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=313214f2f4c8cf8d4bb4e2e3aaa788101d955fce;p=palacios.git New keyed stream interface --- diff --git a/palacios/include/interfaces/vmm_keyed_stream.h b/palacios/include/interfaces/vmm_keyed_stream.h index d9a9eea..1328e4f 100644 --- a/palacios/include/interfaces/vmm_keyed_stream.h +++ b/palacios/include/interfaces/vmm_keyed_stream.h @@ -31,6 +31,9 @@ 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. @@ -54,15 +57,21 @@ v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *k 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)))) { \ @@ -82,6 +91,7 @@ sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream, #define KSTREAM_MAGIC_COOKIE 0xabcd0123 + #define STD_SAVE_TAGGED(stream,ks,tag,size,x) \ do { \ uint32_t temp; \ @@ -162,6 +172,9 @@ if ((size) != v3_keyed_stream_read_key((stream),(ks),&(x),(size))) { \ #define STD_LOAD(stream,ks,x) STD_LOAD_RAW(stream,ks,x) #endif +*/ + +#endif struct v3_keyed_stream_hooks { @@ -184,11 +197,15 @@ 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); diff --git a/palacios/src/interfaces/Kconfig b/palacios/src/interfaces/Kconfig index 6553f40..5f86790 100644 --- a/palacios/src/interfaces/Kconfig +++ b/palacios/src/interfaces/Kconfig @@ -13,16 +13,6 @@ config KEYED_STREAMS 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 diff --git a/palacios/src/interfaces/vmm_keyed_stream.c b/palacios/src/interfaces/vmm_keyed_stream.c index 79d69ac..45d8d20 100644 --- a/palacios/src/interfaces/vmm_keyed_stream.c +++ b/palacios/src/interfaces/vmm_keyed_stream.c @@ -74,24 +74,28 @@ void v3_keyed_stream_close_key(v3_keyed_stream_t stream, char 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); }