qemu_conf.h 6.0 KB
Newer Older
D
Daniel P. Berrange 已提交
1
/*
2
 * qemu_conf.h: QEMU configuration management
D
Daniel P. Berrange 已提交
3
 *
4
 * Copyright (C) 2006-2007, 2009-2012 Red Hat, Inc.
D
Daniel P. Berrange 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2006 Daniel P. Berrange
 *
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
D
Daniel P. Berrange 已提交
20 21 22 23
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

24
#ifndef __QEMUD_CONF_H
25
# define __QEMUD_CONF_H
D
Daniel P. Berrange 已提交
26

27
# include <config.h>
28

29 30 31 32 33 34 35
# include "ebtables.h"
# include "internal.h"
# include "capabilities.h"
# include "network_conf.h"
# include "domain_conf.h"
# include "domain_event.h"
# include "threads.h"
36
# include "security/security_manager.h"
37
# include "vircgroup.h"
38
# include "pci.h"
39
# include "hostusb.h"
40 41
# include "cpu_conf.h"
# include "driver.h"
42
# include "virbitmap.h"
43
# include "vircommand.h"
H
Hu Tao 已提交
44
# include "threadpool.h"
45
# include "locking/lock_manager.h"
46
# include "qemu_capabilities.h"
47

48
# define QEMUD_CPUMASK_LEN CPU_SETSIZE
49

50 51
typedef struct _qemuDriverCloseDef qemuDriverCloseDef;
typedef qemuDriverCloseDef *qemuDriverCloseDefPtr;
52

53 54 55
typedef struct _virQEMUDriver virQEMUDriver;
typedef virQEMUDriver *virQEMUDriverPtr;

56
/* Main driver state */
57
struct _virQEMUDriver {
58
    virMutex lock;
59

H
Hu Tao 已提交
60 61
    virThreadPoolPtr workerPool;

62
    bool privileged;
63
    const char *uri;
64

65 66
    uid_t user;
    gid_t group;
67
    int dynamicOwnership;
68

69
    unsigned int qemuVersion;
70
    int nextvmid;
71

72
    virCgroupPtr cgroup;
73 74 75
    int cgroupControllers;
    char **cgroupDeviceACL;

76 77 78 79
    size_t nactive;
    virStateInhibitCallback inhibitCallback;
    void *inhibitOpaque;

80
    virDomainObjList domains;
81

82
    /* These five directories are ones libvirtd uses (so must be root:root
83
     * to avoid security risk from QEMU processes */
84
    char *configBaseDir;
85 86
    char *configDir;
    char *autostartDir;
87
    char *logDir;
88
    char *stateDir;
89 90 91 92
    /* These two directories are ones QEMU processes use (so must match
     * the QEMU user/group */
    char *libDir;
    char *cacheDir;
93
    char *saveDir;
C
Chris Lalancette 已提交
94
    char *snapshotDir;
E
Eric Blake 已提交
95
    char *qemuImgBinary;
96
    unsigned int vncAutoUnixSocket : 1;
97 98
    unsigned int vncTLS : 1;
    unsigned int vncTLSx509verify : 1;
99
    unsigned int vncSASL : 1;
D
Daniel P. Berrange 已提交
100
    char *vncTLSx509certdir;
101
    char *vncListen;
102
    char *vncPassword;
103
    char *vncSASLdir;
104 105 106 107
    unsigned int spiceTLS : 1;
    char *spiceTLSx509certdir;
    char *spiceListen;
    char *spicePassword;
108 109
    int remotePortMin;
    int remotePortMax;
110 111
    char *hugetlbfs_mount;
    char *hugepage_path;
112

113 114 115
    unsigned int macFilter : 1;
    ebtablesContext *ebtables;

116
    unsigned int relaxedACS : 1;
117
    unsigned int vncAllowHostAudio : 1;
118
    unsigned int clearEmulatorCapabilities : 1;
119
    unsigned int allowDiskFormatProbing : 1;
120
    unsigned int setProcessName : 1;
121

122
    int maxProcesses;
123
    int maxFiles;
124

125 126
    int max_queued;

127
    virCapsPtr caps;
128
    qemuCapsCachePtr capsCache;
129

130
    virDomainEventStatePtr domainEventState;
131

132
    char **securityDriverNames;
133 134
    bool securityDefaultConfined;
    bool securityRequireConfined;
135
    virSecurityManagerPtr securityManager;
136 137

    char *saveImageFormat;
138
    char *dumpImageFormat;
139

H
Hu Tao 已提交
140
    char *autoDumpPath;
141 142 143
    bool autoDumpBypassCache;

    bool autoStartBypassCache;
H
Hu Tao 已提交
144

145
    pciDeviceList *activePciHostdevs;
146
    usbDeviceList *activeUsbHostdevs;
147

148 149 150
    /* The devices which is are not in use by the host or any guest. */
    pciDeviceList *inactivePciHostdevs;

151
    virBitmapPtr reservedRemotePorts;
152 153

    virSysinfoDefPtr hostsysinfo;
154 155

    virLockManagerPluginPtr lockManager;
156

157 158 159 160 161 162 163
    /* Mapping of 'char *uuidstr' -> qemuDriverCloseDefPtr of domains
     * which want a specific cleanup to be done when a connection is
     * closed. Such cleanup may be to automatically destroy the
     * domain or abort a particular job running on it.
     */
    virHashTablePtr closeCallbacks;

164 165
    int keepAliveInterval;
    unsigned int keepAliveCount;
166
    int seccompSandbox;
167 168
};

169 170 171 172 173 174 175 176 177 178 179
typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef;
typedef qemuDomainCmdlineDef *qemuDomainCmdlineDefPtr;
struct _qemuDomainCmdlineDef {
    unsigned int num_args;
    char **args;

    unsigned int num_env;
    char **env_name;
    char **env_value;
};

D
Daniel Veillard 已提交
180
/* Port numbers used for KVM migration. */
181 182
# define QEMUD_MIGRATION_FIRST_PORT 49152
# define QEMUD_MIGRATION_NUM_PORTS 64
183 184


185 186 187
void qemuDriverLock(virQEMUDriverPtr driver);
void qemuDriverUnlock(virQEMUDriverPtr driver);
int qemuLoadDriverConfig(virQEMUDriverPtr driver,
188
                         const char *filename);
189

190 191 192 193
struct qemuDomainDiskInfo {
    bool removable;
    bool locked;
    bool tray_open;
194
    int io_status;
195 196
};

197
typedef virDomainObjPtr (*qemuDriverCloseCallback)(virQEMUDriverPtr driver,
198 199
                                                   virDomainObjPtr vm,
                                                   virConnectPtr conn);
200 201 202
int qemuDriverCloseCallbackInit(virQEMUDriverPtr driver);
void qemuDriverCloseCallbackShutdown(virQEMUDriverPtr driver);
int qemuDriverCloseCallbackSet(virQEMUDriverPtr driver,
203 204 205
                               virDomainObjPtr vm,
                               virConnectPtr conn,
                               qemuDriverCloseCallback cb);
206
int qemuDriverCloseCallbackUnset(virQEMUDriverPtr driver,
207 208
                                 virDomainObjPtr vm,
                                 qemuDriverCloseCallback cb);
209
qemuDriverCloseCallback qemuDriverCloseCallbackGet(virQEMUDriverPtr driver,
210 211
                                                   virDomainObjPtr vm,
                                                   virConnectPtr conn);
212
void qemuDriverCloseCallbackRunAll(virQEMUDriverPtr driver,
213 214
                                   virConnectPtr conn);

215
#endif /* __QEMUD_CONF_H */