2008-03-21 15:03:37 +00:00
|
|
|
/*
|
2013-05-31 17:52:51 +00:00
|
|
|
* Copyright (C) 2010, 2013 Red Hat, Inc.
|
2008-03-21 15:03:37 +00:00
|
|
|
* Copyright IBM Corp. 2008
|
|
|
|
*
|
|
|
|
* lxc_conf.h: header file for linux container config functions
|
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-03-21 15:03:37 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "libvirt_internal.h"
|
|
|
|
#include "domain_conf.h"
|
|
|
|
#include "domain_event.h"
|
|
|
|
#include "capabilities.h"
|
|
|
|
#include "virthread.h"
|
|
|
|
#include "security/security_manager.h"
|
|
|
|
#include "configmake.h"
|
|
|
|
#include "vircgroup.h"
|
|
|
|
#include "virsysinfo.h"
|
|
|
|
#include "virusb.h"
|
|
|
|
#include "virclosecallbacks.h"
|
|
|
|
#include "virhostdev.h"
|
|
|
|
|
|
|
|
#define LXC_DRIVER_NAME "LXC"
|
|
|
|
|
|
|
|
#define LXC_CONFIG_DIR SYSCONFDIR "/libvirt/lxc"
|
2019-08-20 15:05:12 +00:00
|
|
|
#define LXC_STATE_DIR RUNSTATEDIR "/libvirt/lxc"
|
2019-06-18 16:12:32 +00:00
|
|
|
#define LXC_LOG_DIR LOCALSTATEDIR "/log/libvirt/lxc"
|
|
|
|
#define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
|
2008-08-20 20:55:32 +00:00
|
|
|
|
2012-07-13 11:56:29 +00:00
|
|
|
typedef struct _virLXCDriver virLXCDriver;
|
|
|
|
typedef virLXCDriver *virLXCDriverPtr;
|
|
|
|
|
2013-07-16 15:45:05 +00:00
|
|
|
typedef struct _virLXCDriverConfig virLXCDriverConfig;
|
|
|
|
typedef virLXCDriverConfig *virLXCDriverConfigPtr;
|
|
|
|
|
|
|
|
struct _virLXCDriverConfig {
|
|
|
|
virObject parent;
|
|
|
|
|
|
|
|
char *configDir;
|
|
|
|
char *autostartDir;
|
|
|
|
char *stateDir;
|
|
|
|
char *logDir;
|
2016-07-08 12:51:49 +00:00
|
|
|
bool log_libvirtd;
|
2013-07-16 15:45:05 +00:00
|
|
|
int have_netns;
|
|
|
|
|
|
|
|
char *securityDriverName;
|
|
|
|
bool securityDefaultConfined;
|
|
|
|
bool securityRequireConfined;
|
|
|
|
};
|
|
|
|
|
2012-07-13 11:56:29 +00:00
|
|
|
struct _virLXCDriver {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 21:12:41 +00:00
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Require lock to get reference on 'config',
|
|
|
|
* then lockless thereafter */
|
2013-07-16 15:45:05 +00:00
|
|
|
virLXCDriverConfigPtr config;
|
|
|
|
|
2019-05-23 10:34:08 +00:00
|
|
|
/* pid file FD, ensures two copies of the driver can't use the same root */
|
|
|
|
int lockFD;
|
|
|
|
|
2013-07-15 09:43:10 +00:00
|
|
|
/* Require lock to get a reference on the object,
|
|
|
|
* lockless access thereafter */
|
2008-08-13 12:50:55 +00:00
|
|
|
virCapsPtr caps;
|
2013-07-16 15:45:05 +00:00
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Immutable pointer, Immutable object */
|
2013-03-31 18:03:42 +00:00
|
|
|
virDomainXMLOptionPtr xmlopt;
|
2008-08-13 12:50:55 +00:00
|
|
|
|
2020-01-24 20:30:04 +00:00
|
|
|
/* Immutable pointer, lockless APIs */
|
2013-04-03 17:55:20 +00:00
|
|
|
virSysinfoDefPtr hostsysinfo;
|
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Atomic inc/dec only */
|
2013-07-16 17:05:06 +00:00
|
|
|
unsigned int nactive;
|
2013-07-16 15:45:05 +00:00
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Immutable pointers. Caller must provide locking */
|
2012-10-31 19:03:55 +00:00
|
|
|
virStateInhibitCallback inhibitCallback;
|
|
|
|
void *inhibitOpaque;
|
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
2013-01-11 16:04:47 +00:00
|
|
|
virDomainObjListPtr domains;
|
2009-07-06 15:04:36 +00:00
|
|
|
|
2014-03-05 10:49:58 +00:00
|
|
|
virHostdevManagerPtr hostdevMgr;
|
2012-11-23 14:46:18 +00:00
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStatePtr domainEventState;
|
2011-07-13 11:21:54 +00:00
|
|
|
|
2013-07-16 17:20:24 +00:00
|
|
|
/* Immutable pointer. self-locking APIs */
|
2012-01-25 14:12:53 +00:00
|
|
|
virSecurityManagerPtr securityManager;
|
|
|
|
|
2013-07-15 17:08:11 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
|
|
|
virCloseCallbacksPtr closeCallbacks;
|
2008-03-21 15:03:37 +00:00
|
|
|
};
|
|
|
|
|
2013-07-16 15:45:05 +00:00
|
|
|
virLXCDriverConfigPtr virLXCDriverConfigNew(void);
|
|
|
|
virLXCDriverConfigPtr virLXCDriverGetConfig(virLXCDriverPtr driver);
|
|
|
|
int virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg,
|
|
|
|
const char *filename);
|
2013-07-15 09:43:10 +00:00
|
|
|
virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver);
|
|
|
|
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
|
|
|
bool refresh);
|
2019-12-03 10:49:49 +00:00
|
|
|
virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriverPtr driver);
|
2008-03-21 15:03:37 +00:00
|
|
|
|
2012-07-13 11:56:29 +00:00
|
|
|
static inline void lxcDriverLock(virLXCDriverPtr driver)
|
2012-07-13 11:39:29 +00:00
|
|
|
{
|
|
|
|
virMutexLock(&driver->lock);
|
|
|
|
}
|
2012-07-13 11:56:29 +00:00
|
|
|
static inline void lxcDriverUnlock(virLXCDriverPtr driver)
|
2012-07-13 11:39:29 +00:00
|
|
|
{
|
|
|
|
virMutexUnlock(&driver->lock);
|
|
|
|
}
|