module documentation

Xen hypervisors

Class XenHvmHypervisor Xen HVM hypervisor interface
Class XenHypervisor Xen generic hypervisor interface
Class XenPvmHypervisor Xen PVM hypervisor interface
Function WriteXenConfigEvents Undocumented
Constant VIF_BRIDGE_SCRIPT Undocumented
Constant XEN_COMMAND Undocumented
Constant XL_CONFIG_FILE Undocumented
Exception _InstanceCrashed Instance has reached a violent ending.
Function _ConfigureNIC Run the network configuration script for a specified NIC
Function _CreateConfigCpus Create a CPU config string for Xen's config file.
Function _GetAllInstanceList Return the list of instances including running and shutdown.
Function _GetConfigFileDiskData Get disk directives for Xen config file.
Function _GetNodeInfo Combines _MergeInstanceInfo and _ParseNodeInfo.
Function _GetRunningInstanceList Return the list of running instances.
Function _GetShutdownInstanceList Return the list of shutdown instances.
Function _IgnorePaused Removes information about whether a Xen state is paused from the state.
Function _InstanceDomID Get instance domain ID from instance info tuple.
Function _InstanceRunning Get instance runtime from instance info tuple.
Function _InstanceRuntime Get instance runtime from instance info tuple.
Function _IsCrashed Returns whether an instance is in the crashed Xen state.
Function _IsInstanceRunning Determine whether an instance is running.
Function _IsInstanceShutdown Determine whether the instance is shutdown.
Function _MergeInstanceInfo Updates node information from _ParseNodeInfo with instance info.
Function _ParseInstanceList Parses the output of listing instances by xen.
Function _ParseNodeInfo Return information about the node.
Function _QuoteCpuidField Add quotes around the CPUID field only if necessary.
Function _RunInstanceList Helper function for _GetAllInstanceList to retrieve the list of instances from xen.
Function _XenToHypervisorInstanceState Maps Xen states to hypervisor states.
Constant _DOM0_NAME Undocumented
Constant _FILE_DRIVER_MAP Undocumented
def WriteXenConfigEvents(config, hvp):

Undocumented

VIF_BRIDGE_SCRIPT =

Undocumented

Value
utils.PathJoin(pathutils.XEN_CONFIG_DIR, 'scripts/vif-bridge')
XEN_COMMAND: str =

Undocumented

Value
'xl'
XL_CONFIG_FILE =

Undocumented

Value
utils.PathJoin(pathutils.XEN_CONFIG_DIR, 'xen/xl.conf')
def _ConfigureNIC(instance, seq, nic, tap):

Run the network configuration script for a specified NIC

See hv_base.ConfigureNIC.

Parameters
instance:instance objectinstance we're acting on
seq:intnic sequence number
nic:nic objectnic we're acting on
tap:strthe host's tap interface this NIC corresponds to
def _CreateConfigCpus(cpu_mask):

Create a CPU config string for Xen's config file.

def _GetAllInstanceList(fn, include_node, delays, timeout):

Return the list of instances including running and shutdown.

See _RunInstanceList and _ParseInstanceList for parameter details.

def _GetConfigFileDiskData(block_devices, blockdev_prefix, _letters=_DISK_LETTERS):

Get disk directives for Xen config file.

This method builds the xen config disk directive according to the given disk_template and block_devices.

Parameters
block_devices

list of tuples (cfdev, rldev):

  • cfdev: dict containing ganeti config disk part
  • rldev: ganeti.block.bdev.BlockDev object
blockdev_prefixa string containing blockdevice prefix, e.g. "sd" for /dev/sda
_lettersUndocumented
Returns
string containing disk directive for xen instance config file
def _GetNodeInfo(info, instance_list):

Combines _MergeInstanceInfo and _ParseNodeInfo.

Parameters
infoUndocumented
instance_list:list of tupleslist of instance information; one tuple per instance
def _GetRunningInstanceList(fn, include_node, delays, timeout):

Return the list of running instances.

See _GetAllInstanceList for parameter details.

def _GetShutdownInstanceList(fn, include_node, delays, timeout):

Return the list of shutdown instances.

See _GetAllInstanceList for parameter details.

def _IgnorePaused(instance_info):

Removes information about whether a Xen state is paused from the state.

As it turns out, an instance can be reported as paused in almost any condition. Paused instances can be paused, running instances can be paused for scheduling, and any other condition can appear to be paused as a result of races or improbable conditions in Xen's status reporting. As we do not use Xen's pause commands in any way at the time, we can simply ignore the paused field and save ourselves a lot of trouble.

Should we ever use the pause commands, several samples would be needed before we could confirm the domain as paused.

def _InstanceDomID(info):

Get instance domain ID from instance info tuple.

Parameters
info:tupleinstance info as parsed by _ParseInstanceList()
Returns
int, instance domain ID
def _InstanceRunning(info):

Get instance runtime from instance info tuple.

Parameters
info:tupleinstance info as parsed by _ParseInstanceList()
Returns
bool
def _InstanceRuntime(info):

Get instance runtime from instance info tuple.

Parameters
info:tupleinstance info as parsed by _ParseInstanceList()
Returns
float value of instance runtime
def _IsCrashed(instance_info):

Returns whether an instance is in the crashed Xen state.

When a horrible misconfiguration happens to a Xen domain, it can crash, meaning that it encounters a violent ending. While this state usually flashes only temporarily before the domain is restarted, being able to check for it allows Ganeti not to act confused and do something about it.

def _IsInstanceRunning(instance_info):

Determine whether an instance is running.

An instance is running if it is in the following Xen states: running, blocked, paused, or dying (about to be destroyed / shutdown).

For some strange reason, Xen once printed 'rb----' which does not make any sense because an instance cannot be both running and blocked. Fortunately, for Ganeti 'running' or 'blocked' is the same as 'running'.

A state of nothing '------' means that the domain is runnable but it is not currently running. That means it is in the queue behind other domains waiting to be scheduled to run. http://old-list-archives.xenproject.org/xen-users/2007-06/msg00849.html

A dying instance is about to be removed, but it is still consuming resources, and counts as running.

Parameters
instance_info:stringInformation about instance, as supplied by Xen.
Returns
boolWhether an instance is running.
def _IsInstanceShutdown(instance_info):

Determine whether the instance is shutdown.

An instance is shutdown when a user shuts it down from within, and we do not remove domains to be able to detect that.

The dying state has been added as a precaution, as Xen's status reporting is weird.

def _MergeInstanceInfo(info, instance_list):

Updates node information from _ParseNodeInfo with instance info.

Parameters
info:dictResult from _ParseNodeInfo
instance_list:list of tupleslist of instance information; one tuple per instance
Returns
dictUndocumented
def _ParseInstanceList(lines, include_node):

Parses the output of listing instances by xen.

Parameters
lines:listResult of retrieving the instance list from xen
include_node:booleanIf True, return information for Dom0
Returns
list of tuple containing (name, id, memory, vcpus, state, time spent)
def _ParseNodeInfo(info):

Return information about the node.

Returns

a dict with the following keys (memory values in MiB):

  • memory_total: the total memory size on the node
  • memory_free: the available memory on the node for instances
  • nr_cpus: total number of CPUs
  • nr_nodes: in a NUMA system, the number of domains
  • nr_sockets: the number of physical CPU sockets in the node
  • hv_version: the hypervisor version in the form (major, minor)
def _QuoteCpuidField(data):

Add quotes around the CPUID field only if necessary.

Xen CPUID fields come in two shapes: LIBXL strings, which need quotes around them, and lists of XEND strings, which don't.

Parameters
dataEither type of parameter.
Returns
The quoted version thereof.
def _RunInstanceList(fn, instance_list_errors):

Helper function for _GetAllInstanceList to retrieve the list of instances from xen.

Parameters
fn:callableFunction to query xen for the list of instances
instance_list_errors:listError list
Returns
listUndocumented
def _XenToHypervisorInstanceState(instance_info):

Maps Xen states to hypervisor states.

Parameters
instance_info:stringInformation about instance, as supplied by Xen.
Returns
hv_base.HvInstanceStateUndocumented
_DOM0_NAME: str =

Undocumented

Value
'Domain-0'
_FILE_DRIVER_MAP =

Undocumented

Value
{constants.FD_LOOP: 'file',
 constants.FD_BLKTAP: 'tap:aio',
 constants.FD_BLKTAP2: 'tap2:tapdisk:aio'}