lxc_conf.h 3.5 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
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
D
Daniel Veillard 已提交
20 21
 */

22 23
#ifndef LIBVIRT_LXC_CONF_H
# define LIBVIRT_LXC_CONF_H
D
Daniel Veillard 已提交
24

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

39 40
# define LXC_DRIVER_NAME "LXC"

41 42 43
# define LXC_CONFIG_DIR SYSCONFDIR "/libvirt/lxc"
# define LXC_STATE_DIR LOCALSTATEDIR "/run/libvirt/lxc"
# define LXC_LOG_DIR LOCALSTATEDIR "/log/libvirt/lxc"
44
# define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
45

46 47 48
typedef struct _virLXCDriver virLXCDriver;
typedef virLXCDriver *virLXCDriverPtr;

49 50 51 52 53 54 55 56 57 58
typedef struct _virLXCDriverConfig virLXCDriverConfig;
typedef virLXCDriverConfig *virLXCDriverConfigPtr;

struct _virLXCDriverConfig {
    virObject parent;

    char *configDir;
    char *autostartDir;
    char *stateDir;
    char *logDir;
59
    bool log_libvirtd;
60 61 62 63 64 65 66
    int have_netns;

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

67
struct _virLXCDriver {
68
    virMutex lock;
69

70 71
    /* Require lock to get reference on 'config',
     * then lockless thereafter */
72 73
    virLXCDriverConfigPtr config;

74 75
    /* Require lock to get a reference on the object,
     * lockless access thereafter */
76
    virCapsPtr caps;
77

78
    /* Immutable pointer, Immutable object */
79
    virDomainXMLOptionPtr xmlopt;
80

81
    /* Immutable pointer, lockless APIs*/
82 83
    virSysinfoDefPtr hostsysinfo;

84
    /* Atomic inc/dec only */
85
    unsigned int nactive;
86

87
    /* Immutable pointers. Caller must provide locking */
88 89 90
    virStateInhibitCallback inhibitCallback;
    void *inhibitOpaque;

91
    /* Immutable pointer, self-locking APIs */
92
    virDomainObjListPtr domains;
93

94
    virHostdevManagerPtr hostdevMgr;
95

96
    /* Immutable pointer, self-locking APIs */
97
    virObjectEventStatePtr domainEventState;
98

99
    /* Immutable pointer. self-locking APIs */
100 101
    virSecurityManagerPtr securityManager;

102 103
    /* Immutable pointer, self-locking APIs */
    virCloseCallbacksPtr closeCallbacks;
D
Daniel Veillard 已提交
104 105
};

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

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

124
#endif /* LIBVIRT_LXC_CONF_H */