From: Peter Dinda Date: Sat, 17 Sep 2011 00:05:30 +0000 (-0500) Subject: Merge branch 'devel' of newskysaw.cs.northwestern.edu:/home/palacios/palacios into... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=ef9b4151c09c67502de3720b8fb8f42c10edd073;hp=96c8702630006b04e8e8f762f059f5300660e612 Merge branch 'devel' of newskysaw.cs.northwestern.edu:/home/palacios/palacios into devel --- diff --git a/bios/vgabios/VGABIOS-lgpl-latest.bin b/bios/vgabios/VGABIOS-lgpl-latest.bin index dc6785d..60f9f6e 100644 Binary files a/bios/vgabios/VGABIOS-lgpl-latest.bin and b/bios/vgabios/VGABIOS-lgpl-latest.bin differ diff --git a/linux_module/iface-console.c b/linux_module/iface-console.c index ab66d5a..9eedbe5 100644 --- a/linux_module/iface-console.c +++ b/linux_module/iface-console.c @@ -140,7 +140,7 @@ console_write(struct file * filp, const char __user * buf, size_t size, loff_t * for (i = 0; i < size; i++) { - if (copy_from_user(&(event.scan_code), buf + i, 1)) { + if (copy_from_user(&(event.scan_code), buf++, 1)) { printk("Console Write fault\n"); return -EFAULT; } @@ -228,7 +228,7 @@ static int console_connect(struct v3_guest * guest, unsigned int cmd, return -1; } - cons_fd = anon_inode_getfd("v3-cons", &cons_fops, cons, O_RDWR); + cons_fd = anon_inode_getfd("v3-cons", &cons_fops, cons, 0); if (cons_fd < 0) { printk("Error creating console inode\n"); 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/devices/keyboard.c b/palacios/src/devices/keyboard.c index e974503..f8786e2 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -573,7 +573,7 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { #if KEYBOARD_DEBUG_80H -static int keyboard_write_delay(ushort_t port, void * src, uint_t length, void * priv_data) { +static int keyboard_write_delay(struct guest_info *core, ushort_t port, void * src, uint_t length, void * priv_data) { if (length == 1) { PrintDebug("keyboard: write of 0x%x to 80h\n", *((uint8_t*)src)); 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) {