libqos.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef LIBQOS_H
  2. #define LIBQOS_H
  3. #include "../libqtest.h"
  4. #include "pci.h"
  5. #include "malloc.h"
  6. typedef struct QOSState QOSState;
  7. typedef struct QOSOps {
  8. void (*alloc_init)(QGuestAllocator *, QTestState *, QAllocOpts);
  9. QPCIBus *(*qpci_new)(QTestState *qts, QGuestAllocator *alloc);
  10. void (*qpci_free)(QPCIBus *bus);
  11. void (*shutdown)(QOSState *);
  12. } QOSOps;
  13. struct QOSState {
  14. QTestState *qts;
  15. QGuestAllocator alloc;
  16. QPCIBus *pcibus;
  17. QOSOps *ops;
  18. };
  19. QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
  20. QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
  21. void qtest_common_shutdown(QOSState *qs);
  22. void qtest_shutdown(QOSState *qs);
  23. bool have_qemu_img(void);
  24. void mkimg(const char *file, const char *fmt, unsigned size_mb);
  25. void mkqcow2(const char *file, unsigned size_mb);
  26. void migrate(QOSState *from, QOSState *to, const char *uri);
  27. void prepare_blkdebug_script(const char *debug_fn, const char *event);
  28. void generate_pattern(void *buffer, size_t len, size_t cycle_len);
  29. static inline uint64_t qmalloc(QOSState *q, size_t bytes)
  30. {
  31. return guest_alloc(&q->alloc, bytes);
  32. }
  33. static inline void qfree(QOSState *q, uint64_t addr)
  34. {
  35. guest_free(&q->alloc, addr);
  36. }
  37. #endif