From: Peter Dinda Date: Thu, 7 Apr 2011 21:11:59 +0000 (-0500) Subject: Added host keyed stream support X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=bdbff6b6e5f78f5a1689f5d77814196ee2e4f6cb;p=palacios.releases.git Added host keyed stream support --- diff --git a/Kconfig b/Kconfig index 28c4b09..cd0774e 100644 --- a/Kconfig +++ b/Kconfig @@ -131,6 +131,12 @@ config FILE help Select this if your host OS supports file operatoins and you want Palacios to be able to use them. +config KEYED_STREAMS + bool "Host support for keyed streams" + default n + help + Select this if your host OS supports keyed streams + Palacios Checkpoint/Restore and Migration depends on this feature config CONSOLE bool "Host Support for VM text-mode console" diff --git a/palacios/include/palacios/vmm_keyed_stream.h b/palacios/include/palacios/vmm_keyed_stream.h new file mode 100644 index 0000000..b3de41c --- /dev/null +++ b/palacios/include/palacios/vmm_keyed_stream.h @@ -0,0 +1,109 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2011, Peter Dinda + * Copyright (c) 2011, The V3VEE Project + * All rights reserved. + * + * Author: Peter Dinda + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + +#ifndef __VMM_KEYED_STREAM_H__ +#define __VMM_KEYED_STREAM_H__ + +#include + + +/* + A keyed stream essentially supports this: + + URL => {collection of key->stream pairs} + + 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. + + Writing works similarly. + + You cannot both read and write. + +*/ + +/* A keyed stream and its components are opaque to palacios */ +typedef void * v3_keyed_stream_t; +typedef void * v3_keyed_stream_key_t; + +typedef enum {V3_KS_RD_ONLY,V3_KS_WR_ONLY,V3_KS_WR_ONLY_CREATE} v3_keyed_stream_open_t; + +#ifdef __V3VEE__ + + +v3_keyed_stream_t v3_keyed_stream_open(char *url, v3_keyed_stream_open_t open_type); +void v3_keyed_stream_close(v3_keyed_stream_t stream); +v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *key); +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 *buf, + sint64_t len); +sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream, + v3_keyed_stream_key_t key, + void *buf, + sint64_t len); + +#define STD_SAVE(stream,ks,x) \ + do { \ + if (sizeof((x)) != v3_keyed_stream_write_key((stream), (ks), &(x), sizeof((x)))) { \ + v3_keyed_stream_close_key((stream),(ks)); \ + return -1; \ + } \ + } while (0) + +#define STD_LOAD(stream,ks,x) \ + do { \ + if (sizeof((x)) != v3_keyed_stream_read_key((stream), (ks), &(x), sizeof((x)))) { \ + v3_keyed_stream_close_key((stream),(ks)); \ + return -1; \ + } \ + } while (0) +#endif + + +struct v3_keyed_stream_hooks { + // url is meaningful only to the host implementation + v3_keyed_stream_t (*open)(char *url, + v3_keyed_stream_open_t open_type); + + void (*close)(v3_keyed_stream_t stream); + + v3_keyed_stream_key_t (*open_key)(v3_keyed_stream_t stream, + char *key); + + void (*close_key)(v3_keyed_stream_t stream, + char *key); + + + sint64_t (*write_key)(v3_keyed_stream_t stream, + v3_keyed_stream_key_t key, + void *buf, + sint64_t len); + sint64_t (*read_key)(v3_keyed_stream_t stream, + v3_keyed_stream_key_t key, + void *buf, + sint64_t len); + +}; + + +extern void V3_Init_Keyed_Streams(struct v3_keyed_stream_hooks *hooks); + +#endif diff --git a/palacios/src/palacios/Makefile b/palacios/src/palacios/Makefile index c02f934..dfc16c6 100644 --- a/palacios/src/palacios/Makefile +++ b/palacios/src/palacios/Makefile @@ -71,6 +71,7 @@ obj-$(CONFIG_VNET) += vmm_vnet_core.o obj-$(CONFIG_FILE) += vmm_file.o obj-$(CONFIG_CONSOLE) += vmm_console.o vmm_stream.o obj-$(CONFIG_GRAPHICS_CONSOLE) += vmm_graphics_console.o +obj-$(CONFIG_KEYED_STREAM) += vmm_keyed_stream.o obj-$(CONFIG_SYMBIOTIC) += vmm_symbiotic.o vmm_symspy.o diff --git a/palacios/src/palacios/vmm_keyed_stream.c b/palacios/src/palacios/vmm_keyed_stream.c new file mode 100644 index 0000000..cbe2481 --- /dev/null +++ b/palacios/src/palacios/vmm_keyed_stream.c @@ -0,0 +1,96 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2011, Peter Dinda + * Copyright (c) 2011, The V3VEE Project + * All rights reserved. + * + * Author: Peter Dinda + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + +#include +#include +#include +#include +#include + +struct v3_keyed_stream_hooks * keyed_stream_hooks = 0; + +v3_keyed_stream_t v3_keyed_stream_open(char *url, v3_keyed_stream_open_t open_type) +{ + V3_ASSERT(keyed_stream_hooks != NULL); + V3_ASSERT(keyed_stream_hooks->open != NULL); + + return keyed_stream_hooks->open(url,open_type); +} + + + +void v3_keyed_stream_close(v3_keyed_stream_t stream) +{ + V3_ASSERT(keyed_stream_hooks != NULL); + V3_ASSERT(keyed_stream_hooks->close != NULL); + + return keyed_stream_hooks->close(stream); + +} + + +v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *key) +{ + V3_ASSERT(keyed_stream_hooks != NULL); + V3_ASSERT(keyed_stream_hooks->open_key != NULL); + + return keyed_stream_hooks->open_key(stream,key); +} + + +void v3_keyed_stream_close_key(v3_keyed_stream_t stream, char *key) +{ + V3_ASSERT(keyed_stream_hooks != NULL); + V3_ASSERT(keyed_stream_hooks->close_key != NULL); + + return keyed_stream_hooks->close_key(stream,key); +} + + +sint64_t v3_keyed_stream_write_key(v3_keyed_stream_t stream, + v3_keyed_stream_key_t key, + 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); +} + +sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream, + v3_keyed_stream_key_t key, + 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); +} + + + +void V3_Init_Keyed_Streams(struct v3_keyed_stream_hooks * hooks) { + keyed_stream_hooks = hooks; + PrintDebug("V3 keyed stream support inited\n"); + + return; +}