2012-07-13 10:16:23 +00:00
|
|
|
/*
|
|
|
|
* 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
|
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/>.
|
2012-07-13 10:16:23 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:32 +00:00
|
|
|
#pragma once
|
2012-07-13 10:16:23 +00:00
|
|
|
|
2019-06-18 16:12:32 +00:00
|
|
|
#include "vircgroup.h"
|
|
|
|
#include "lxc_conf.h"
|
|
|
|
#include "lxc_monitor.h"
|
|
|
|
#include "virenum.h"
|
2012-07-17 10:55:38 +00:00
|
|
|
|
2016-05-16 21:36:47 +00:00
|
|
|
|
2015-08-20 13:46:17 +00:00
|
|
|
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;
|
|
|
|
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virLXCDomainNamespace);
|
|
|
|
VIR_ENUM_DECL(virLXCDomainNamespaceSource);
|
2015-08-20 13:46:17 +00:00
|
|
|
|
|
|
|
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];
|
|
|
|
};
|
2012-07-13 10:16:23 +00:00
|
|
|
|
2016-05-16 21:36:47 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
};
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virLXCDomainJob);
|
2016-05-16 21:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct virLXCDomainJobObj {
|
|
|
|
virCond cond; /* Use to coordinate jobs */
|
|
|
|
enum virLXCDomainJob active; /* Currently running job */
|
|
|
|
int owner; /* Thread which set current job */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-18 16:20:46 +00:00
|
|
|
typedef struct _virLXCDomainObjPrivate virLXCDomainObjPrivate;
|
|
|
|
typedef virLXCDomainObjPrivate *virLXCDomainObjPrivatePtr;
|
|
|
|
struct _virLXCDomainObjPrivate {
|
2012-07-17 11:14:35 +00:00
|
|
|
virLXCMonitorPtr monitor;
|
2012-07-17 10:55:38 +00:00
|
|
|
bool doneStopEvent;
|
2012-07-17 14:54:08 +00:00
|
|
|
int stopReason;
|
2012-07-23 11:25:37 +00:00
|
|
|
bool wantReboot;
|
2012-11-22 17:15:54 +00:00
|
|
|
|
|
|
|
pid_t initpid;
|
2013-03-21 14:40:29 +00:00
|
|
|
|
|
|
|
virCgroupPtr cgroup;
|
2016-02-01 15:50:54 +00:00
|
|
|
char *machineName;
|
2016-05-16 21:36:47 +00:00
|
|
|
|
|
|
|
struct virLXCDomainJobObj job;
|
2012-07-13 10:16:23 +00:00
|
|
|
};
|
|
|
|
|
2019-08-20 21:39:24 +00:00
|
|
|
extern virXMLNamespace virLXCDriverDomainXMLNamespace;
|
2013-03-05 15:17:24 +00:00
|
|
|
extern virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks;
|
2013-03-11 11:12:08 +00:00
|
|
|
extern virDomainDefParserConfig virLXCDriverDomainDefParserConfig;
|
2012-07-13 10:16:23 +00:00
|
|
|
|
2016-05-16 21:36:47 +00:00
|
|
|
int
|
|
|
|
virLXCDomainObjBeginJob(virLXCDriverPtr driver,
|
|
|
|
virDomainObjPtr obj,
|
|
|
|
enum virLXCDomainJob job)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2016-05-16 21:36:47 +00:00
|
|
|
|
2016-05-20 15:17:01 +00:00
|
|
|
void
|
2016-05-16 21:36:47 +00:00
|
|
|
virLXCDomainObjEndJob(virLXCDriverPtr driver,
|
2016-05-20 15:17:01 +00:00
|
|
|
virDomainObjPtr obj);
|
2016-05-16 21:36:47 +00:00
|
|
|
|
|
|
|
|
2017-07-21 13:51:03 +00:00
|
|
|
char *
|
|
|
|
virLXCDomainGetMachineName(virDomainDefPtr def, pid_t pid);
|
|
|
|
|
2019-01-25 11:42:54 +00:00
|
|
|
int
|
|
|
|
virLXCDomainSetRunlevel(virDomainObjPtr vm,
|
|
|
|
int runlevel);
|