mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 04:31:27 +00:00
Check for KVM_CAP_USER_MEMORY
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
committed by
Will Deacon
parent
9b1fb1c3dc
commit
2da26a59d3
@@ -1,6 +1,7 @@
|
||||
#include "kvm/cpu.h"
|
||||
|
||||
#include <linux/kvm.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -9,6 +10,17 @@ struct kvm {
|
||||
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);
|
||||
@@ -44,6 +56,9 @@ int main(int argc, char *argv[])
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user