From: Peter Dinda Date: Fri, 16 Sep 2011 23:07:53 +0000 (-0500) Subject: Merge branch 'devel' of palacios@newskysaw.cs.northwestern.edu:/home/palacios/palacio... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=a78284b06acb02600e70abe4bb5288b8c2fbf253;hp=0429591d3bfd490a04e467e97b4490977fb54581 Merge branch 'devel' of palacios@newskysaw.cs.northwestern.edu:/home/palacios/palacios into devel --- diff --git a/linux_module/main.c b/linux_module/main.c index 621ab58..a6787ce 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -34,37 +34,22 @@ int mod_frees = 0; static int v3_major_num = 0; -static u8 v3_minor_map[MAX_VMS / 8] = {[0 ... (MAX_VMS / 8) - 1] = 0}; - +static struct v3_guest * guest_map[MAX_VMS] = {[0 ... MAX_VMS - 1] = 0}; struct class * v3_class = NULL; static struct cdev ctrl_dev; -static int register_vm( void ) { - int i, j = 0; - int avail = 0; - - for (i = 0; i < sizeof(v3_minor_map); i++) { - if (v3_minor_map[i] != 0xff) { - for (j = 0; j < 8; j++) { - if (!(v3_minor_map[i] & (0x1 << j))) { - avail = 1; - v3_minor_map[i] |= (0x1 << j); - break; - } - } - - if (avail == 1) { - break; - } +static int register_vm(struct v3_guest * guest) { + int i = 0; + + for (i = 0; i < MAX_VMS; i++) { + if (guest_map[i] == NULL) { + guest_map[i] = guest; + return i; } } - if (avail == 0) { - return -1; - } - - return (i * 8) + j; + return -1; } @@ -88,9 +73,9 @@ static long v3_dev_ioctl(struct file * filp, memset(guest, 0, sizeof(struct v3_guest)); - printk("Starting V3 Guest...\n"); + printk("Starting V3 Guest... (%p)\n", guest); - vm_minor = register_vm(); + vm_minor = register_vm(guest); if (vm_minor == -1) { printk("Too many VMs are currently running\n"); @@ -153,6 +138,23 @@ static long v3_dev_ioctl(struct file * filp, return guest->vm_dev; break; } + case V3_STOP_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; + } + + stop_palacios_vm(guest); + guest_map[vm_idx] = NULL; + break; + } case V3_ADD_MEMORY: { struct v3_mem_region mem; diff --git a/linux_module/palacios.h b/linux_module/palacios.h index 3a253ee..cece080 100644 --- a/linux_module/palacios.h +++ b/linux_module/palacios.h @@ -9,12 +9,13 @@ /* Global Control IOCTLs */ #define V3_START_GUEST 10 +#define V3_STOP_GUEST 11 #define V3_ADD_MEMORY 50 /* VM Specific IOCTLs */ #define V3_VM_CONSOLE_CONNECT 20 -#define V3_VM_STOP 22 + #define V3_VM_PAUSE 23 #define V3_VM_CONTINUE 24 diff --git a/linux_module/vm.c b/linux_module/vm.c index f53a598..1e37587 100644 --- a/linux_module/vm.c +++ b/linux_module/vm.c @@ -127,12 +127,6 @@ static long v3_vm_ioctl(struct file * filp, printk("V3 IOCTL %d\n", ioctl); switch (ioctl) { - - case V3_VM_STOP: { - printk("Stopping VM (%s)\n", guest->name); - stop_palacios_vm(guest); - break; - } case V3_VM_PAUSE: { printk("Pausing VM (%s)\n", guest->name); v3_pause_vm(guest->v3_ctx); @@ -280,12 +274,13 @@ int start_palacios_vm(void * arg) { int stop_palacios_vm(struct v3_guest * guest) { + v3_stop_vm(guest->v3_ctx); wait_for_completion(&(guest->thread_done)); v3_free_vm(guest->v3_ctx); - + device_destroy(v3_class, guest->vm_dev); cdev_del(&(guest->cdev)); diff --git a/linux_usr/v3_ctrl.h b/linux_usr/v3_ctrl.h index 126330d..550ab9a 100644 --- a/linux_usr/v3_ctrl.h +++ b/linux_usr/v3_ctrl.h @@ -7,12 +7,12 @@ #define _v3_ctrl_h #define V3_START_GUEST 10 +#define V3_STOP_GUEST 11 #define V3_ADD_MEMORY 50 #define V3_START_NETWORK 60 #define V3_VM_CONSOLE_CONNECT 20 #define V3_VM_SERIAL_CONNECT 21 -#define V3_VM_STOP 22 #define V3_VM_MOVE_CORE 33 diff --git a/linux_usr/v3_stop.c b/linux_usr/v3_stop.c index b47347d..061cd28 100644 --- a/linux_usr/v3_stop.c +++ b/linux_usr/v3_stop.c @@ -18,25 +18,28 @@ int read_file(int fd, int size, unsigned char * buf); int main(int argc, char* argv[]) { - char * filename = argv[1]; int vm_fd = 0; - + unsigned long vm_idx = 0; + if (argc <= 1) { - printf("Usage: ./v3_stop \n"); + printf("Usage: ./v3_stop \n"); return -1; } + + vm_idx = atoi(argv[1]); + printf("Stopping VM\n"); - vm_fd = open(filename, O_RDONLY); + vm_fd = open("/dev/v3vee", O_RDONLY); if (vm_fd == -1) { printf("Error opening V3Vee VM device\n"); return -1; } - ioctl(vm_fd, V3_VM_STOP, NULL); + ioctl(vm_fd, V3_STOP_GUEST, vm_idx); diff --git a/palacios/src/interfaces/vmm_stream.c b/palacios/src/interfaces/vmm_stream.c index 377a545..4b391ac 100644 --- a/palacios/src/interfaces/vmm_stream.c +++ b/palacios/src/interfaces/vmm_stream.c @@ -36,7 +36,7 @@ struct v3_stream * v3_stream_open(struct v3_vm_info * vm, const char * name, V3_ASSERT(stream_hooks != NULL); V3_ASSERT(stream_hooks->open != NULL); - stream = V3_Malloc(sizeof(struct v3_stream *)); + stream = V3_Malloc(sizeof(struct v3_stream)); stream->input = input; stream->guest_stream_data = guest_stream_data; diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 18f7ee7..419b706 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -922,7 +922,7 @@ int v3_start_vmx_guest(struct guest_info * info) { if (v3_vmx_enter(info) == -1) { - addr_t host_addr; + addr_t host_addr; addr_t linear_addr = 0; info->vm_info->run_state = VM_ERROR; @@ -932,9 +932,7 @@ int v3_start_vmx_guest(struct guest_info * info) { v3_print_guest_state(info); V3_Print("VMX core %u\n", info->vcpu_id); - - linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); if (info->mem_mode == PHYSICAL_MEM) {