api-sample.cc 534 B

123456789101112131415161718192021222324252627282930
  1. #include "kvmxx.hh"
  2. #include "identity.hh"
  3. #include "exception.hh"
  4. #include <stdio.h>
  5. static int global = 0;
  6. static void set_global()
  7. {
  8. global = 1;
  9. }
  10. int test_main(int ac, char** av)
  11. {
  12. kvm::system system;
  13. kvm::vm vm(system);
  14. mem_map memmap(vm);
  15. identity::vm ident_vm(vm, memmap);
  16. kvm::vcpu vcpu(vm, 0);
  17. identity::vcpu thread(vcpu, set_global);
  18. vcpu.run();
  19. printf("global %d\n", global);
  20. return global == 1 ? 0 : 1;
  21. }
  22. int main(int ac, char** av)
  23. {
  24. return try_main(test_main, ac, av);
  25. }