libxl_conf.h 4.4 KB
Newer Older
J
Jim Fehlig 已提交
1
/*---------------------------------------------------------------------------*/
2
/*  Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
3
 *  Copyright (C) 2011 Univention GmbH.
J
Jim Fehlig 已提交
4 5 6 7 8 9 10 11 12 13 14 15
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library.  If not, see
O
Osier Yang 已提交
17
 * <http://www.gnu.org/licenses/>.
M
Markus Groß 已提交
18 19 20
 *
 * Authors:
 *     Jim Fehlig <jfehlig@novell.com>
21
 *     Markus Groß <gross@univention.de>
J
Jim Fehlig 已提交
22 23 24 25 26 27 28 29 30 31
 */
/*---------------------------------------------------------------------------*/

#ifndef LIBXL_CONF_H
# define LIBXL_CONF_H

# include <libxl.h>

# include "internal.h"
# include "domain_conf.h"
32
# include "domain_event.h"
J
Jim Fehlig 已提交
33 34
# include "capabilities.h"
# include "configmake.h"
35
# include "virportallocator.h"
36
# include "virobject.h"
B
Bamvor Jian Zhang 已提交
37
# include "virchrdev.h"
J
Jim Fehlig 已提交
38 39 40 41 42 43 44 45 46 47 48


# define LIBXL_VNC_PORT_MIN  5900
# define LIBXL_VNC_PORT_MAX  65535

# define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl"
# define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart"
# define LIBXL_STATE_DIR LOCALSTATEDIR "/run/libvirt/libxl"
# define LIBXL_LOG_DIR LOCALSTATEDIR "/log/libvirt/libxl"
# define LIBXL_LIB_DIR LOCALSTATEDIR "/lib/libvirt/libxl"
# define LIBXL_SAVE_DIR LIBXL_LIB_DIR "/save"
49
# define LIBXL_BOOTLOADER_PATH BINDIR "/pygrub"
J
Jim Fehlig 已提交
50 51 52 53


typedef struct _libxlDriverPrivate libxlDriverPrivate;
typedef libxlDriverPrivate *libxlDriverPrivatePtr;
54 55 56 57 58 59 60

typedef struct _libxlDriverConfig libxlDriverConfig;
typedef libxlDriverConfig *libxlDriverConfigPtr;

struct _libxlDriverConfig {
    virObject parent;

61
    const libxl_version_info *verInfo;
J
Jim Fehlig 已提交
62 63
    unsigned int version;

J
Jim Fehlig 已提交
64 65 66
    /* log stream for driver-wide libxl ctx */
    FILE *logger_file;
    xentoollog_logger *logger;
J
Jim Fehlig 已提交
67
    /* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
J
Jim Fehlig 已提交
68
    libxl_ctx *ctx;
J
Jim Fehlig 已提交
69

70 71 72 73
    /* Controls automatic ballooning of domain0. If true, attempt to get
     * memory for new domains from domain0. */
    bool autoballoon;

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    /* Once created, caps are immutable */
    virCapsPtr caps;

    char *configDir;
    char *autostartDir;
    char *logDir;
    char *stateDir;
    char *libDir;
    char *saveDir;
};


struct _libxlDriverPrivate {
    virMutex lock;

    /* Require lock to get reference on 'config',
     * then lockless thereafter */
    libxlDriverConfigPtr config;

93
    /* Atomic inc/dec only */
94
    unsigned int nactive;
95

96
    /* Immutable pointers. Caller must provide locking */
97 98 99
    virStateInhibitCallback inhibitCallback;
    void *inhibitOpaque;

100
    /* Immutable pointer, self-locking APIs */
101
    virDomainObjListPtr domains;
J
Jim Fehlig 已提交
102

103
    /* Immutable pointer, immutable object */
104 105
    virDomainXMLOptionPtr xmlopt;

106
    /* Immutable pointer, self-locking APIs */
107
    virDomainEventStatePtr domainEventState;
108

109
    /* Immutable pointer, self-locking APIs */
110 111
    virPortAllocatorPtr reservedVNCPorts;

112
    /* Immutable pointer, lockless APIs*/
113
    virSysinfoDefPtr hostsysinfo;
J
Jim Fehlig 已提交
114 115
};

J
Jim Fehlig 已提交
116 117 118
typedef struct _libxlEventHookInfo libxlEventHookInfo;
typedef libxlEventHookInfo *libxlEventHookInfoPtr;

119 120 121 122 123 124 125 126 127 128 129 130
# define LIBXL_SAVE_MAGIC "libvirt-xml\n \0 \r"
# define LIBXL_SAVE_VERSION 1

typedef struct _libxlSavefileHeader libxlSavefileHeader;
typedef libxlSavefileHeader *libxlSavefileHeaderPtr;
struct _libxlSavefileHeader {
    char magic[sizeof(LIBXL_SAVE_MAGIC)-1];
    uint32_t version;
    uint32_t xmlLen;
    /* 24 bytes used, pad up to 64 bytes */
    uint32_t unused[10];
};
J
Jim Fehlig 已提交
131

132 133 134 135 136
libxlDriverConfigPtr
libxlDriverConfigNew(void);

libxlDriverConfigPtr
libxlDriverConfigGet(libxlDriverPrivatePtr driver);
137

J
Jim Fehlig 已提交
138 139 140
virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx);

141
int
J
Jim Fehlig 已提交
142
libxlMakeDisk(virDomainDiskDefPtr l_dev, libxl_device_disk *x_dev);
143
int
J
Jim Fehlig 已提交
144
libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic);
145
int
J
Jim Fehlig 已提交
146
libxlMakeVfb(libxlDriverPrivatePtr driver,
147
             virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb);
148

J
Jim Fehlig 已提交
149 150
int
libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
151
                       virDomainObjPtr vm, libxl_domain_config *d_config);
J
Jim Fehlig 已提交
152 153

#endif /* LIBXL_CONF_H */