X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_usr%2Fv3_free.c;h=c7393d1ea82ac000e29384bc206c56d4b65cb497;hb=68f8c4cd303c5da40c1083cbabdaf6395e4dbaa1;hp=8e3c41f33ebe380dd8c4e5d4e20a0ea11f66fb72;hpb=0b342d28c860e4b3911b529f5363d35faa86aa25;p=palacios.git diff --git a/linux_usr/v3_free.c b/linux_usr/v3_free.c index 8e3c41f..c7393d1 100644 --- a/linux_usr/v3_free.c +++ b/linux_usr/v3_free.c @@ -3,49 +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(idx, NULL, 0); - vm_idx = atoi(argv[1]); - - printf("Freeing VM %d\n", vm_idx); + printf("Freeing VM %lu\n", vm_idx); - vm_fd = open("/dev/v3vee", O_RDONLY); - - if (vm_fd == -1) { - printf("Error opening V3Vee VM device\n"); - return -1; + if (v3_dev_ioctl(V3_FREE_GUEST, (void*)vm_idx) < 0) { + fprintf(stderr, "Error freeing VM %lu (%s)\n", vm_idx,argv[1]); + return -1; } - ioctl(vm_fd, V3_FREE_GUEST, vm_idx); - - - - /* Close the file descriptor. */ - close(vm_fd); - - - return 0; }