aboutsummaryrefslogtreecommitdiff
path: root/qga/commands-common.h
blob: cb51b1c6e95ae09a19df4eda7a8fbb786a312b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * QEMU Guest Agent common/cross-platform common commands
 *
 * Copyright (c) 2020 Red Hat, Inc.
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */
#ifndef QGA_COMMANDS_COMMON_H
#define QGA_COMMANDS_COMMON_H

#include "qga-qapi-types.h"
#include "guest-agent-core.h"
#include "qemu/queue.h"

#if defined(__linux__)
#include <linux/fs.h>
#ifdef FIFREEZE
#define CONFIG_FSFREEZE
#endif
#ifdef FITRIM
#define CONFIG_FSTRIM
#endif
#endif /* __linux__ */

#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM)
typedef struct FsMount {
    char *dirname;
    char *devtype;
    unsigned int devmajor, devminor;
    QTAILQ_ENTRY(FsMount) next;
} FsMount;

typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;

bool build_fs_mount_list(FsMountList *mounts, Error **errp);
void free_fs_mount_list(FsMountList *mounts);
#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */

#if defined(CONFIG_FSFREEZE)
int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints,
                                          strList *mountpoints,
                                          FsMountList mounts,
                                          Error **errp);
int qmp_guest_fsfreeze_do_thaw(Error **errp);
#endif /* CONFIG_FSFREEZE */

typedef struct GuestFileHandle GuestFileHandle;

GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp);

GuestFileRead *guest_file_read_unsafe(GuestFileHandle *gfh,
                                      int64_t count, Error **errp);

/**
 * qga_get_host_name:
 * @errp: Error object
 *
 * Operating system agnostic way of querying host name.
 * Compared to g_get_host_name(), it doesn't cache the result.
 *
 * Returns allocated hostname (caller should free), NULL on failure.
 */
char *qga_get_host_name(Error **errp);

#endif