2 * qemu_conf.h: QEMU configuration management
4 * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
5 * Copyright (C) 2006 Daniel P. Berrange
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see
19 * <http://www.gnu.org/licenses/>.
22 #ifndef LIBVIRT_QEMU_CONF_H
23 # define LIBVIRT_QEMU_CONF_H
27 # include "virebtables.h"
28 # include "internal.h"
29 # include "capabilities.h"
30 # include "network_conf.h"
31 # include "domain_conf.h"
32 # include "snapshot_conf.h"
33 # include "domain_event.h"
34 # include "virthread.h"
35 # include "security/security_manager.h"
39 # include "cpu_conf.h"
41 # include "virportallocator.h"
42 # include "vircommand.h"
43 # include "virthreadpool.h"
44 # include "locking/lock_manager.h"
45 # include "qemu_capabilities.h"
46 # include "virclosecallbacks.h"
47 # include "virhostdev.h"
49 # include "virfilecache.h"
50 # include "virfirmware.h"
52 # ifdef CPU_SETSIZE /* Linux */
53 # define QEMUD_CPUMASK_LEN CPU_SETSIZE
54 # elif defined(_SC_NPROCESSORS_CONF) /* Cygwin */
55 # define QEMUD_CPUMASK_LEN (sysconf(_SC_NPROCESSORS_CONF))
60 # define QEMU_DRIVER_NAME "QEMU"
62 typedef struct _virQEMUDriver virQEMUDriver
;
63 typedef virQEMUDriver
*virQEMUDriverPtr
;
65 typedef struct _virQEMUDriverConfig virQEMUDriverConfig
;
66 typedef virQEMUDriverConfig
*virQEMUDriverConfigPtr
;
68 /* Main driver config. The data in these object
69 * instances is immutable, so can be accessed
70 * without locking. Threads must, however, hold
71 * a valid reference on the object to prevent it
72 * being released while they use it.
75 * qemuDriverLock(driver);
76 * virQEMUDriverConfigPtr cfg = virObjectRef(driver->config);
77 * qemuDriverUnlock(driver);
79 * ...do stuff with 'cfg'..
81 * virObjectUnref(cfg);
83 struct _virQEMUDriverConfig
{
90 bool dynamicOwnership
;
92 virBitmapPtr namespaces
;
95 int cgroupControllers
;
96 char **cgroupDeviceACL
;
98 /* These five directories are ones libvirtd uses (so must be root:root
99 * to avoid security risk from QEMU processes */
107 /* These two directories are ones QEMU processes use (so must match
108 * the QEMU user/group */
113 char *channelTargetDir
;
115 char *swtpmStorageDir
;
117 char *defaultTLSx509certdir
;
118 bool defaultTLSx509certdirPresent
;
119 bool defaultTLSx509verify
;
120 char *defaultTLSx509secretUUID
;
122 bool vncAutoUnixSocket
;
124 bool vncTLSx509verify
;
125 bool vncTLSx509verifyPresent
;
127 char *vncTLSx509certdir
;
128 char *vncTLSx509secretUUID
;
134 char *spiceTLSx509certdir
;
139 bool spiceAutoUnixSocket
;
142 char *chardevTLSx509certdir
;
143 bool chardevTLSx509verify
;
144 bool chardevTLSx509verifyPresent
;
145 char *chardevTLSx509secretUUID
;
147 char *migrateTLSx509certdir
;
148 bool migrateTLSx509verify
;
149 bool migrateTLSx509verifyPresent
;
150 char *migrateTLSx509secretUUID
;
152 unsigned int remotePortMin
;
153 unsigned int remotePortMax
;
155 unsigned int webSocketPortMin
;
156 unsigned int webSocketPortMax
;
158 virHugeTLBFSPtr hugetlbfs
;
161 char *bridgeHelperName
;
167 bool vncAllowHostAudio
;
168 bool nogfxAllowHostAudio
;
169 bool clearEmulatorCapabilities
;
172 unsigned int maxProcesses
;
173 unsigned int maxFiles
;
174 unsigned long long maxCore
;
177 unsigned int maxQueuedJobs
;
179 char **securityDriverNames
;
180 bool securityDefaultConfined
;
181 bool securityRequireConfined
;
183 char *saveImageFormat
;
184 char *dumpImageFormat
;
185 char *snapshotImageFormat
;
188 bool autoDumpBypassCache
;
189 bool autoStartBypassCache
;
191 char *lockManagerName
;
193 int keepAliveInterval
;
194 unsigned int keepAliveCount
;
199 /* The default for -incoming */
200 char *migrationAddress
;
201 unsigned int migrationPortMin
;
202 unsigned int migrationPortMax
;
207 virFirmwarePtr
*firmwares
;
209 unsigned int glusterDebugLevel
;
211 char *memoryBackingDir
;
214 char *vxhsTLSx509certdir
;
217 char *nbdTLSx509certdir
;
223 /* Main driver state */
224 struct _virQEMUDriver
{
227 /* Require lock to get reference on 'config',
228 * then lockless thereafter */
229 virQEMUDriverConfigPtr config
;
231 /* Immutable pointer, self-locking APIs */
232 virThreadPoolPtr workerPool
;
234 /* Atomic increment only */
237 /* Atomic inc/dec only */
238 unsigned int nactive
;
240 /* Immutable value */
243 /* Immutable pointers. Caller must provide locking */
244 virStateInhibitCallback inhibitCallback
;
247 /* Immutable pointer, self-locking APIs */
248 virDomainObjListPtr domains
;
250 /* Immutable pointer */
253 /* Immutable pointer, lockless APIs. Pointless abstraction */
254 ebtablesContext
*ebtables
;
256 /* Require lock to get a reference on the object,
257 * lockless access thereafter
261 /* Immutable pointer, Immutable object */
262 virDomainXMLOptionPtr xmlopt
;
264 /* Immutable pointer, self-locking APIs */
265 virFileCachePtr qemuCapsCache
;
267 /* Immutable pointer, self-locking APIs */
268 virObjectEventStatePtr domainEventState
;
270 /* Immutable pointer. self-locking APIs */
271 virSecurityManagerPtr securityManager
;
273 virHostdevManagerPtr hostdevMgr
;
275 /* Immutable pointer. Unsafe APIs. XXX */
276 virHashTablePtr sharedDevices
;
278 /* Immutable pointer, immutable object */
279 virPortAllocatorRangePtr remotePorts
;
281 /* Immutable pointer, immutable object */
282 virPortAllocatorRangePtr webSocketPorts
;
284 /* Immutable pointer, immutable object */
285 virPortAllocatorRangePtr migrationPorts
;
287 /* Immutable pointer, lockless APIs*/
288 virSysinfoDefPtr hostsysinfo
;
290 /* Immutable pointer. lockless access */
291 virLockManagerPluginPtr lockManager
;
293 /* Immutable pointer, self-clocking APIs */
294 virCloseCallbacksPtr closeCallbacks
;
296 /* Immutable pointer, self-locking APIs */
297 virHashAtomicPtr migrationErrors
;
300 typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef
;
301 typedef qemuDomainCmdlineDef
*qemuDomainCmdlineDefPtr
;
302 struct _qemuDomainCmdlineDef
{
306 unsigned int num_env
;
313 void qemuDomainCmdlineDefFree(qemuDomainCmdlineDefPtr def
);
315 virQEMUDriverConfigPtr
virQEMUDriverConfigNew(bool privileged
);
317 int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg
,
318 const char *filename
,
322 virQEMUDriverConfigValidate(virQEMUDriverConfigPtr cfg
);
325 virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr cfg
);
327 virQEMUDriverConfigPtr
virQEMUDriverGetConfig(virQEMUDriverPtr driver
);
328 bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver
);
330 virCapsPtr
virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver
);
331 virCapsPtr
virQEMUDriverGetCapabilities(virQEMUDriverPtr driver
,
334 typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry
;
335 typedef qemuSharedDeviceEntry
*qemuSharedDeviceEntryPtr
;
337 bool qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry
,
340 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
342 char *qemuGetSharedDeviceKey(const char *disk_path
)
343 ATTRIBUTE_NONNULL(1);
345 void qemuSharedDeviceEntryFree(void *payload
, const void *name
);
347 int qemuAddSharedDisk(virQEMUDriverPtr driver
,
348 virDomainDiskDefPtr disk
,
350 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
352 int qemuAddSharedDevice(virQEMUDriverPtr driver
,
353 virDomainDeviceDefPtr dev
,
355 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
357 int qemuRemoveSharedDevice(virQEMUDriverPtr driver
,
358 virDomainDeviceDefPtr dev
,
360 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
362 int qemuRemoveSharedDisk(virQEMUDriverPtr driver
,
363 virDomainDiskDefPtr disk
,
365 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
367 int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev
);
369 int qemuDriverAllocateID(virQEMUDriverPtr driver
);
370 virDomainXMLOptionPtr
virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver
);
372 int qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def
);
374 char * qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage
);
375 char * qemuGetDomainHugepagePath(const virDomainDef
*def
,
376 virHugeTLBFSPtr hugepage
);
378 int qemuGetDomainHupageMemPath(const virDomainDef
*def
,
379 virQEMUDriverConfigPtr cfg
,
380 unsigned long long pagesize
,
383 int qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg
,
385 int qemuGetMemoryBackingDomainPath(const virDomainDef
*def
,
386 virQEMUDriverConfigPtr cfg
,
388 int qemuGetMemoryBackingPath(const virDomainDef
*def
,
389 virQEMUDriverConfigPtr cfg
,
392 #endif /* LIBVIRT_QEMU_CONF_H */