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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#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"
41
#define LXC_STATE_DIR RUNSTATEDIR "/libvirt/lxc"
42 43
#define LXC_LOG_DIR LOCALSTATEDIR "/log/libvirt/lxc"
#define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
44

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

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

struct _virLXCDriverConfig {
    virObject parent;

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

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

66
struct _virLXCDriver {
67
    virMutex lock;
68

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

73 74 75
    /* pid file FD, ensures two copies of the driver can't use the same root */
    int lockFD;

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

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

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

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

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

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

96
    virHostdevManagerPtr hostdevMgr;
97

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

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

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

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

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