Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Addition of basic multiboot functionality plus refactor of HVM
[palacios.git] / linux_usr / v3_free.c
index 1aa4d7a..293befa 100644 (file)
@@ -3,50 +3,33 @@
  * (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;
+    char *idx;
     int ret;
 
+    if (argc <= 1) 
+       v3_usage("<vm-dev-idx>|<vm-dev>\n");
 
-    if (argc <= 1) {
-       printf("usage: v3_free <vm-dev-idx>\n");
-       return -1;
+    if (!(idx=strstr(argv[1],"v3-vm"))) { 
+       idx=argv[1];
+    } else {
+        idx+=5;
     }
 
-
-    vm_idx = strtol(argv[1], NULL, 0);
+    vm_idx = strtol(idx, NULL, 0);
 
     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;
-    }
-
-    ret = ioctl(vm_fd, V3_FREE_GUEST, vm_idx); 
-    if (ret < 0) {
-        printf("Error freeing VM %d\n", vm_idx);
+    if (v3_dev_ioctl(V3_FREE_GUEST, vm_idx) < 0) {
+        fprintf(stderr, "Error freeing VM %d (%s)\n", vm_idx,argv[1]);
         return -1;
     }
 
-    /* Close the file descriptor.  */ 
-    close(vm_fd); 
-
     return 0; 
 }