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.


d7439d8f7aec00d57e35b2c5890a9f27fbb64792
[palacios.git] / linux_usr / v3_core_move.c
1 /* 
2  * V3 Virtual Core Migrate Control
3  * (c) Lei Xia, 2011
4  */
5
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/ioctl.h> 
10 #include <errno.h>
11 #include <assert.h>
12 #include <string.h>
13 #include <fcntl.h>
14 #include <unistd.h>
15
16 #include "v3_ctrl.h"
17
18 struct v3_core_move_cmd {
19     unsigned short vcore_id;
20     unsigned short pcore_id;
21 };
22
23
24 int main(int argc, char* argv[]) {
25     int vm_fd;
26     char * vm_dev = NULL;
27     struct v3_core_move_cmd cmd; 
28
29     if (argc < 4) {
30         printf("Usage: v3_core_migrate <vm_device> <vcore id> <target physical CPU id>\n");
31         return -1;
32     }
33
34     vm_dev = argv[1];
35     cmd.vcore_id = atoi(argv[2]);
36     cmd.pcore_id = atoi(argv[3]);
37
38     printf("Migrate vcore %d to physical CPU %d\n", cmd.vcore_id, cmd.pcore_id);
39
40     vm_fd = open(vm_dev, O_RDONLY);
41
42     if (vm_fd == -1) {
43         printf("Error opening VM device: %s\n", vm_dev);
44         return -1;
45     }
46
47     int err = ioctl(vm_fd, V3_VM_MOVE_CORE, &cmd); 
48
49     if (err < 0) {
50         printf("Error write core migrating command to vm\n");
51         return -1;
52     }
53
54     close(vm_fd); 
55
56     return 0; 
57 }
58
59