lxc_domain.h 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (C) 2010-2012 Red Hat, Inc.
 * Copyright IBM Corp. 2008
 *
 * lxc_domain.h: LXC domain helpers
 *
 * 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/>.
20 21
 */

22 23
#ifndef LIBVIRT_LXC_DOMAIN_H
# define LIBVIRT_LXC_DOMAIN_H
24

25
# include "vircgroup.h"
26
# include "lxc_conf.h"
27
# include "lxc_monitor.h"
28

29

I
ik.nitk 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
typedef enum {
    VIR_LXC_DOMAIN_NAMESPACE_SHARENET = 0,
    VIR_LXC_DOMAIN_NAMESPACE_SHAREIPC,
    VIR_LXC_DOMAIN_NAMESPACE_SHAREUTS,
    VIR_LXC_DOMAIN_NAMESPACE_LAST,
} virLXCDomainNamespace;

typedef enum {
    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE,
    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NAME,
    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_PID,
    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NETNS,

    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_LAST,
} virLXCDomainNamespaceSource;

VIR_ENUM_DECL(virLXCDomainNamespace)
VIR_ENUM_DECL(virLXCDomainNamespaceSource)

typedef struct _lxcDomainDef lxcDomainDef;
typedef lxcDomainDef *lxcDomainDefPtr;
struct _lxcDomainDef {
    int ns_source[VIR_LXC_DOMAIN_NAMESPACE_LAST]; /* virLXCDomainNamespaceSource */
    char *ns_val[VIR_LXC_DOMAIN_NAMESPACE_LAST];
};
55

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

/* Only 1 job is allowed at any time
 * A job includes *all* lxc.so api, even those just querying
 * information, not merely actions */

enum virLXCDomainJob {
    LXC_JOB_NONE = 0,      /* Always set to 0 for easy if (jobActive) conditions */
    LXC_JOB_QUERY,         /* Doesn't change any state */
    LXC_JOB_DESTROY,       /* Destroys the domain (cannot be masked out) */
    LXC_JOB_MODIFY,        /* May change state */
    LXC_JOB_LAST
};
VIR_ENUM_DECL(virLXCDomainJob)


struct virLXCDomainJobObj {
    virCond cond;                       /* Use to coordinate jobs */
    enum virLXCDomainJob active;        /* Currently running job */
    int owner;                          /* Thread which set current job */
};


78 79 80
typedef struct _virLXCDomainObjPrivate virLXCDomainObjPrivate;
typedef virLXCDomainObjPrivate *virLXCDomainObjPrivatePtr;
struct _virLXCDomainObjPrivate {
81
    virLXCMonitorPtr monitor;
82
    bool doneStopEvent;
83
    int stopReason;
84
    bool wantReboot;
85 86

    pid_t initpid;
87 88

    virCgroupPtr cgroup;
89
    char *machineName;
90 91

    struct virLXCDomainJobObj job;
92 93
};

I
ik.nitk 已提交
94
extern virDomainXMLNamespace virLXCDriverDomainXMLNamespace;
95
extern virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks;
96
extern virDomainDefParserConfig virLXCDriverDomainDefParserConfig;
97

98 99 100 101 102 103
int
virLXCDomainObjBeginJob(virLXCDriverPtr driver,
                       virDomainObjPtr obj,
                       enum virLXCDomainJob job)
    ATTRIBUTE_RETURN_CHECK;

104
void
105
virLXCDomainObjEndJob(virLXCDriverPtr driver,
106
                     virDomainObjPtr obj);
107 108


109 110 111
char *
virLXCDomainGetMachineName(virDomainDefPtr def, pid_t pid);

112
#endif /* LIBVIRT_LXC_DOMAIN_H */