2007-02-14 01:40:09 +00:00
|
|
|
/*
|
2009-05-21 14:16:55 +00:00
|
|
|
* qemu_conf.h: QEMU configuration management
|
2007-02-14 01:40:09 +00:00
|
|
|
*
|
2010-05-13 03:07:00 +00:00
|
|
|
* Copyright (C) 2006-2007, 2009-2010 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2007-02-14 15:41:03 +00:00
|
|
|
#ifndef __QEMUD_CONF_H
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __QEMUD_CONF_H
|
2007-02-14 01:40:09 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <config.h>
|
2007-11-26 11:50:16 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "ebtables.h"
|
|
|
|
# include "internal.h"
|
|
|
|
# include "bridge.h"
|
|
|
|
# include "capabilities.h"
|
|
|
|
# include "network_conf.h"
|
|
|
|
# include "domain_conf.h"
|
|
|
|
# include "domain_event.h"
|
|
|
|
# include "threads.h"
|
Refactor the security drivers to simplify usage
The current security driver usage requires horrible code like
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityHostdevLabel &&
driver->securityDriver->domainSetSecurityHostdevLabel(driver->securityDriver,
vm, hostdev) < 0)
This pair of checks for NULL clutters up the code, making the driver
calls 2 lines longer than they really need to be. The goal of the
patchset is to change the calling convention to simply
if (virSecurityManagerSetHostdevLabel(driver->securityDriver,
vm, hostdev) < 0)
The first check for 'driver->securityDriver' being NULL is removed
by introducing a 'no op' security driver that will always be present
if no real driver is enabled. This guarentees driver->securityDriver
!= NULL.
The second check for 'driver->securityDriver->domainSetSecurityHostdevLabel'
being non-NULL is hidden in a new abstraction called virSecurityManager.
This separates the driver callbacks, from main internal API. The addition
of a virSecurityManager object, that is separate from the virSecurityDriver
struct also allows for security drivers to carry state / configuration
information directly. Thus the DAC/Stack drivers from src/qemu which
used to pull config from 'struct qemud_driver' can now be moved into
the 'src/security' directory and store their config directly.
* src/qemu/qemu_conf.h, src/qemu/qemu_driver.c: Update to
use new virSecurityManager APIs
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_dac.h
src/qemu/qemu_security_stacked.c, src/qemu/qemu_security_stacked.h:
Move into src/security directory
* src/security/security_stack.c, src/security/security_stack.h,
src/security/security_dac.c, src/security/security_dac.h: Generic
versions of previous QEMU specific drivers
* src/security/security_apparmor.c, src/security/security_apparmor.h,
src/security/security_driver.c, src/security/security_driver.h,
src/security/security_selinux.c, src/security/security_selinux.h:
Update to take virSecurityManagerPtr object as the first param
in all callbacks
* src/security/security_nop.c, src/security/security_nop.h: Stub
implementation of all security driver APIs.
* src/security/security_manager.h, src/security/security_manager.c:
New internal API for invoking security drivers
* src/libvirt.c: Add missing debug for security APIs
2010-11-17 20:26:30 +00:00
|
|
|
# include "security/security_manager.h"
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "cgroup.h"
|
|
|
|
# include "pci.h"
|
|
|
|
# include "cpu_conf.h"
|
|
|
|
# include "driver.h"
|
2010-05-21 13:52:09 +00:00
|
|
|
# include "bitmap.h"
|
2010-11-30 17:50:54 +00:00
|
|
|
# include "macvtap.h"
|
2010-11-22 23:09:13 +00:00
|
|
|
# include "command.h"
|
2010-12-08 06:19:17 +00:00
|
|
|
# include "threadpool.h"
|
2010-10-26 14:04:46 +00:00
|
|
|
# include "locking/lock_manager.h"
|
2007-06-26 23:48:46 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define QEMUD_CPUMASK_LEN CPU_SETSIZE
|
2007-06-26 23:48:46 +00:00
|
|
|
|
2007-06-26 22:13:21 +00:00
|
|
|
|
|
|
|
/* Main driver state */
|
|
|
|
struct qemud_driver {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 21:06:41 +00:00
|
|
|
|
2010-12-08 06:19:17 +00:00
|
|
|
virThreadPoolPtr workerPool;
|
|
|
|
|
2009-06-12 13:20:13 +00:00
|
|
|
int privileged;
|
|
|
|
|
2009-07-15 21:25:01 +00:00
|
|
|
uid_t user;
|
|
|
|
gid_t group;
|
2010-01-13 16:43:29 +00:00
|
|
|
int dynamicOwnership;
|
2009-07-15 21:25:01 +00:00
|
|
|
|
2008-08-29 07:11:15 +00:00
|
|
|
unsigned int qemuVersion;
|
2007-06-26 22:13:21 +00:00
|
|
|
int nextvmid;
|
2008-07-11 17:33:45 +00:00
|
|
|
|
2009-07-09 13:10:59 +00:00
|
|
|
virCgroupPtr cgroup;
|
2009-07-22 15:08:04 +00:00
|
|
|
int cgroupControllers;
|
|
|
|
char **cgroupDeviceACL;
|
|
|
|
|
2008-10-10 14:20:37 +00:00
|
|
|
virDomainObjList domains;
|
2008-07-11 17:33:45 +00:00
|
|
|
|
2007-06-26 22:13:21 +00:00
|
|
|
brControl *brctl;
|
2009-08-25 15:49:09 +00:00
|
|
|
/* These four directories are ones libvirtd uses (so must be root:root
|
|
|
|
* to avoid security risk from QEMU processes */
|
2007-06-26 22:13:21 +00:00
|
|
|
char *configDir;
|
|
|
|
char *autostartDir;
|
2008-07-11 19:34:11 +00:00
|
|
|
char *logDir;
|
2008-12-18 15:22:49 +00:00
|
|
|
char *stateDir;
|
2009-08-25 15:49:09 +00:00
|
|
|
/* These two directories are ones QEMU processes use (so must match
|
|
|
|
* the QEMU user/group */
|
|
|
|
char *libDir;
|
|
|
|
char *cacheDir;
|
2010-04-01 15:57:32 +00:00
|
|
|
char *saveDir;
|
2010-04-02 14:10:37 +00:00
|
|
|
char *snapshotDir;
|
2011-01-12 04:44:11 +00:00
|
|
|
unsigned int vncAutoUnixSocket : 1;
|
2007-11-15 10:56:24 +00:00
|
|
|
unsigned int vncTLS : 1;
|
|
|
|
unsigned int vncTLSx509verify : 1;
|
2009-03-16 13:54:26 +00:00
|
|
|
unsigned int vncSASL : 1;
|
2007-10-12 16:05:44 +00:00
|
|
|
char *vncTLSx509certdir;
|
2008-07-11 19:34:11 +00:00
|
|
|
char *vncListen;
|
2009-01-29 17:50:00 +00:00
|
|
|
char *vncPassword;
|
2009-03-16 13:54:26 +00:00
|
|
|
char *vncSASLdir;
|
2010-03-05 20:31:50 +00:00
|
|
|
unsigned int spiceTLS : 1;
|
|
|
|
char *spiceTLSx509certdir;
|
|
|
|
char *spiceListen;
|
|
|
|
char *spicePassword;
|
Support configuration of huge pages in guests
Add option to domain XML for
<memoryBacking>
<hugepages/>
</memoryBacking>
* configure.in: Add check for mntent.h
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
Add 'hugetlbfs_mount' config parameter
* src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
and pass it when hugepages are requested.
Load hugetlbfs_mount config parameter, search for mount if not given.
* src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
Create directory for QEMU hugepage usage, chowning if required.
* docs/formatdomain.html.in: Document memoryBacking/hugepages elements
* docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
* src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
helper API
* tests/qemuhelptest.c: Add -mem-path constants
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
handling
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
hugepage tests
2009-08-25 14:05:18 +00:00
|
|
|
char *hugetlbfs_mount;
|
|
|
|
char *hugepage_path;
|
2008-02-27 04:35:08 +00:00
|
|
|
|
2009-11-03 22:41:23 +00:00
|
|
|
unsigned int macFilter : 1;
|
|
|
|
ebtablesContext *ebtables;
|
|
|
|
|
2009-12-22 17:21:16 +00:00
|
|
|
unsigned int relaxedACS : 1;
|
2010-05-19 20:41:01 +00:00
|
|
|
unsigned int vncAllowHostAudio : 1;
|
2010-05-27 23:17:55 +00:00
|
|
|
unsigned int clearEmulatorCapabilities : 1;
|
2010-06-15 16:58:58 +00:00
|
|
|
unsigned int allowDiskFormatProbing : 1;
|
2010-10-20 08:25:05 +00:00
|
|
|
unsigned int setProcessName : 1;
|
2010-05-19 20:41:01 +00:00
|
|
|
|
2011-04-05 12:17:28 +00:00
|
|
|
int maxProcesses;
|
|
|
|
|
2008-02-27 04:35:08 +00:00
|
|
|
virCapsPtr caps;
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2011-05-12 12:54:07 +00:00
|
|
|
virDomainEventStatePtr domainEventState;
|
2009-03-03 12:03:44 +00:00
|
|
|
|
|
|
|
char *securityDriverName;
|
Refactor the security drivers to simplify usage
The current security driver usage requires horrible code like
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityHostdevLabel &&
driver->securityDriver->domainSetSecurityHostdevLabel(driver->securityDriver,
vm, hostdev) < 0)
This pair of checks for NULL clutters up the code, making the driver
calls 2 lines longer than they really need to be. The goal of the
patchset is to change the calling convention to simply
if (virSecurityManagerSetHostdevLabel(driver->securityDriver,
vm, hostdev) < 0)
The first check for 'driver->securityDriver' being NULL is removed
by introducing a 'no op' security driver that will always be present
if no real driver is enabled. This guarentees driver->securityDriver
!= NULL.
The second check for 'driver->securityDriver->domainSetSecurityHostdevLabel'
being non-NULL is hidden in a new abstraction called virSecurityManager.
This separates the driver callbacks, from main internal API. The addition
of a virSecurityManager object, that is separate from the virSecurityDriver
struct also allows for security drivers to carry state / configuration
information directly. Thus the DAC/Stack drivers from src/qemu which
used to pull config from 'struct qemud_driver' can now be moved into
the 'src/security' directory and store their config directly.
* src/qemu/qemu_conf.h, src/qemu/qemu_driver.c: Update to
use new virSecurityManager APIs
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_dac.h
src/qemu/qemu_security_stacked.c, src/qemu/qemu_security_stacked.h:
Move into src/security directory
* src/security/security_stack.c, src/security/security_stack.h,
src/security/security_dac.c, src/security/security_dac.h: Generic
versions of previous QEMU specific drivers
* src/security/security_apparmor.c, src/security/security_apparmor.h,
src/security/security_driver.c, src/security/security_driver.h,
src/security/security_selinux.c, src/security/security_selinux.h:
Update to take virSecurityManagerPtr object as the first param
in all callbacks
* src/security/security_nop.c, src/security/security_nop.h: Stub
implementation of all security driver APIs.
* src/security/security_manager.h, src/security/security_manager.c:
New internal API for invoking security drivers
* src/libvirt.c: Add missing debug for security APIs
2010-11-17 20:26:30 +00:00
|
|
|
virSecurityManagerPtr securityManager;
|
Compressed save image format for Qemu.
Implement a compressed save image format for qemu. While ideally
we would have the choice between compressed/non-compressed
available to the libvirt API, unfortunately there is no "flags"
parameter to the virDomainSave() API. Therefore, implement this
as a qemu.conf option. gzip, bzip2, and lzma are implemented, and
it should be very easy to implement additional compression
methods.
One open question is if/how we should detect the compression
binaries. One way to do it is to do compile-time setting of the
paths (via configure.in), but that doesn't seem like a great thing
to do. My preferred solution is not to detect at all;
when we go to run the commands that need them, if they
aren't available, or aren't available in one of the standard paths,
then we'll fail. That's also the solution implemented in this patch.
In the future, we'll have a more robust (managed) save/restore API,
at which time we can expose this functionality properly in the API.
V2: get rid of redundant dd command and just use >> to append data.
V3: Add back the missing pieces for the enum and bumping the save version.
V4: Make the compressed field in the save_header an int.
Implement LZMA compression.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-07 11:34:05 +00:00
|
|
|
|
|
|
|
char *saveImageFormat;
|
2010-10-28 07:31:46 +00:00
|
|
|
char *dumpImageFormat;
|
2009-08-17 14:05:23 +00:00
|
|
|
|
2010-12-08 06:19:17 +00:00
|
|
|
char *autoDumpPath;
|
|
|
|
|
2009-08-17 14:05:23 +00:00
|
|
|
pciDeviceList *activePciHostdevs;
|
2010-05-21 13:52:09 +00:00
|
|
|
|
|
|
|
virBitmapPtr reservedVNCPorts;
|
2010-10-29 12:18:29 +00:00
|
|
|
|
|
|
|
virSysinfoDefPtr hostsysinfo;
|
2010-10-26 14:04:46 +00:00
|
|
|
|
|
|
|
virLockManagerPluginPtr lockManager;
|
2011-06-23 09:37:57 +00:00
|
|
|
|
|
|
|
/* Mapping of 'char *uuidstr' -> virConnectPtr
|
|
|
|
* of guests which will be automatically killed
|
|
|
|
* when the virConnectPtr is closed*/
|
|
|
|
virHashTablePtr autodestroy;
|
2007-06-26 22:13:21 +00:00
|
|
|
};
|
|
|
|
|
2010-04-17 01:49:31 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2008-11-14 08:42:47 +00:00
|
|
|
/* Port numbers used for KVM migration. */
|
2010-03-09 18:22:22 +00:00
|
|
|
# define QEMUD_MIGRATION_FIRST_PORT 49152
|
|
|
|
# define QEMUD_MIGRATION_NUM_PORTS 64
|
2007-06-26 22:13:21 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define qemuReportError(code, ...) \
|
2011-04-16 08:30:22 +00:00
|
|
|
virReportErrorHelper(VIR_FROM_QEMU, code, __FILE__, \
|
2010-03-01 23:38:28 +00:00
|
|
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
2007-06-26 22:13:21 +00:00
|
|
|
|
|
|
|
|
2010-12-16 16:11:48 +00:00
|
|
|
void qemuDriverLock(struct qemud_driver *driver);
|
|
|
|
void qemuDriverUnlock(struct qemud_driver *driver);
|
2007-10-12 16:05:44 +00:00
|
|
|
int qemudLoadDriverConfig(struct qemud_driver *driver,
|
|
|
|
const char *filename);
|
2007-06-26 22:13:21 +00:00
|
|
|
|
2007-11-26 11:50:16 +00:00
|
|
|
#endif /* __QEMUD_CONF_H */
|