};
+void * get_vm_ext_data(struct v3_guest * guest, char * ext_name) {
+ struct vm_ext * ext = NULL;
+
+ list_for_each_entry(ext, &(guest->exts), node) {
+ if (strncmp(ext->impl->name, ext_name, strlen(ext->impl->name)) == 0) {
+ return ext->vm_data;
+ }
+ }
+
+ return NULL;
+}
+
int init_vm_extensions(struct v3_guest * guest) {
extern struct linux_ext * __start__lnx_exts[];
if (ext_impl->guest_init == NULL) {
// We can have global extensions without per guest state
+ ext_impl = __start__lnx_exts[++i];
continue;
}
}
+
int deinit_vm_extensions(struct v3_guest * guest) {
struct vm_ext * ext = NULL;
struct vm_ext * tmp = NULL;
int init_lnx_extensions( void );
int deinit_lnx_extensions( void );
+int init_vm_extensions(struct v3_guest * guest);
+int deinit_vm_extensions(struct v3_guest * guest);
+
+void * get_vm_ext_data(struct v3_guest * guest, char * ext_name);
+
#define register_extension(ext) \
#include "palacios-mm.h"
#include "palacios-vm.h"
#include "palacios-stream.h"
-#include "palacios-file.h"
#include "palacios-serial.h"
#include "palacios-socket.h"
#include "palacios-vnet.h"
INIT_LIST_HEAD(&(guest->streams));
- INIT_LIST_HEAD(&(guest->files));
INIT_LIST_HEAD(&(guest->sockets));
#ifdef V3_CONFIG_HOST_DEVICE
INIT_LIST_HEAD(&(guest->hostdev.devs));
palacios_init_stream();
#endif
-#ifdef V3_CONFIG_FILE
- palacios_file_init();
-#endif
-
#ifdef V3_CONFIG_KEYED_STREAMS
palacios_init_keyed_streams();
#endif
class_destroy(v3_class);
+ deinit_lnx_extensions();
+
#ifdef V3_CONFIG_EXT_INSPECTOR
palacios_deinit_inspector();
#endif
-#ifdef V3_CONFIG_FILE
- palacios_file_deinit();
-#endif
#ifdef V3_CONFIG_STREAM
palacios_deinit_stream();
#include <linux/module.h>
#include "palacios.h"
+#include "linux-exts.h"
#include <interfaces/vmm_file.h>
static struct list_head global_files;
+
struct palacios_file {
struct file * filp;
};
+// Currently this just holds the list of open files
+struct vm_file_state {
+ struct list_head open_files;
+};
+
+
static void * palacios_file_open(const char * path, int mode, void * private_data) {
struct v3_guest * guest = (struct v3_guest *)private_data;
- struct palacios_file * pfile = NULL;
+ struct palacios_file * pfile = NULL;
+ struct vm_file_state * vm_state = NULL;
+
+ if (guest != NULL) {
+ vm_state = get_vm_ext_data(guest, "FILE_INTERFACE");
+
+ if (vm_state == NULL) {
+ printk("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n");
+ return NULL;
+ }
+ }
pfile = kmalloc(sizeof(struct palacios_file), GFP_KERNEL);
memset(pfile, 0, sizeof(struct palacios_file));
if (guest == NULL) {
list_add(&(pfile->file_node), &(global_files));
} else {
- list_add(&(pfile->file_node), &(guest->files));
+ list_add(&(pfile->file_node), &(vm_state->open_files));
}
};
-int palacios_file_init( void ) {
+
+static int file_init( void ) {
INIT_LIST_HEAD(&(global_files));
V3_Init_File(&palacios_file_hooks);
}
-int palacios_file_deinit( void ) {
+static int file_deinit( void ) {
if (!list_empty(&(global_files))) {
printk("Error removing module with open files\n");
}
return 0;
}
+
+static int guest_file_init(struct v3_guest * guest, void ** vm_data) {
+ struct vm_file_state * state = kmalloc(sizeof(struct vm_file_state), GFP_KERNEL);
+
+ INIT_LIST_HEAD(&(state->open_files));
+
+ *vm_data = state;
+
+ return 0;
+}
+
+
+static int guest_file_deinit(struct v3_guest * guest, void * vm_data) {
+
+ return 0;
+}
+
+
+static struct linux_ext file_ext = {
+ .name = "FILE_INTERFACE",
+ .init = file_init,
+ .deinit = file_deinit,
+ .guest_init = guest_file_init,
+ .guest_deinit = guest_file_deinit
+};
+
+
+register_extension(&file_ext);
+++ /dev/null
-#ifndef __PALACIOS_FILE_H__
-#define __PALACISO_FILE_H__
-
-int palacios_file_init(void);
-int palacios_file_deinit(void);
-
-#endif
#include "palacios.h"
#include "palacios-vm.h"
+#include "linux-exts.h"
struct vm_ctrl {
// allow_signal(SIGKILL);
unlock_kernel();
+ init_vm_extensions(guest);
guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name);
struct rb_root vm_ctrls;
struct list_head exts;
- struct list_head files;
struct list_head streams;
struct list_head sockets;