qemu-oe-bridge-helper.c 705 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright 2022 Garmin Ltd. or its subsidiaries
  3. *
  4. * SPDX-License-Identifier: GPL-2.0
  5. *
  6. * Attempts to find and exec the host qemu-bridge-helper program
  7. */
  8. #include <stdio.h>
  9. #include <unistd.h>
  10. #include <stdlib.h>
  11. void try_program(char const* path, char** args) {
  12. if (access(path, X_OK) == 0) {
  13. execv(path, args);
  14. }
  15. }
  16. int main(int argc, char** argv) {
  17. char* var;
  18. var = getenv("QEMU_BRIDGE_HELPER");
  19. if (var && var[0] != '\0') {
  20. execvp(var, argv);
  21. return 1;
  22. }
  23. try_program("/usr/libexec/qemu-bridge-helper", argv);
  24. try_program("/usr/lib/qemu/qemu-bridge-helper", argv);
  25. fprintf(stderr, "No bridge helper found\n");
  26. return 1;
  27. }