#include <zone.hpp>
Public Types | |
typedef netdev::Attrs | NetdevAttrs |
typedef std::function< void(bool succeeded)> | StartAsyncResultCallback |
Public Member Functions | |
Zone (const std::string &zoneId, const std::string &zonesPath, const std::string &zoneTemplatePath, const std::string &dbPath, const std::string &zoneTemplateDir, const std::string &baseRunMountPointPath) | |
Zone constructor. More... | |
Zone (const Zone &)=delete | |
Zone & | operator= (const Zone &)=delete |
~Zone () | |
const std::string & | getId () const |
Get the zone id. More... | |
int | getPrivilege () const |
Get the zone privilege. More... | |
void | restore () |
Restore zone to the previous state. More... | |
void | start () |
Boot the zone to the background. More... | |
void | stop (bool saveState) |
Try to shutdown the zone, if failed, destroy it. More... | |
bool | activateVT () |
Activate this zone's VT. More... | |
void | goForeground () |
Setup this zone to be put in the foreground. More... | |
void | goBackground () |
Setup this zone to be put in the background. More... | |
void | setDetachOnExit () |
Set if zone should be detached on exit. More... | |
void | setDestroyOnExit () |
Set if zone should be destroyed on exit. More... | |
bool | isRunning () |
bool | isStopped () |
Check if the zone is stopped. More... | |
void | suspend () |
Suspends an active zone, the process is frozen without further access to CPU resources and I/O, but the memory used by the zone at the hypervisor level will stay allocated. More... | |
void | resume () |
Resume zone. More... | |
bool | isPaused () |
bool | isSwitchToDefaultAfterTimeoutAllowed () const |
int | getVT () const |
Get id of VT. More... | |
int | createFile (const std::string &path, const std::int32_t flags, const std::int32_t mode) |
Create file inside zone, return its fd. More... | |
std::string | declareFile (const int32_t &type, const std::string &path, const int32_t &flags, const int32_t &mode) |
Declare file, directory or pipe that will be created while zone startup. More... | |
std::string | declareMount (const std::string &source, const std::string &target, const std::string &type, const int64_t &flags, const std::string &data) |
Declare mount that will be created while zone startup. More... | |
std::string | declareLink (const std::string &source, const std::string &target) |
Declare link that will be created while zone startup. More... | |
std::vector< std::string > | getDeclarations () const |
Gets all declarations. More... | |
void | removeDeclaration (const std::string &declarationId) |
Remove declaration. More... | |
std::string | getRootPath () const |
Get zone root path. More... | |
void | createNetdevVeth (const std::string &zoneDev, const std::string &hostDev) |
Create veth network device. More... | |
void | createNetdevMacvlan (const std::string &zoneDev, const std::string &hostDev, const uint32_t &mode) |
Create macvlan network device. More... | |
void | moveNetdev (const std::string &devId) |
Move network device to zone. More... | |
void | destroyNetdev (const std::string &devId) |
Destroy network device in zone. More... | |
void | setNetdevAttrs (const std::string &netdev, const NetdevAttrs &attrs) |
Set network device attributes. More... | |
NetdevAttrs | getNetdevAttrs (const std::string &netdev) |
Get network device attributes. More... | |
std::vector< std::string > | getNetdevList () |
Get network device list. More... | |
void | deleteNetdevIpAddress (const std::string &netdev, const std::string &ip) |
Remove ipv4/ipv6 address from network device. More... | |
void | setSchedulerLevel (SchedulerLevel sched) |
Sets the zones scheduler CFS quota. More... | |
std::int64_t | getSchedulerQuota () |
Private Member Functions | |
void | onNameLostCallback () |
void | saveDynamicConfig () |
void | updateRequestedState (const std::string &state) |
void | setSchedulerParams (std::uint64_t cpuShares, std::uint64_t vcpuPeriod, std::int64_t vcpuQuota) |
Private Attributes | |
ZoneConfig | mConfig |
ZoneDynamicConfig | mDynamicConfig |
std::unique_ptr< ZoneProvision > | mProvision |
std::recursive_mutex | mReconnectMutex |
std::string | mRunMountPoint |
std::string | mRootPath |
std::string | mDbPath |
lxc::LxcZone | mZone |
const std::string | mId |
bool | mDetachOnExit |
bool | mDestroyOnExit |
typedef netdev::Attrs vasum::Zone::NetdevAttrs |
typedef std::function<void(bool succeeded)> vasum::Zone::StartAsyncResultCallback |
vasum::Zone::Zone | ( | const std::string & | zoneId, |
const std::string & | zonesPath, | ||
const std::string & | zoneTemplatePath, | ||
const std::string & | dbPath, | ||
const std::string & | zoneTemplateDir, | ||
const std::string & | baseRunMountPointPath | ||
) |
Zone constructor.
zoneId | zone id |
zonesPath | directory where zones are defined (configs, rootfs etc) |
zoneTemplatePath | path for zones config template |
dbPath | path to dynamic config db file |
zoneTemplateDir | directory where templates are stored |
baseRunMountPointPath | base directory for run mount point |
|
delete |
vasum::Zone::~Zone | ( | ) |
bool vasum::Zone::activateVT | ( | ) |
Activate this zone's VT.
int vasum::Zone::createFile | ( | const std::string & | path, |
const std::int32_t | flags, | ||
const std::int32_t | mode | ||
) |
Create file inside zone, return its fd.
path | Path where the file should be created |
flags | Flags used when opening the file. See common/lxc/zone.hpp for more info. |
mode | Permissions with which file is created |
void vasum::Zone::createNetdevMacvlan | ( | const std::string & | zoneDev, |
const std::string & | hostDev, | ||
const uint32_t & | mode | ||
) |
Create macvlan network device.
void vasum::Zone::createNetdevVeth | ( | const std::string & | zoneDev, |
const std::string & | hostDev | ||
) |
Create veth network device.
std::string vasum::Zone::declareFile | ( | const int32_t & | type, |
const std::string & | path, | ||
const int32_t & | flags, | ||
const int32_t & | mode | ||
) |
Declare file, directory or pipe that will be created while zone startup.
std::string vasum::Zone::declareLink | ( | const std::string & | source, |
const std::string & | target | ||
) |
Declare link that will be created while zone startup.
std::string vasum::Zone::declareMount | ( | const std::string & | source, |
const std::string & | target, | ||
const std::string & | type, | ||
const int64_t & | flags, | ||
const std::string & | data | ||
) |
Declare mount that will be created while zone startup.
void vasum::Zone::deleteNetdevIpAddress | ( | const std::string & | netdev, |
const std::string & | ip | ||
) |
Remove ipv4/ipv6 address from network device.
void vasum::Zone::destroyNetdev | ( | const std::string & | devId | ) |
Destroy network device in zone.
std::vector< std::string > vasum::Zone::getDeclarations | ( | ) | const |
Gets all declarations.
const std::string & vasum::Zone::getId | ( | ) | const |
Get the zone id.
Zone::NetdevAttrs vasum::Zone::getNetdevAttrs | ( | const std::string & | netdev | ) |
Get network device attributes.
std::vector< std::string > vasum::Zone::getNetdevList | ( | ) |
Get network device list.
int vasum::Zone::getPrivilege | ( | ) | const |
Get the zone privilege.
std::string vasum::Zone::getRootPath | ( | ) | const |
Get zone root path.
std::int64_t vasum::Zone::getSchedulerQuota | ( | ) |
int vasum::Zone::getVT | ( | ) | const |
Get id of VT.
void vasum::Zone::goBackground | ( | ) |
Setup this zone to be put in the background.
I.e. set appropriate scheduler level.
void vasum::Zone::goForeground | ( | ) |
Setup this zone to be put in the foreground.
I.e. set appropriate scheduler level.
bool vasum::Zone::isPaused | ( | ) |
bool vasum::Zone::isRunning | ( | ) |
bool vasum::Zone::isStopped | ( | ) |
Check if the zone is stopped.
It's NOT equivalent to !isRunning, because it checks different internal zone states. There are other states, (e.g. paused) when the zone isn't running nor stopped.
bool vasum::Zone::isSwitchToDefaultAfterTimeoutAllowed | ( | ) | const |
void vasum::Zone::moveNetdev | ( | const std::string & | devId | ) |
Move network device to zone.
|
private |
void vasum::Zone::removeDeclaration | ( | const std::string & | declarationId | ) |
Remove declaration.
void vasum::Zone::restore | ( | ) |
Restore zone to the previous state.
void vasum::Zone::resume | ( | ) |
Resume zone.
|
private |
void vasum::Zone::setDestroyOnExit | ( | ) |
Set if zone should be destroyed on exit.
void vasum::Zone::setDetachOnExit | ( | ) |
Set if zone should be detached on exit.
void vasum::Zone::setNetdevAttrs | ( | const std::string & | netdev, |
const NetdevAttrs & | attrs | ||
) |
Set network device attributes.
void vasum::Zone::setSchedulerLevel | ( | SchedulerLevel | sched | ) |
Sets the zones scheduler CFS quota.
|
private |
void vasum::Zone::start | ( | ) |
Boot the zone to the background.
void vasum::Zone::stop | ( | bool | saveState | ) |
Try to shutdown the zone, if failed, destroy it.
saveState | save zone's state |
void vasum::Zone::suspend | ( | ) |
Suspends an active zone, the process is frozen without further access to CPU resources and I/O, but the memory used by the zone at the hypervisor level will stay allocated.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |