libvirt/src/qemu/qemu_conf.h

405 lines
11 KiB
C
Raw Normal View History

2007-02-14 01:40:09 +00:00
/*
* qemu_conf.h: QEMU configuration management
2007-02-14 01:40:09 +00:00
*
* Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
2007-02-14 01:40:09 +00:00
* 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
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
2007-02-14 01:40:09 +00:00
*/
#pragma once
#include <unistd.h>
#include "virebtables.h"
#include "internal.h"
#include "capabilities.h"
#include "network_conf.h"
#include "domain_conf.h"
#include "checkpoint_conf.h"
#include "snapshot_conf.h"
#include "domain_event.h"
#include "virthread.h"
#include "security/security_manager.h"
#include "virpci.h"
#include "virusb.h"
#include "virscsi.h"
#include "cpu_conf.h"
#include "driver.h"
#include "virportallocator.h"
#include "vircommand.h"
#include "virthreadpool.h"
#include "locking/lock_manager.h"
#include "qemu_capabilities.h"
#include "virclosecallbacks.h"
#include "virhostdev.h"
#include "virfile.h"
#include "virfilecache.h"
#include "virfirmware.h"
#define QEMU_DRIVER_NAME "QEMU"
typedef struct _virQEMUDriver virQEMUDriver;
typedef virQEMUDriver *virQEMUDriverPtr;
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
typedef virQEMUDriverConfig *virQEMUDriverConfigPtr;
/* Main driver config. The data in these object
* instances is immutable, so can be accessed
* without locking. Threads must, however, hold
* a valid reference on the object to prevent it
* being released while they use it.
*
* eg
* qemuDriverLock(driver);
* virQEMUDriverConfigPtr cfg = virObjectRef(driver->config);
* qemuDriverUnlock(driver);
*
* ...do stuff with 'cfg'..
*
* virObjectUnref(cfg);
*/
struct _virQEMUDriverConfig {
virObject parent;
qemu: add support for running QEMU driver in embedded mode This enables support for running QEMU embedded to the calling application process using a URI: qemu:///embed?root=/some/path Note that it is important to keep the path reasonably short to avoid risk of hitting the limit on UNIX socket path names which is 108 characters. When using the embedded mode with a root=/var/tmp/embed, the driver will use the following paths: logDir: /var/tmp/embed/log/qemu swtpmLogDir: /var/tmp/embed/log/swtpm configBaseDir: /var/tmp/embed/etc/qemu stateDir: /var/tmp/embed/run/qemu swtpmStateDir: /var/tmp/embed/run/swtpm cacheDir: /var/tmp/embed/cache/qemu libDir: /var/tmp/embed/lib/qemu swtpmStorageDir: /var/tmp/embed/lib/swtpm defaultTLSx509certdir: /var/tmp/embed/etc/pki/qemu These are identical whether the embedded driver is privileged or unprivileged. This compares with the system instance which uses logDir: /var/log/libvirt/qemu swtpmLogDir: /var/log/swtpm/libvirt/qemu configBaseDir: /etc/libvirt/qemu stateDir: /run/libvirt/qemu swtpmStateDir: /run/libvirt/qemu/swtpm cacheDir: /var/cache/libvirt/qemu libDir: /var/lib/libvirt/qemu swtpmStorageDir: /var/lib/libvirt/swtpm defaultTLSx509certdir: /etc/pki/qemu At this time all features present in the QEMU driver are available when running in embedded mode, availability matching whether the embedded driver is privileged or unprivileged. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-05-17 11:35:57 +00:00
char *uri;
uid_t user;
gid_t group;
bool dynamicOwnership;
virBitmapPtr namespaces;
bool rememberOwner;
int cgroupControllers;
char **cgroupDeviceACL;
/* These five directories are ones libvirtd uses (so must be root:root
* to avoid security risk from QEMU processes */
char *configBaseDir;
char *configDir;
char *autostartDir;
char *logDir;
char *swtpmLogDir;
char *stateDir;
char *swtpmStateDir;
char *slirpStateDir;
/* These two directories are ones QEMU processes use (so must match
* the QEMU user/group */
char *libDir;
char *cacheDir;
char *saveDir;
char *snapshotDir;
char *checkpointDir;
char *channelTargetDir;
char *nvramDir;
char *swtpmStorageDir;
char *defaultTLSx509certdir;
bool defaultTLSx509certdirPresent;
bool defaultTLSx509verify;
char *defaultTLSx509secretUUID;
bool vncAutoUnixSocket;
bool vncTLS;
bool vncTLSx509verify;
bool vncTLSx509verifyPresent;
bool vncSASL;
2007-10-12 16:05:44 +00:00
char *vncTLSx509certdir;
char *vncTLSx509secretUUID;
char *vncListen;
char *vncPassword;
2009-03-16 13:54:26 +00:00
char *vncSASLdir;
bool spiceTLS;
char *spiceTLSx509certdir;
bool spiceSASL;
char *spiceSASLdir;
char *spiceListen;
char *spicePassword;
bool spiceAutoUnixSocket;
bool chardevTLS;
char *chardevTLSx509certdir;
bool chardevTLSx509verify;
bool chardevTLSx509verifyPresent;
char *chardevTLSx509secretUUID;
char *migrateTLSx509certdir;
bool migrateTLSx509verify;
bool migrateTLSx509verifyPresent;
char *migrateTLSx509secretUUID;
unsigned int remotePortMin;
unsigned int remotePortMax;
unsigned int webSocketPortMin;
unsigned int webSocketPortMax;
virHugeTLBFSPtr hugetlbfs;
size_t nhugetlbfs;
char *bridgeHelperName;
char *prHelperName;
char *slirpHelperName;
bool macFilter;
bool relaxedACS;
bool vncAllowHostAudio;
bool nogfxAllowHostAudio;
bool setProcessName;
unsigned int maxProcesses;
unsigned int maxFiles;
unsigned int maxThreadsPerProc;
unsigned long long maxCore;
bool dumpGuestCore;
unsigned int maxQueuedJobs;
char **securityDriverNames;
bool securityDefaultConfined;
bool securityRequireConfined;
char *saveImageFormat;
char *dumpImageFormat;
char *snapshotImageFormat;
char *autoDumpPath;
bool autoDumpBypassCache;
bool autoStartBypassCache;
char *lockManagerName;
int keepAliveInterval;
unsigned int keepAliveCount;
int seccompSandbox;
char *migrateHost;
/* The default for -incoming */
char *migrationAddress;
unsigned int migrationPortMin;
unsigned int migrationPortMax;
bool logTimestamp;
bool stdioLogD;
virFirmwarePtr *firmwares;
size_t nfirmwares;
unsigned int glusterDebugLevel;
char *memoryBackingDir;
bool vxhsTLS;
char *vxhsTLSx509certdir;
bool nbdTLS;
char *nbdTLSx509certdir;
uid_t swtpm_user;
gid_t swtpm_group;
char **capabilityfilters;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUDriverConfig, virObjectUnref);
/* Main driver state */
struct _virQEMUDriver {
virMutex lock;
/* Require lock to get reference on 'config',
* then lockless thereafter */
virQEMUDriverConfigPtr config;
/* pid file FD, ensures two copies of the driver can't use the same root */
int lockFD;
/* Immutable pointer, self-locking APIs */
virThreadPoolPtr workerPool;
/* Atomic increment only */
int lastvmid;
/* Atomic inc/dec only */
unsigned int nactive;
qemu: add support for running QEMU driver in embedded mode This enables support for running QEMU embedded to the calling application process using a URI: qemu:///embed?root=/some/path Note that it is important to keep the path reasonably short to avoid risk of hitting the limit on UNIX socket path names which is 108 characters. When using the embedded mode with a root=/var/tmp/embed, the driver will use the following paths: logDir: /var/tmp/embed/log/qemu swtpmLogDir: /var/tmp/embed/log/swtpm configBaseDir: /var/tmp/embed/etc/qemu stateDir: /var/tmp/embed/run/qemu swtpmStateDir: /var/tmp/embed/run/swtpm cacheDir: /var/tmp/embed/cache/qemu libDir: /var/tmp/embed/lib/qemu swtpmStorageDir: /var/tmp/embed/lib/swtpm defaultTLSx509certdir: /var/tmp/embed/etc/pki/qemu These are identical whether the embedded driver is privileged or unprivileged. This compares with the system instance which uses logDir: /var/log/libvirt/qemu swtpmLogDir: /var/log/swtpm/libvirt/qemu configBaseDir: /etc/libvirt/qemu stateDir: /run/libvirt/qemu swtpmStateDir: /run/libvirt/qemu/swtpm cacheDir: /var/cache/libvirt/qemu libDir: /var/lib/libvirt/qemu swtpmStorageDir: /var/lib/libvirt/swtpm defaultTLSx509certdir: /etc/pki/qemu At this time all features present in the QEMU driver are available when running in embedded mode, availability matching whether the embedded driver is privileged or unprivileged. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-05-17 11:35:57 +00:00
/* Immutable values */
bool privileged;
qemu: add support for running QEMU driver in embedded mode This enables support for running QEMU embedded to the calling application process using a URI: qemu:///embed?root=/some/path Note that it is important to keep the path reasonably short to avoid risk of hitting the limit on UNIX socket path names which is 108 characters. When using the embedded mode with a root=/var/tmp/embed, the driver will use the following paths: logDir: /var/tmp/embed/log/qemu swtpmLogDir: /var/tmp/embed/log/swtpm configBaseDir: /var/tmp/embed/etc/qemu stateDir: /var/tmp/embed/run/qemu swtpmStateDir: /var/tmp/embed/run/swtpm cacheDir: /var/tmp/embed/cache/qemu libDir: /var/tmp/embed/lib/qemu swtpmStorageDir: /var/tmp/embed/lib/swtpm defaultTLSx509certdir: /var/tmp/embed/etc/pki/qemu These are identical whether the embedded driver is privileged or unprivileged. This compares with the system instance which uses logDir: /var/log/libvirt/qemu swtpmLogDir: /var/log/swtpm/libvirt/qemu configBaseDir: /etc/libvirt/qemu stateDir: /run/libvirt/qemu swtpmStateDir: /run/libvirt/qemu/swtpm cacheDir: /var/cache/libvirt/qemu libDir: /var/lib/libvirt/qemu swtpmStorageDir: /var/lib/libvirt/swtpm defaultTLSx509certdir: /etc/pki/qemu At this time all features present in the QEMU driver are available when running in embedded mode, availability matching whether the embedded driver is privileged or unprivileged. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-05-17 11:35:57 +00:00
char *embeddedRoot;
/* Immutable pointers. Caller must provide locking */
virStateInhibitCallback inhibitCallback;
void *inhibitOpaque;
/* Immutable pointer, self-locking APIs */
virDomainObjListPtr domains;
/* Immutable pointer */
char *qemuImgBinary;
/* Immutable pointer, lockless APIs. Pointless abstraction */
ebtablesContext *ebtables;
/* Require lock to get a reference on the object,
* lockless access thereafter
*/
virCapsPtr caps;
/* Lazy initialized on first use, immutable thereafter.
* Require lock to get the pointer & do optional initialization
*/
virCapsHostNUMAPtr hostnuma;
/* Lazy initialized on first use, immutable thereafter.
* Require lock to get the pointer & do optional initialization
*/
virCPUDefPtr hostcpu;
/* Immutable value */
virArch hostarch;
/* Immutable pointer, Immutable object */
virDomainXMLOptionPtr xmlopt;
/* Immutable pointer, self-locking APIs */
virFileCachePtr qemuCapsCache;
/* Immutable pointer, self-locking APIs */
virObjectEventStatePtr domainEventState;
/* Immutable pointer. self-locking APIs */
virSecurityManagerPtr securityManager;
virHostdevManagerPtr hostdevMgr;
/* Immutable pointer. Unsafe APIs. XXX */
virHashTablePtr sharedDevices;
/* Immutable pointer, immutable object */
virPortAllocatorRangePtr remotePorts;
/* Immutable pointer, immutable object */
virPortAllocatorRangePtr webSocketPorts;
/* Immutable pointer, immutable object */
virPortAllocatorRangePtr migrationPorts;
/* Immutable pointer, lockless APIs*/
virSysinfoDefPtr hostsysinfo;
/* Immutable pointer. lockless access */
virLockManagerPluginPtr lockManager;
/* Immutable pointer, self-clocking APIs */
virCloseCallbacksPtr closeCallbacks;
/* Immutable pointer, self-locking APIs */
virHashAtomicPtr migrationErrors;
};
qemu: add support for running QEMU driver in embedded mode This enables support for running QEMU embedded to the calling application process using a URI: qemu:///embed?root=/some/path Note that it is important to keep the path reasonably short to avoid risk of hitting the limit on UNIX socket path names which is 108 characters. When using the embedded mode with a root=/var/tmp/embed, the driver will use the following paths: logDir: /var/tmp/embed/log/qemu swtpmLogDir: /var/tmp/embed/log/swtpm configBaseDir: /var/tmp/embed/etc/qemu stateDir: /var/tmp/embed/run/qemu swtpmStateDir: /var/tmp/embed/run/swtpm cacheDir: /var/tmp/embed/cache/qemu libDir: /var/tmp/embed/lib/qemu swtpmStorageDir: /var/tmp/embed/lib/swtpm defaultTLSx509certdir: /var/tmp/embed/etc/pki/qemu These are identical whether the embedded driver is privileged or unprivileged. This compares with the system instance which uses logDir: /var/log/libvirt/qemu swtpmLogDir: /var/log/swtpm/libvirt/qemu configBaseDir: /etc/libvirt/qemu stateDir: /run/libvirt/qemu swtpmStateDir: /run/libvirt/qemu/swtpm cacheDir: /var/cache/libvirt/qemu libDir: /var/lib/libvirt/qemu swtpmStorageDir: /var/lib/libvirt/swtpm defaultTLSx509certdir: /etc/pki/qemu At this time all features present in the QEMU driver are available when running in embedded mode, availability matching whether the embedded driver is privileged or unprivileged. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-05-17 11:35:57 +00:00
virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged,
const char *root);
int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
const char *filename,
bool privileged);
int
virQEMUDriverConfigValidate(virQEMUDriverConfigPtr cfg);
int
virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr cfg);
virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver);
bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver);
virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver);
virCPUDefPtr virQEMUDriverGetHostCPU(virQEMUDriverPtr driver);
virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver);
virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
bool refresh);
virDomainCapsPtr
virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
const char *machine,
virArch arch,
virDomainVirtType virttype);
typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry;
typedef qemuSharedDeviceEntry *qemuSharedDeviceEntryPtr;
bool qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry,
const char *name,
int *idx)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
char *qemuGetSharedDeviceKey(const char *disk_path)
ATTRIBUTE_NONNULL(1);
void qemuSharedDeviceEntryFree(void *payload);
int qemuAddSharedDisk(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk,
const char *name)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuAddSharedDevice(virQEMUDriverPtr driver,
virDomainDeviceDefPtr dev,
const char *name)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuRemoveSharedDevice(virQEMUDriverPtr driver,
virDomainDeviceDefPtr dev,
const char *name)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuRemoveSharedDisk(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk,
const char *name)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
int qemuDriverAllocateID(virQEMUDriverPtr driver);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver,
const char *defsecmodel);
int qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def);
char * qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage);
char * qemuGetDomainHugepagePath(const virDomainDef *def,
virHugeTLBFSPtr hugepage);
int qemuGetDomainHupageMemPath(const virDomainDef *def,
virQEMUDriverConfigPtr cfg,
unsigned long long pagesize,
char **memPath);
void qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg,
char **path);
int qemuGetMemoryBackingDomainPath(const virDomainDef *def,
virQEMUDriverConfigPtr cfg,
char **path);
int qemuGetMemoryBackingPath(const virDomainDef *def,
virQEMUDriverConfigPtr cfg,
const char *alias,
char **memPath);