Check for KVM_API_VERSION at init

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
Pekka Enberg
2015-06-01 16:39:38 +01:00
committed by Will Deacon
parent b8f6afcd5e
commit 6c7d85141b
+6 -1
View File
@@ -1,5 +1,6 @@
#include "kvm/cpu.h"
#include <linux/kvm.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -23,12 +24,16 @@ static struct cpu *cpu__new(void)
int main(int argc, char *argv[])
{
struct cpu *cpu;
int fd;
int fd, ret;
fd = open("/dev/kvm", O_RDWR);
if (fd < 0)
die("open");
ret = ioctl(fd, KVM_GET_API_VERSION, 0);
if (ret != KVM_API_VERSION)
die("ioctl");
cpu = cpu__new();
cpu__reset(cpu);