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.


Linux user updates for more recent distros (Ubuntu 14.04 as target)
[palacios.git] / linux_usr / v3_mem_move.c
1 /* 
2  * V3 memory movement control
3  * (c) Peter Dinda 2013
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
19 int main(int argc, char* argv[]) {
20     int vm_fd;
21     char * vm_dev = NULL;
22     struct v3_mem_move_cmd cmd; 
23
24     if (argc < 4) {
25         printf("usage: v3_mem_move <vm_device> <guest_physical_addr> <target_physical_cpu>\n\n");
26         printf("Moves the memory region into which the guest_physical_addr is mapped\n");
27         printf("to host physical memory that has highest affinity for the target_physical_cpu.\n");
28         printf("you can find the current memory mapping via /proc/v3vee/v3-guests-details\n\n");
29         printf(" guest_physical_addr  - hex address\n");
30         printf(" target_physical_cpu  - base 10 cpuid (0..numcpus-1)\n\n");
31         return -1;
32     }
33
34     vm_dev = argv[1];
35     cmd.gpa = strtoll(argv[2],0,16);
36     cmd.pcore_id = atoi(argv[3]);
37
38     printf("Migrating memory region of %p to memory with affinity for physical CPU %d\n", (void*)cmd.gpa, 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_MEM, &cmd); 
48
49     if (err < 0) {
50         printf("Error write memory migrating command to vm\n");
51         return -1;
52     }
53
54     close(vm_fd); 
55
56     return 0; 
57 }
58
59