Philippe Mathieu-Daudé | 5d3586b | 2020-04-14 15:30:42 +0200 | [diff] [blame] | 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 | |
| 12 | #include "qga-qapi-types.h" |
Alexander Ivanov | 518b0d8 | 2022-10-17 09:28:20 +0200 | [diff] [blame] | 13 | #include "guest-agent-core.h" |
| 14 | #include "qemu/queue.h" |
| 15 | |
| 16 | #if defined(__linux__) |
| 17 | #include <linux/fs.h> |
Alexander Ivanov | 518b0d8 | 2022-10-17 09:28:20 +0200 | [diff] [blame] | 18 | #endif /* __linux__ */ |
| 19 | |
Alexander Ivanov | bad0001 | 2022-10-17 09:28:21 +0200 | [diff] [blame] | 20 | #ifdef __FreeBSD__ |
| 21 | #include <ufs/ffs/fs.h> |
Alexander Ivanov | bad0001 | 2022-10-17 09:28:21 +0200 | [diff] [blame] | 22 | #endif /* __FreeBSD__ */ |
| 23 | |
Alexander Ivanov | 518b0d8 | 2022-10-17 09:28:20 +0200 | [diff] [blame] | 24 | #if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) |
| 25 | typedef struct FsMount { |
| 26 | char *dirname; |
| 27 | char *devtype; |
| 28 | unsigned int devmajor, devminor; |
Alexander Ivanov | bad0001 | 2022-10-17 09:28:21 +0200 | [diff] [blame] | 29 | #if defined(__FreeBSD__) |
| 30 | dev_t dev; |
| 31 | fsid_t fsid; |
| 32 | #endif |
Alexander Ivanov | 518b0d8 | 2022-10-17 09:28:20 +0200 | [diff] [blame] | 33 | QTAILQ_ENTRY(FsMount) next; |
| 34 | } FsMount; |
| 35 | |
| 36 | typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; |
| 37 | |
| 38 | bool build_fs_mount_list(FsMountList *mounts, Error **errp); |
| 39 | void free_fs_mount_list(FsMountList *mounts); |
| 40 | #endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */ |
| 41 | |
| 42 | #if defined(CONFIG_FSFREEZE) |
| 43 | int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints, |
| 44 | strList *mountpoints, |
| 45 | FsMountList mounts, |
| 46 | Error **errp); |
| 47 | int qmp_guest_fsfreeze_do_thaw(Error **errp); |
| 48 | #endif /* CONFIG_FSFREEZE */ |
Philippe Mathieu-Daudé | 5d3586b | 2020-04-14 15:30:42 +0200 | [diff] [blame] | 49 | |
Alexander Ivanov | a124109 | 2022-10-17 09:28:24 +0200 | [diff] [blame] | 50 | #ifdef HAVE_GETIFADDRS |
| 51 | #include <ifaddrs.h> |
| 52 | bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned char *buf, |
| 53 | bool *obtained, Error **errp); |
| 54 | #endif |
| 55 | |
Philippe Mathieu-Daudé | 5d3586b | 2020-04-14 15:30:42 +0200 | [diff] [blame] | 56 | typedef struct GuestFileHandle GuestFileHandle; |
| 57 | |
| 58 | GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp); |
| 59 | |
Philippe Mathieu-Daudé | ead83a1 | 2020-04-14 15:30:43 +0200 | [diff] [blame] | 60 | GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh, |
| 61 | int64_t count, Error **errp); |
| 62 | |
Marc-André Lureau | 548fb0d | 2022-04-20 17:26:14 +0400 | [diff] [blame] | 63 | /** |
| 64 | * qga_get_host_name: |
| 65 | * @errp: Error object |
| 66 | * |
| 67 | * Operating system agnostic way of querying host name. |
| 68 | * Compared to g_get_host_name(), it doesn't cache the result. |
| 69 | * |
| 70 | * Returns allocated hostname (caller should free), NULL on failure. |
| 71 | */ |
| 72 | char *qga_get_host_name(Error **errp); |
| 73 | |
Philippe Mathieu-Daudé | 5d3586b | 2020-04-14 15:30:42 +0200 | [diff] [blame] | 74 | #endif |