Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
#include "kvm/cpu.h"
#include <linux/kvm.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <fcntl.h>
int vmfd;
};
+static inline bool kvm__supports_extension(struct kvm *self, unsigned int extension)
+{
+ int ret;
+
+ ret = ioctl(self->fd, KVM_CHECK_EXTENSION, extension);
+ if (ret < 0)
+ return false;
+
+ return ret;
+}
+
static void die(const char *s)
{
perror(s);
if (kvm.vmfd < 0)
die("open");
+ if (!kvm__supports_extension(&kvm, KVM_CAP_USER_MEMORY))
+ die("KVM_CAP_USER_MEMORY");
+
cpu = cpu__new();
cpu__reset(cpu);