commands-common.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifdef FIFREEZE
  17. #define CONFIG_FSFREEZE
  18. #endif
  19. #ifdef FITRIM
  20. #define CONFIG_FSTRIM
  21. #endif
  22. #endif /* __linux__ */
  23. #ifdef __FreeBSD__
  24. #include <ufs/ffs/fs.h>
  25. #ifdef UFSSUSPEND
  26. #define CONFIG_FSFREEZE
  27. #endif
  28. #endif /* __FreeBSD__ */
  29. #if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM)
  30. typedef struct FsMount {
  31. char *dirname;
  32. char *devtype;
  33. unsigned int devmajor, devminor;
  34. #if defined(__FreeBSD__)
  35. dev_t dev;
  36. fsid_t fsid;
  37. #endif
  38. QTAILQ_ENTRY(FsMount) next;
  39. } FsMount;
  40. typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;
  41. bool build_fs_mount_list(FsMountList *mounts, Error **errp);
  42. void free_fs_mount_list(FsMountList *mounts);
  43. #endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */
  44. #if defined(CONFIG_FSFREEZE)
  45. int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints,
  46. strList *mountpoints,
  47. FsMountList mounts,
  48. Error **errp);
  49. int qmp_guest_fsfreeze_do_thaw(Error **errp);
  50. #endif /* CONFIG_FSFREEZE */
  51. #ifdef HAVE_GETIFADDRS
  52. #include <ifaddrs.h>
  53. bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned char *buf,
  54. bool *obtained, Error **errp);
  55. #endif
  56. typedef struct GuestFileHandle GuestFileHandle;
  57. GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp);
  58. GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh,
  59. int64_t count, Error **errp);
  60. /**
  61. * qga_get_host_name:
  62. * @errp: Error object
  63. *
  64. * Operating system agnostic way of querying host name.
  65. * Compared to g_get_host_name(), it doesn't cache the result.
  66. *
  67. * Returns allocated hostname (caller should free), NULL on failure.
  68. */
  69. char *qga_get_host_name(Error **errp);
  70. #endif