Also check these ioctls
authorLauri Kasanen <cand@gmx.com>
Thu, 27 May 2021 15:34:00 +0000 (18:34 +0300)
committerLauri Kasanen <cand@gmx.com>
Thu, 27 May 2021 15:34:00 +0000 (18:34 +0300)
main.c

diff --git a/main.c b/main.c
index cf98fe3dbfbedc20e4861db2449a227605cec57f..f4e8b586a28c8c41cc85abe016f9a7b5fb330e56 100644 (file)
--- a/main.c
+++ b/main.c
@@ -365,14 +365,16 @@ int main(int argc, char **argv) {
                .userspace_addr = (uint64_t) ram,
                .flags = 0
        };
-       ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &region);
+       if (ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &region) == -1)
+               abort();
 
        region.slot = 1;
        region.guest_phys_addr = PROGSTART;
        region.memory_size = binlen;
        region.userspace_addr = (uint64_t) progmem;
        region.flags = KVM_MEM_READONLY;
-       ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &region);
+       if (ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &region) == -1)
+               abort();
 
        vcpu = ioctl(vmfd, KVM_CREATE_VCPU, (unsigned long)0);
        const unsigned vcpulen = ioctl(kvm, KVM_GET_VCPU_MMAP_SIZE, NULL);