]> git.proxmox.com Git - mirror_qemu.git/blame - qga/commands-common.h
qga: Move Linux-specific FS freeze/thaw code to a separate file
[mirror_qemu.git] / qga / commands-common.h
CommitLineData
5d3586b8
PMD
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"
518b0d80
AI
13#include "guest-agent-core.h"
14#include "qemu/queue.h"
15
16#if defined(__linux__)
17#include <linux/fs.h>
18#ifdef FIFREEZE
19#define CONFIG_FSFREEZE
20#endif
21#ifdef FITRIM
22#define CONFIG_FSTRIM
23#endif
24#endif /* __linux__ */
25
26#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM)
27typedef struct FsMount {
28 char *dirname;
29 char *devtype;
30 unsigned int devmajor, devminor;
31 QTAILQ_ENTRY(FsMount) next;
32} FsMount;
33
34typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;
35
36bool build_fs_mount_list(FsMountList *mounts, Error **errp);
37void free_fs_mount_list(FsMountList *mounts);
38#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */
39
40#if defined(CONFIG_FSFREEZE)
41int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints,
42 strList *mountpoints,
43 FsMountList mounts,
44 Error **errp);
45int qmp_guest_fsfreeze_do_thaw(Error **errp);
46#endif /* CONFIG_FSFREEZE */
5d3586b8
PMD
47
48typedef struct GuestFileHandle GuestFileHandle;
49
50GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp);
51
ead83a13
PMD
52GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh,
53 int64_t count, Error **errp);
54
548fb0da
MAL
55/**
56 * qga_get_host_name:
57 * @errp: Error object
58 *
59 * Operating system agnostic way of querying host name.
60 * Compared to g_get_host_name(), it doesn't cache the result.
61 *
62 * Returns allocated hostname (caller should free), NULL on failure.
63 */
64char *qga_get_host_name(Error **errp);
65
5d3586b8 66#endif