The nova.virt.libvirt.blockinfo Module

Handling of block device information and mapping.

This module contains helper methods for interpreting the block device information and determining the suitable mapping to guest devices and libvirt XML.

Throughout these methods there are a number of standard variables / types used

  • ‘mapping’: a dict contains the storage device mapping.

    For the default disk types it will contain the following keys & values:

    ‘disk’ -> disk_info ‘disk.rescue’ -> disk_info ‘disk.local’ -> disk_info ‘disk.swap’ -> disk_info ‘disk.config’ -> disk_info

    If any of the default disks are overridden by the block device info mappings, the hash value will be None

    For any ephemeral device there will also be a dict entry

    ‘disk.eph$NUM’ -> disk_info

    For any volume device there will also be a dict entry:

    $path -> disk_info

    Finally a special key will refer to the root device:

    ‘root’ -> disk_info

  • ‘disk_info’: a dict specifying disk configuration

    It contains the following 3 required fields

    bus (disk_bus), dev (disk_dev), type (device_type)

    and possibly these optional fields: (‘format’, ‘boot_index’)

  • ‘disk_bus’: the guest bus type (‘ide’, ‘virtio’, ‘scsi’, etc)

  • ‘disk_dev’: the device name ‘vda’, ‘hdc’, ‘sdf’, ‘xvde’ etc

  • ‘device_type’: type of device eg ‘disk’, ‘cdrom’, ‘floppy’

  • ‘format’: Which format to apply to the device if applicable

  • ‘boot_index’: Number designating the boot order of the device

default_device_names(virt_type, context, instance, block_device_info, image_meta)
find_disk_dev_for_disk_bus(mapping, bus, last_device=False, assigned_devices=None)

Identify a free disk dev name for a bus.

Determines the possible disk dev names for the bus, and then checks them in order until it identifies one that is not yet used in the disk mapping. If ‘last_device’ is set, it will only consider the last available disk dev name.

Returns the chosen disk_dev name, or raises an exception if none is available.

get_boot_order(disk_info)
get_config_drive_type()

Determine the type of config drive.

If config_drive_format is set to iso9660 then the config drive will be ‘cdrom’, otherwise ‘disk’.

Returns a string indicating the config drive type.

get_dev_count_for_disk_bus(disk_bus)

Determine the number disks supported.

Determine how many disks can be supported in a single VM for a particular disk bus.

Returns the number of disks supported.

get_dev_prefix_for_disk_bus(disk_bus)

Determine the dev prefix for a disk bus.

Determine the dev prefix to be combined with a disk number to fix a disk_dev. eg ‘hd’ for ‘ide’ bus can be used to form a disk dev ‘hda’

Returns the dev prefix or raises an exception if the disk bus is unknown.

get_device_name(bdm)

Get the device name if present regardless of the bdm format.

get_disk_bus_for_device_type(instance, virt_type, image_meta, device_type='disk')

Determine the best disk bus to use for a device type.

Considering the currently configured virtualization type, return the optimal disk_bus to use for a given device type. For example, for a disk on KVM it will return ‘virtio’, while for a CDROM it will return ‘ide’ on x86_64 and ‘scsi’ on ppc64.

Returns the disk_bus, or returns None if the device type is not supported for this virtualization

get_disk_bus_for_disk_dev(virt_type, disk_dev)

Determine the disk bus for a disk device.

Given a disk device like ‘hda’, ‘sdf’, ‘xvdb’, etc guess what the most appropriate disk bus is for the currently configured virtualization technology

Returns the disk bus, or raises an Exception if the disk device prefix is unknown.

get_disk_info(virt_type, instance, image_meta, block_device_info=None, rescue=False)

Determine guest disk mapping info.

This is a wrapper around get_disk_mapping, which also returns the chosen disk_bus and cdrom_bus. The returned data is in a dict

  • disk_bus: the bus for harddisks
  • cdrom_bus: the bus for CDROMs
  • mapping: the disk mapping

Returns the disk mapping disk.

get_disk_mapping(virt_type, instance, disk_bus, cdrom_bus, image_meta, block_device_info=None, rescue=False)

Determine how to map default disks to the virtual machine.

This is about figuring out whether the default ‘disk’, ‘disk.local’, ‘disk.swap’ and ‘disk.config’ images have been overridden by the block device mapping.

Returns the guest disk mapping for the devices.

get_eph_disk(index)
get_info_from_bdm(instance, virt_type, image_meta, bdm, mapping=None, disk_bus=None, dev_type=None, allowed_types=None, assigned_devices=None)
get_next_disk_info(mapping, disk_bus, device_type='disk', last_device=False, boot_index=None, assigned_devices=None)

Determine the disk info for the next device on disk_bus.

Considering the disks already listed in the disk mapping, determine the next available disk dev that can be assigned for the disk bus.

Returns the disk_info for the next available disk.

get_root_info(instance, virt_type, image_meta, root_bdm, disk_bus, cdrom_bus, root_device_name=None)
has_default_ephemeral(instance, disk_bus, block_device_info, mapping)
has_disk_dev(mapping, disk_dev)

Determine if a disk device name has already been used.

Looks at all the keys in mapping to see if any corresponding disk_info tuple has a device name matching disk_dev

Returns True if the disk_dev is in use.

is_disk_bus_valid_for_virt(virt_type, disk_bus)
update_bdm(bdm, info)

Previous topic

The nova.virt.ironic.patcher Module

Next topic

The nova.virt.libvirt.compat Module

Project Source

This Page