2 * V3 Hypercall Add Utility
3 * Allows hypercalls to be added to Palacios at run-time
5 * (c) Kyle C. Hale, 2011
15 #include <sys/types.h>
16 #include <sys/ioctl.h>
18 #include "../linux_module/iface-host-hypercall.h"
20 static void usage (char * bin) {
21 fprintf(stderr, "%s /dev/v3-vm<N> add|remove <nr> [function]\n", bin);
22 fprintf(stderr, "<nr> = hypercall number\n"
23 "[function] = kernel symbol to bind to\n"
24 " (defaults to a nop if not given)\n");
27 int main (int argc, char ** argv) {
31 enum {ADD,REMOVE} task;
34 if (argc < 4 || argc>5) {
41 hd.hcall_nr = strtol(argv[3], NULL, 0);
44 if (!strcasecmp(argv[2],"add")) {
49 strcpy(hd.fn,argv[4]);
51 } else if (!strcasecmp(argv[2],"remove")) {
58 printf("%s hypercall %d (0x%x) -> '%s' on %s\n",
59 task==ADD ? "Adding" : "Removing",
60 hd.hcall_nr, hd.hcall_nr,
61 task==REMOVE ? "(unimportant)"
62 : strcmp(hd.fn,"") ? hd.fn : "(default nop)", vm_dev);
64 vm_fd = open(vm_dev, O_RDONLY);
66 perror("Cannot open VM device");
71 task==ADD ? V3_VM_HYPERCALL_ADD : V3_VM_HYPERCALL_REMOVE,
73 perror("Cannot complete task due ioctl failure");