summary refs log tree commit diff
path: root/tests/plugin_extensions.c
blob: 4e3ea87624ce02cac69f39edac0dbce9709656ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright 2018 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <errno.h>
#include <fcntl.h>
#include <linux/memfd.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>

#include "crosvm.h"

int main(int argc, char** argv) {
    struct crosvm *crosvm;
    int ret = crosvm_connect(&crosvm);
    if (ret) {
        fprintf(stderr, "failed to connect to crosvm: %d\n", ret);
        return 1;
    }

    bool supported;
    ret = crosvm_check_extension(crosvm, KVM_CAP_IRQCHIP, &supported);
    if (ret) {
        fprintf(stderr, "failed to check for KVM extension: %d\n", ret);
        return 1;
    }
    if (!supported) {
        fprintf(stderr, "expected KVM extension to be supported\n");
        return 1;
    }

    // Assume s390 extensions aren't supported because we shouldn't be running on one.
    ret = crosvm_check_extension(crosvm, KVM_CAP_S390_PSW, &supported);
    if (ret) {
        fprintf(stderr, "failed to check for KVM extension: %d\n", ret);
        return 1;
    }
    if (supported) {
        fprintf(stderr, "unexpected KVM extension is supported\n");
        return 1;
    }

    return 0;
}