The nova.virt.hardware Module

class InstanceInfo(state=None, max_mem_kb=0, mem_kb=0, num_cpu=0, cpu_time_ns=0, id=None)

Bases: object

format_cpu_spec(cpuset, allow_ranges=True)

Format a libvirt CPU range specification.

Parameters:cpuset – set (or list) of CPU indexes

Format a set/list of CPU indexes as a libvirt CPU range specification. It allow_ranges is true, it will try to detect continuous ranges of CPUs, otherwise it will just list each CPU index explicitly.

Returns:a formatted CPU range string
get_best_cpu_topology(flavor, image_meta, allow_threads=True, numa_topology=None)

Get best CPU topology according to settings

Parameters:
  • flavor – Flavor object to query extra specs from
  • image_meta – nova.objects.ImageMeta object instance
  • allow_threads – if the hypervisor supports CPU threads
  • numa_topology – InstanceNUMATopology object that may contain additional topology constraints (such as threading information) that we should consider

Look at the properties set in the flavor extra specs and the image metadata and build up a list of all possible valid CPU topologies that can be used in the guest. Then return the best topology to use

Returns:a nova.objects.VirtCPUTopology instance for best topology
get_host_numa_usage_from_instance(host, instance, free=False, never_serialize_result=False)

Calculate new ‘numa_usage’ of ‘host’ from ‘instance’ NUMA usage

This is a convenience method to help us handle the fact that we use several different types throughout the code (ComputeNode and Instance objects, dicts, scheduler HostState) which may have both json and deserialized versions of objects.numa classes.

Handles all the complexity without polluting the class method with it.

Parameters:
  • host – nova.objects.ComputeNode instance, or a db object or dict
  • instance – nova.objects.Instance instance, or a db object or dict
  • free – if True the returned topology will have it’s usage decreased instead.
  • never_serialize_result – if True result will always be an instance of objects.NUMATopology class.
Returns:

numa_usage in the format it was on the host or objects.NUMATopology instance if never_serialize_result was True

get_number_of_serial_ports(flavor, image_meta)

Get the number of serial consoles from the flavor or image

Parameters:
  • flavor – Flavor object to read extra specs from
  • image_meta – nova.objects.ImageMeta object instance

If flavor extra specs is not set, then any image meta value is permitted. If flavor extra specs is set, then this provides the default serial port count. The image meta is permitted to override the extra specs, but only with a lower value. ie

  • flavor hw:serial_port_count=4 VM gets 4 serial ports
  • flavor hw:serial_port_count=4 and image hw_serial_port_count=2 VM gets 2 serial ports
  • image hw_serial_port_count=6 VM gets 6 serial ports
  • flavor hw:serial_port_count=4 and image hw_serial_port_count=6 Abort guest boot - forbidden to exceed flavor value
Returns:number of serial ports
get_vcpu_pin_set()

Parsing vcpu_pin_set config.

Returns a set of pcpu ids can be used by instances.

host_topology_and_format_from_host(host)

Convenience method for getting the numa_topology out of hosts

Since we may get a host as either a dict, a db object, or an actual ComputeNode object, or an instance of HostState class, this makes sure we get beck either None, or an instance of objects.NUMATopology class.

Returns:A two-tuple, first element is the topology itself or None, second is a boolean set to True if topology was in JSON format.
instance_topology_from_instance(instance)

Convenience method for getting the numa_topology out of instances

Since we may get an Instance as either a dict, a db object, or an actual Instance object, this makes sure we get beck either None, or an instance of objects.InstanceNUMATopology class.

is_realtime_enabled(flavor)
numa_fit_instance_to_host(host_topology, instance_topology, limits=None, pci_requests=None, pci_stats=None)

Fit the instance topology onto the host topology given the limits

Parameters:
  • host_topology – objects.NUMATopology object to fit an instance on
  • instance_topology – objects.InstanceNUMATopology to be fitted
  • limits – objects.NUMATopologyLimits that defines limits
  • pci_requests – instance pci_requests
  • pci_stats – pci_stats for the host

Given a host and instance topology and optionally limits - this method will attempt to fit instance cells onto all permutations of host cells by calling the _numa_fit_instance_cell method, and return a new InstanceNUMATopology with it’s cell ids set to host cell id’s of the first successful permutation, or None.

numa_get_constraints(flavor, image_meta)

Return topology related to input request

Parameters:
  • flavor – Flavor object to read extra specs from
  • image_meta – nova.objects.ImageMeta object instance

May raise exception.ImageNUMATopologyIncomplete() if the image properties are not correctly specified, or exception.ImageNUMATopologyForbidden if an attempt is made to override flavor settings with image properties.

Returns:InstanceNUMATopology or None
numa_usage_from_instances(host, instances, free=False)

Get host topology usage

Parameters:
  • host – objects.NUMATopology with usage information
  • instances – list of objects.InstanceNUMATopology
  • free – If True usage of the host will be decreased

Sum the usage from all @instances to report the overall host topology usage

Returns:objects.NUMATopology including usage information
parse_cpu_spec(spec)

Parse a CPU set specification.

Parameters:spec – cpu set string eg “1-4,^3,6”

Each element in the list is either a single CPU number, a range of CPU numbers, or a caret followed by a CPU number to be excluded from a previous range.

Returns:a set of CPU indexes
vcpus_realtime_topology(vcpus_set, flavor, image)

Partitions vcpus used for realtime and ‘normal’ vcpus.

According to a mask specified from flavor or image, returns set of vcpus configured for realtime scheduler and set running as a ‘normal’ vcpus.

Previous topic

The nova.virt.firewall Module

Next topic

The nova.virt.hyperv.constants Module

Project Source

This Page