switch (ioctl) {
- case V3_START_GUEST:{
+ case V3_CREATE_GUEST:{
int vm_minor = 0;
struct v3_guest_img user_image;
struct v3_guest * guest = kmalloc(sizeof(struct v3_guest), GFP_KERNEL);
memset(guest, 0, sizeof(struct v3_guest));
- printk("Palacios: Starting V3 Guest...\n");
+ printk("Palacios: Creating V3 Guest...\n");
vm_minor = register_vm(guest);
strncpy(guest->name, user_image.name, 127);
- printk("Palacios: Launching VM\n");
-
INIT_LIST_HEAD(&(guest->exts));
- if (start_palacios_vm(guest) == -1) {
- printk("Palacios: Error starting guest\n");
+ if (create_palacios_vm(guest) == -1) {
+ printk("Palacios: Error creating guest\n");
return -EFAULT;
}
- return guest->vm_dev;
+ return vm_minor;
break;
}
- case V3_STOP_GUEST: {
+ case V3_FREE_GUEST: {
unsigned long vm_idx = arg;
struct v3_guest * guest = guest_map[vm_idx];
- printk("Stopping VM idx=%d\n", vm_idx);
- printk("Stopping VM (%s) (%p)\n", guest->name, guest);
-
-
- if (irqs_disabled()) {
- printk("WHAT!!?? IRQs are disabled??\n");
- break;
- }
+ printk("Freeing VM (%s) (%p)\n", guest->name, guest);
- stop_palacios_vm(guest);
+ free_palacios_vm(guest);
guest_map[vm_idx] = NULL;
break;
}
/* Global Control IOCTLs */
-#define V3_START_GUEST 10
-#define V3_STOP_GUEST 11
#define V3_CREATE_GUEST 12
#define V3_FREE_GUEST 13
printk("V3 IOCTL %d\n", ioctl);
switch (ioctl) {
+ case V3_VM_LAUNCH: {
+ printk("palacios: launching vm\n");
+
+ if (v3_start_vm(guest->v3_ctx, 0xfffffffe) < 0) {
+ printk("palacios: launch of vm failed\n");
+ return -1;
+ }
+
+ break;
+ }
+ case V3_VM_STOP: {
+ printk("Stopping VM (%s) (%p)\n", guest->name, guest);
+
+ if (irqs_disabled()) {
+ printk("WHAT!!?? IRQs are disabled??\n");
+ break;
+ }
+
+ v3_stop_vm(guest->v3_ctx);
+ break;
+ }
case V3_VM_PAUSE: {
printk("Pausing VM (%s)\n", guest->name);
v3_pause_vm(guest->v3_ctx);
extern u32 mallocs;
extern u32 frees;
-int start_palacios_vm(struct v3_guest * guest) {
+int create_palacios_vm(struct v3_guest * guest) {
int err;
init_vm_extensions(guest);
return -1;
}
- printk("palacios: launching vm\n");
-
- if (v3_start_vm(guest->v3_ctx, 0xffffffff) < 0) {
- printk("palacios: launch of vm failed\n");
- device_destroy(v3_class, guest->vm_dev);
- cdev_del(&(guest->cdev));
- v3_free_vm(guest->v3_ctx);
- return -1;
- }
-
- printk("palacios: vm completed. returning.\n");
+ printk("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
return 0;
}
-int stop_palacios_vm(struct v3_guest * guest) {
-
-
- v3_stop_vm(guest->v3_ctx);
+int free_palacios_vm(struct v3_guest * guest) {
v3_free_vm(guest->v3_ctx);
#include "palacios.h"
-int start_palacios_vm(struct v3_guest * guest);
-int stop_palacios_vm(struct v3_guest * guest);
+int create_palacios_vm(struct v3_guest * guest);
+int free_palacios_vm(struct v3_guest * guest);
int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd,
-v3_ctrl : v3_ctrl.c v3_pause.c v3_continue.c v3_ctrl.h
- gcc -static v3_ctrl.c -o v3_ctrl
+v3_ctrl : v3_ctrl.c v3_pause.c v3_continue.c v3_launch.c v3_stop.c v3_create.c v3_free.c
+ gcc -static v3_launch.c -o v3_launch
+ gcc -static v3_stop.c -o v3_stop
gcc -static v3_pause.c -o v3_pause
gcc -static v3_continue.c -o v3_continue
+ gcc -static v3_create.c -o v3_create
+ gcc -static v3_free.c -o v3_free
-v3_stop : v3_stop.c v3_ctrl.h
- gcc -static v3_stop.c -o v3_stop
v3_save : v3_save.c v3_ctrl.h
gcc -static v3_save.c -o v3_save
gcc -static v3_mem.c -o v3_mem
v3_cons : v3_cons.c v3_cons_sc.c v3_ctrl.h
- gcc v3_cons.c -o v3_cons -lcurses
- gcc v3_cons_sc.c -o v3_cons_sc -lcurses
+ gcc -static v3_cons.c -o v3_cons -lcurses
+ gcc -static v3_cons_sc.c -o v3_cons_sc -lcurses
v3_stream : v3_stream.c v3_ctrl.h
gcc -static v3_stream.c -o v3_stream
--- /dev/null
+/*
+ * V3 Control utility
+ * (c) Jack lange, 2010
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "v3_ctrl.h"
+
+int read_file(int fd, int size, unsigned char * buf);
+
+int main(int argc, char* argv[]) {
+ char * filename = argv[1];
+ char * name = argv[2];
+ int guest_fd = 0;
+ int v3_fd = 0;
+ struct v3_guest_img guest_img;
+ struct stat guest_stats;
+ int dev_idx = 0;
+
+ memset(&guest_img, 0, sizeof(struct v3_guest_img));
+
+ if (argc <= 2) {
+ printf("Usage: ./v3_ctrl <guest_img> <vm name>\n");
+ return -1;
+ }
+
+ printf("Launching guest: %s\n", filename);
+
+ guest_fd = open(filename, O_RDONLY);
+
+ if (guest_fd == -1) {
+ printf("Error Opening guest image: %s\n", filename);
+ return -1;
+ }
+
+ if (fstat(guest_fd, &guest_stats) == -1) {
+ printf("ERROR: Could not stat guest image file -- %s\n", filename);
+ return -1;
+ }
+
+
+ guest_img.size = guest_stats.st_size;
+
+ // load guest image into user memory
+ guest_img.guest_data = malloc(guest_img.size);
+
+ read_file(guest_fd, guest_img.size, guest_img.guest_data);
+
+ close(guest_fd);
+
+ printf("Loaded guest image. Launching to V3Vee\n");
+
+ strncpy(guest_img.name, name, 127);
+
+
+ v3_fd = open(v3_dev, O_RDONLY);
+
+ if (v3_fd == -1) {
+ printf("Error opening V3Vee control device\n");
+ return -1;
+ }
+
+ dev_idx = ioctl(v3_fd, V3_CREATE_GUEST, &guest_img);
+
+
+ if (dev_idx < 0) {
+ printf("Error (%d) creating VM\n", dev_idx);
+ return -1;
+ }
+
+ printf("VM (%s) created at /dev/v3-vm%d\n", name, dev_idx);
+
+ /* Close the file descriptor. */
+ close(v3_fd);
+
+
+
+ return 0;
+}
+
+
+
+int read_file(int fd, int size, unsigned char * buf) {
+ int left_to_read = size;
+ int have_read = 0;
+
+ while (left_to_read != 0) {
+ int bytes_read = read(fd, buf + have_read, left_to_read);
+
+ if (bytes_read <= 0) {
+ break;
+ }
+
+ have_read += bytes_read;
+ left_to_read -= bytes_read;
+ }
+
+ if (left_to_read != 0) {
+ printf("Error could not finish reading file\n");
+ return -1;
+ }
+
+ return 0;
+}
#ifndef _v3_ctrl_h
#define _v3_ctrl_h
-#define V3_START_GUEST 10
-#define V3_STOP_GUEST 11
#define V3_CREATE_GUEST 12
#define V3_FREE_GUEST 13
--- /dev/null
+/*
+ * V3 Control utility
+ * (c) Jack lange, 2011
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "v3_ctrl.h"
+
+int main(int argc, char* argv[]) {
+ int vm_fd = 0;
+ unsigned long vm_idx = 0;
+
+
+ if (argc <= 1) {
+ printf("Usage: ./v3_free <vm-dev-idx>\n");
+ return -1;
+ }
+
+
+ vm_idx = atoi(argv[1]);
+
+ printf("Freeing VM %d\n", vm_idx);
+
+ vm_fd = open("/dev/v3vee", O_RDONLY);
+
+ if (vm_fd == -1) {
+ printf("Error opening V3Vee VM device\n");
+ return -1;
+ }
+
+ ioctl(vm_fd, V3_FREE_GUEST, vm_idx);
+
+
+
+ /* Close the file descriptor. */
+ close(vm_fd);
+
+
+
+ return 0;
+}
+
+
--- /dev/null
+/*
+ * V3 Control utility
+ * (c) Jack lange, 2010
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "v3_ctrl.h"
+
+int main(int argc, char* argv[]) {
+ int vm_fd = 0;
+ char * filename = argv[1];
+
+ if (argc <= 1) {
+ printf("Usage: ./v3_launch <vm-device>\n");
+ return -1;
+ }
+
+ printf("Launching VM (%s)\n", filename);
+
+ vm_fd = open(filename, O_RDONLY);
+
+ if (vm_fd == -1) {
+ printf("Error opening V3Vee VM device\n");
+ return -1;
+ }
+
+ ioctl(vm_fd, V3_VM_LAUNCH, NULL);
+
+
+
+ /* Close the file descriptor. */
+ close(vm_fd);
+
+
+
+ return 0;
+}
+
+
#include "v3_ctrl.h"
-int read_file(int fd, int size, unsigned char * buf);
-
int main(int argc, char* argv[]) {
int vm_fd = 0;
- unsigned long vm_idx = 0;
-
+ char * filename = argv[1];
if (argc <= 1) {
- printf("Usage: ./v3_stop <vm-dev-idx>\n");
+ printf("Usage: ./v3_stop <vm-device>\n");
return -1;
}
-
- vm_idx = atoi(argv[1]);
-
- printf("Stopping VM\n");
+ printf("Stopping VM (%s)\n", filename);
- vm_fd = open("/dev/v3vee", O_RDONLY);
+ vm_fd = open(filename, O_RDONLY);
if (vm_fd == -1) {
printf("Error opening V3Vee VM device\n");
return -1;
}
- ioctl(vm_fd, V3_STOP_GUEST, vm_idx);
+ ioctl(vm_fd, V3_VM_STOP, NULL);
*/
core->pcpu_id = target_cpu;
- V3_Print("core now at %d\n", core->pcpu_id);
-
+ V3_Print("core now at %d\n", core->pcpu_id);
}
-
-
-
v3_lower_barrier(vm);
return 0;