lxc_conf.h 3.6 KB
Newer Older
D
Daniel Veillard 已提交
1
/*
2
 * Copyright (C) 2010, 2013 Red Hat, Inc.
D
Daniel Veillard 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * Copyright IBM Corp. 2008
 *
 * lxc_conf.h: header file for linux container config functions
 *
 * Authors:
 *  David L. Leskovec <dlesko at linux.vnet.ibm.com>
 *
 * 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
21
 * License along with this library.  If not, see
O
Osier Yang 已提交
22
 * <http://www.gnu.org/licenses/>.
D
Daniel Veillard 已提交
23 24 25
 */

#ifndef LXC_CONF_H
26
# define LXC_CONF_H
D
Daniel Veillard 已提交
27

28
# include "internal.h"
29
# include "libvirt_internal.h"
30 31 32
# include "domain_conf.h"
# include "domain_event.h"
# include "capabilities.h"
33
# include "virthread.h"
34
# include "security/security_manager.h"
35
# include "configmake.h"
36
# include "vircgroup.h"
37
# include "virsysinfo.h"
38
# include "virusb.h"
39
# include "virclosecallbacks.h"
40
# include "virhostdev.h"
D
Daniel Veillard 已提交
41

42 43
# define LXC_DRIVER_NAME "LXC"

44 45 46
# define LXC_CONFIG_DIR SYSCONFDIR "/libvirt/lxc"
# define LXC_STATE_DIR LOCALSTATEDIR "/run/libvirt/lxc"
# define LXC_LOG_DIR LOCALSTATEDIR "/log/libvirt/lxc"
47
# define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
48

49 50 51
typedef struct _virLXCDriver virLXCDriver;
typedef virLXCDriver *virLXCDriverPtr;

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
typedef struct _virLXCDriverConfig virLXCDriverConfig;
typedef virLXCDriverConfig *virLXCDriverConfigPtr;

struct _virLXCDriverConfig {
    virObject parent;

    char *configDir;
    char *autostartDir;
    char *stateDir;
    char *logDir;
    int log_libvirtd;
    int have_netns;

    char *securityDriverName;
    bool securityDefaultConfined;
    bool securityRequireConfined;
};

70
struct _virLXCDriver {
71
    virMutex lock;
72

73 74
    /* Require lock to get reference on 'config',
     * then lockless thereafter */
75 76
    virLXCDriverConfigPtr config;

77 78
    /* Require lock to get a reference on the object,
     * lockless access thereafter */
79
    virCapsPtr caps;
80

81
    /* Immutable pointer, Immutable object */
82
    virDomainXMLOptionPtr xmlopt;
83

84
    /* Immutable pointer, lockless APIs*/
85 86
    virSysinfoDefPtr hostsysinfo;

87
    /* Atomic inc/dec only */
88
    unsigned int nactive;
89

90
    /* Immutable pointers. Caller must provide locking */
91 92 93
    virStateInhibitCallback inhibitCallback;
    void *inhibitOpaque;

94
    /* Immutable pointer, self-locking APIs */
95
    virDomainObjListPtr domains;
96

97
    virHostdevManagerPtr hostdevMgr;
98

99
    /* Immutable pointer, self-locking APIs */
100
    virObjectEventStatePtr domainEventState;
101

102
    /* Immutable pointer. self-locking APIs */
103 104
    virSecurityManagerPtr securityManager;

105 106
    /* Immutable pointer, self-locking APIs */
    virCloseCallbacksPtr closeCallbacks;
D
Daniel Veillard 已提交
107 108
};

109 110 111 112
virLXCDriverConfigPtr virLXCDriverConfigNew(void);
virLXCDriverConfigPtr virLXCDriverGetConfig(virLXCDriverPtr driver);
int virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg,
                           const char *filename);
113 114 115
virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver);
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
                                       bool refresh);
116
virDomainXMLOptionPtr lxcDomainXMLConfInit(void);
D
Daniel Veillard 已提交
117

118
static inline void lxcDriverLock(virLXCDriverPtr driver)
119 120 121
{
    virMutexLock(&driver->lock);
}
122
static inline void lxcDriverUnlock(virLXCDriverPtr driver)
123 124 125 126
{
    virMutexUnlock(&driver->lock);
}

D
Daniel Veillard 已提交
127
#endif /* LXC_CONF_H */