Created
February 8, 2011 22:38
-
-
Save corruptmem/817434 to your computer and use it in GitHub Desktop.
kvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/ioctl.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <linux/kvm.h> | |
#include <errno.h> | |
#include <string.h> | |
int main(int argc, char* argv[]) | |
{ | |
int kvm = open("/dev/kvm", O_RDWR); | |
int vm = ioctl(kvm, KVM_CREATE_VM, 0); | |
perror("CREATE_VM"); | |
struct kvm_userspace_memory_region mem; | |
mem.slot = 0; | |
mem.guest_phys_addr = 0x0; | |
mem.memory_size = 1024; | |
mem.userspace_addr = (long) malloc(1024); | |
ioctl(vm, KVM_SET_USER_MEMORY_REGION, mem); | |
perror("SET_USER_MEMORY_REGION"); | |
ioctl(vm, KVM_CREATE_VCPU, 0); | |
perror("CREATE_VCPU"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment