X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_usr%2Fv3_free.c;h=293befa148f3e1e05f96dab2dc9dfbd65ab5c3bf;hb=d3fa9d0b82291fafc35ce9bb7e777256d78c0ecd;hp=1aa4d7ac801374036cae7decd9f5116edf8bf574;hpb=69f8e46cb46163c55b2832fe5e504d8090ec084e;p=palacios.git diff --git a/linux_usr/v3_free.c b/linux_usr/v3_free.c index 1aa4d7a..293befa 100644 --- a/linux_usr/v3_free.c +++ b/linux_usr/v3_free.c @@ -3,50 +3,33 @@ * (c) Jack lange, 2011 */ - -#include -#include -#include -#include -#include -#include -#include #include #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("|\n"); - if (argc <= 1) { - printf("usage: v3_free \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; }