X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fpalacios-vm.c;h=dd422c318df999e0b5d39b9b43ff044ed4a85e4e;hb=e595e6c854a5414edc0cd8c8b38545e78c19e549;hp=cd3ba2c23e622fb76db87ea7011d23a8878c80f2;hpb=260bb3e805ebc92ae294c3c2b36d027ba8bca488;p=palacios.git diff --git a/linux_module/palacios-vm.c b/linux_module/palacios-vm.c index cd3ba2c..dd422c3 100644 --- a/linux_module/palacios-vm.c +++ b/linux_module/palacios-vm.c @@ -21,17 +21,33 @@ #include #include "palacios.h" -#include "palacios-console.h" -#include "palacios-serial.h" #include "palacios-vm.h" +#ifdef V3_CONFIG_STREAM +#include "palacios-stream.h" +#endif + +#ifdef V3_CONFIG_CONSOLE +#include "palacios-console.h" +#endif + +#ifdef V3_CONFIG_EXT_INSPECTOR +#include "palacios-inspector.h" +#endif + +#ifdef V3_CONFIG_GRAPHICS_CONSOLE +#include "palacios-graphics-console.h" +#endif + +#ifdef V3_CONFIG_HOST_DEVICE +#include "palacios-host-dev.h" +#endif + extern struct class * v3_class; #define STREAM_NAME_LEN 128 static long v3_vm_ioctl(struct file * filp, unsigned int ioctl, unsigned long arg) { - void __user * argp = (void __user *)arg; - char path_name[STREAM_NAME_LEN]; struct v3_guest * guest = filp->private_data; @@ -39,24 +55,74 @@ static long v3_vm_ioctl(struct file * filp, switch (ioctl) { + case V3_VM_STOP: { + printk("Stopping VM\n"); + stop_palacios_vm(guest); + break; + } + case V3_VM_CONSOLE_CONNECT: { +#ifdef V3_CONFIG_CONSOLE return connect_console(guest); +#else + printk("Console support not available\n"); + return -EFAULT; +#endif break; } - case V3_VM_SERIAL_CONNECT: { + + case V3_VM_STREAM_CONNECT: { +#ifdef V3_CONFIG_STREAM + void __user * argp = (void __user *)arg; + char path_name[STREAM_NAME_LEN]; + if (copy_from_user(path_name, argp, STREAM_NAME_LEN)) { - printk("copy from user error getting guest image...\n"); + printk("%s(%d): copy from user error...\n", __FILE__, __LINE__); return -EFAULT; } - return open_serial(path_name); + return open_stream(path_name); +#else + printk("Stream support Not available\n"); + return -EFAULT; +#endif break; } - case V3_VM_STOP: { - printk("Stopping VM\n"); - stop_palacios_vm(guest); + + case V3_VM_HOST_DEV_CONNECT: { +#ifdef V3_CONFIG_HOST_DEV + if (copy_from_user(host_dev_url, argp, HOST_DEV_URL_LEN)) { + printk("copy from user error getting url for host device connect...\n"); + return -EFAULT; + } + + return connect_host_dev(guest,host_dev_url); +#else + printk("palacios: Host device support not available\n"); + return -EFAULT; +#endif break; } + + case V3_VM_FB_INPUT: +#ifdef V3_CONFIG_GRAPHICS_CONSOLE + return palacios_graphics_console_user_input(&(guest->graphics_console), + (struct v3_fb_input __user *) arg) ; +#else + return -EFAULT; +#endif + break; + + case V3_VM_FB_QUERY: +#ifdef V3_CONFIG_GRAPHICS_CONSOLE + return palacios_graphics_console_user_query(&(guest->graphics_console), + (struct v3_fb_query_response __user *) arg); +#else + return -EFAULT; +#endif + break; + + default: printk("\tUnhandled\n"); return -EINVAL; @@ -79,7 +145,6 @@ static ssize_t v3_vm_read(struct file * filp, char __user * buf, size_t size, lo static ssize_t v3_vm_write(struct file * filp, const char __user * buf, size_t size, loff_t * offset) { - return 0; } @@ -95,36 +160,33 @@ static struct file_operations v3_vm_fops = { }; - extern int vm_running; extern u32 pg_allocs; extern u32 pg_frees; extern u32 mallocs; extern u32 frees; - int start_palacios_vm(void * arg) { struct v3_guest * guest = (struct v3_guest *)arg; int err; lock_kernel(); daemonize(guest->name); -// allow_signal(SIGKILL); + // allow_signal(SIGKILL); unlock_kernel(); - - guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name); if (guest->v3_ctx == NULL) { printk("palacios: failed to create vm\n"); + complete(&(guest->start_done)); return -1; } printk("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev)); - cdev_init(&(guest->cdev), &v3_vm_fops); + cdev_init(&(guest->cdev), &v3_vm_fops); guest->cdev.owner = THIS_MODULE; guest->cdev.ops = &v3_vm_fops; @@ -135,27 +197,39 @@ int start_palacios_vm(void * arg) { if (err) { printk("Fails to add cdev\n"); + v3_free_vm(guest->v3_ctx); + complete(&(guest->start_done)); return -1; } if (device_create(v3_class, NULL, guest->vm_dev, guest, "v3-vm%d", MINOR(guest->vm_dev)) == NULL){ printk("Fails to create device\n"); + cdev_del(&(guest->cdev)); + v3_free_vm(guest->v3_ctx); + complete(&(guest->start_done)); return -1; } - complete(&(guest->thread_done)); + complete(&(guest->start_done)); + + printk("palacios: launching vm\n"); - printk("palacios: launching vm\n"); +#ifdef V3_CONFIG_EXT_INSPECTOR + inspect_vm(guest); +#endif + 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; - } + } complete(&(guest->thread_done)); - printk("palacios: vm completed. returning.\n"); return 0; @@ -165,13 +239,19 @@ 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)); + + kfree(guest->img); + kfree(guest); return 0; }