1
0

plugin_extensions.c 1.3 KB

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