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.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_usr / v3_load.c
1 /* 
2  * V3 checkpoint save utility
3  */
4
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <fcntl.h> 
9 #include <sys/ioctl.h> 
10 #include <sys/stat.h> 
11 #include <sys/types.h> 
12 #include <unistd.h>
13 #include <string.h>
14 #include <fcntl.h>
15 #include <pthread.h>
16 #include <errno.h>
17 #include<linux/unistd.h>
18 #include <curses.h>
19
20
21 #include "v3_ctrl.h"
22
23
24 #define MAX_STORE_LEN 128
25 #define MAX_URL_LEN 256
26
27
28 struct v3_chkpt_info chkpt;
29
30 int main(int argc, char* argv[]) {
31     int vm_fd;
32     char * vm_dev = NULL;
33
34     if (argc < 4) {
35         printf("usage: v3_load <vm_device> <store> <url> [optionmask]\n");
36         printf(" optionmask consists of the sum of any of the following\n");
37         printf(" 0    none\n");
38         printf(" 1    skip memory\n");
39         printf(" 2    skip devices\n");
40         printf(" 4    skip cores\n");
41         printf(" 8    skip architecture-specific core state\n");
42         return -1;
43     }
44
45     vm_dev = argv[1];
46
47     if (strlen(argv[2]) >= MAX_STORE_LEN) {
48         printf("ERROR: Checkpoint store name longer than maximum size (%d)\n", MAX_STORE_LEN);
49         return -1;
50     }
51
52     strncpy(chkpt.store, argv[2], MAX_STORE_LEN);
53
54
55     if (strlen(argv[3]) >= MAX_URL_LEN) {
56         printf("ERROR: Checkpoint URL longer than maximum size (%d)\n", MAX_URL_LEN);
57         return -1;
58     }
59
60     strncpy(chkpt.url, argv[3], MAX_URL_LEN);
61
62     if (argc>4) {
63       chkpt.opts = atoll(argv[4]);
64     } else {
65       chkpt.opts = V3_CHKPT_OPT_NONE;
66     }
67
68     vm_fd = open(vm_dev, O_RDONLY);
69     if (vm_fd == -1) {
70         printf("Error opening VM device: %s\n", vm_dev);
71         return -1;
72     }
73
74     ioctl(vm_fd, V3_VM_LOAD, &chkpt); 
75
76     /* Close the file descriptor.  */ 
77     close(vm_fd);
78  
79     return 0; 
80 }
81
82