commands-common.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * QEMU Guest Agent common/cross-platform common commands
  3. *
  4. * Copyright (c) 2020 Red Hat, Inc.
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. */
  9. #ifndef QGA_COMMANDS_COMMON_H
  10. #define QGA_COMMANDS_COMMON_H
  11. #include "qga-qapi-types.h"
  12. #include "guest-agent-core.h"
  13. #include "qemu/queue.h"
  14. #if defined(__linux__)
  15. #include <linux/fs.h>
  16. #endif /* __linux__ */
  17. #ifdef __FreeBSD__
  18. #include <ufs/ffs/fs.h>
  19. #endif /* __FreeBSD__ */
  20. #if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM)
  21. typedef struct FsMount {
  22. char *dirname;
  23. char *devtype;
  24. unsigned int devmajor, devminor;
  25. #if defined(__FreeBSD__)
  26. dev_t dev;
  27. fsid_t fsid;
  28. #endif
  29. QTAILQ_ENTRY(FsMount) next;
  30. } FsMount;
  31. typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;
  32. bool build_fs_mount_list(FsMountList *mounts, Error **errp);
  33. void free_fs_mount_list(FsMountList *mounts);
  34. #endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */
  35. #if defined(CONFIG_FSFREEZE)
  36. int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints,
  37. strList *mountpoints,
  38. FsMountList mounts,
  39. Error **errp);
  40. int qmp_guest_fsfreeze_do_thaw(Error **errp);
  41. #endif /* CONFIG_FSFREEZE */
  42. #ifdef HAVE_GETIFADDRS
  43. #include <ifaddrs.h>
  44. bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned char *buf,
  45. bool *obtained, Error **errp);
  46. #endif
  47. typedef struct GuestFileHandle GuestFileHandle;
  48. GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp);
  49. GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh,
  50. int64_t count, Error **errp);
  51. /**
  52. * qga_get_host_name:
  53. * @errp: Error object
  54. *
  55. * Operating system agnostic way of querying host name.
  56. * Compared to g_get_host_name(), it doesn't cache the result.
  57. *
  58. * Returns allocated hostname (caller should free), NULL on failure.
  59. */
  60. char *qga_get_host_name(Error **errp);
  61. #endif