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