• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <linux/memfd.h>
10 #include <pthread.h>
11 #include <stdint.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <sys/mman.h>
16 #include <sys/syscall.h>
17 #include <time.h>
18 #include <unistd.h>
19 
20 #include "crosvm.h"
21 
main(int argc,char ** argv)22 int main(int argc, char** argv) {
23     struct crosvm *crosvm;
24     int ret = crosvm_connect(&crosvm);
25     if (ret) {
26         fprintf(stderr, "failed to connect to crosvm: %d\n", ret);
27         return 1;
28     }
29 
30     bool supported;
31     ret = crosvm_check_extension(crosvm, KVM_CAP_IRQCHIP, &supported);
32     if (ret) {
33         fprintf(stderr, "failed to check for KVM extension: %d\n", ret);
34         return 1;
35     }
36     if (!supported) {
37         fprintf(stderr, "expected KVM extension to be supported\n");
38         return 1;
39     }
40 
41     // Assume s390 extensions aren't supported because we shouldn't be running on one.
42     ret = crosvm_check_extension(crosvm, KVM_CAP_S390_PSW, &supported);
43     if (ret) {
44         fprintf(stderr, "failed to check for KVM extension: %d\n", ret);
45         return 1;
46     }
47     if (supported) {
48         fprintf(stderr, "unexpected KVM extension is supported\n");
49         return 1;
50     }
51 
52     return 0;
53 }
54