The nova.virt.libvirt.driver Module

A connection to a hypervisor through libvirt.

Supports KVM, LXC, QEMU, UML, XEN and Parallels.

class GuestNumaConfig

Bases: tuple

GuestNumaConfig(cpuset, cputune, numaconfig, numatune)

cpuset

Alias for field number 0

cputune

Alias for field number 1

numaconfig

Alias for field number 2

numatune

Alias for field number 3

class LibvirtDriver(virtapi, read_only=False)

Bases: nova.virt.driver.ComputeDriver

attach_interface(instance, image_meta, vif)
attach_volume(context, connection_info, instance, mountpoint, disk_bus=None, device_type=None, encryption=None)
block_stats(instance, disk_id)

Note that this function takes an instance name.

capabilities = {'supports_migrate_to_same_host': False, 'has_imagecache': True, 'supports_recreate': True}
check_can_live_migrate_destination(context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False)

Check if it is possible to execute live migration.

This runs checks on the destination host, and then calls back to the source host to check the results.

Parameters:
  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance
  • block_migration – if true, prepare for block migration
  • disk_over_commit – if true, allow disk over commit
Returns:

a dict containing: :filename: name of the tmpfile under CONF.instances_path :block_migration: whether this is block migration :disk_over_commit: disk-over-commit factor on dest host :disk_available_mb: available disk space on dest host

check_can_live_migrate_destination_cleanup(context, dest_check_data)

Do required cleanup on dest host after check_can_live_migrate calls

Parameters:context – security context
check_can_live_migrate_source(context, instance, dest_check_data, block_device_info=None)

Check if it is possible to execute live migration.

This checks if the live migration can succeed, based on the results from check_can_live_migrate_destination.

Parameters:
  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance
  • dest_check_data – result of check_can_live_migrate_destination
  • block_device_info – result of _get_instance_block_device_info
Returns:

a dict containing migration info

check_instance_shared_storage_cleanup(context, data)
check_instance_shared_storage_local(context, instance)

Check if instance files located on shared storage.

This runs check on the destination host, and then calls back to the source host to check the results.

Parameters:
  • context – security context
  • instance – nova.objects.instance.Instance object
Returns:

  • tempfile: A dict containing the tempfile info on the destination

    host

  • None:

    1. If the instance path is not existing.
    2. If the image backend is shared block storage type.

check_instance_shared_storage_remote(context, data)
cleanup(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None, destroy_vifs=True)
confirm_migration(migration, instance, network_info)

Confirms a resize, destroying the source VM.

default_device_names_for_instance(instance, root_device_name, *block_device_lists)
default_root_device_name(instance, image_meta, root_bdm)
delete_instance_files(instance)
destroy(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None)
detach_interface(instance, vif)
detach_volume(connection_info, instance, mountpoint, encryption=None)
disk_cachemode
ensure_filtering_rules_for_instance(instance, network_info)

Ensure that an instance’s filtering rules are enabled.

When migrating an instance, we need the filtering rules to be configured on the destination host before starting the migration.

Also, when restarting the compute service, we need to ensure that filtering rules exist for all running services.

filter_defer_apply_off()
filter_defer_apply_on()
finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance, block_device_info=None, power_on=True)
finish_revert_migration(context, instance, network_info, block_device_info=None, power_on=True)
get_all_volume_usage(context, compute_host_bdms)

Return usage info for volumes attached to vms on a given host.

get_available_nodes(refresh=False)
get_available_resource(nodename)

Retrieve resource information.

This method is called when nova-compute launches, and as part of a periodic task that records the results in the DB.

Parameters:nodename – will be put in PCI device
Returns:dictionary containing resource info
get_console_output(context, instance)
get_console_pool_info(console_type)
get_device_name_for_instance(instance, bdms, block_device_obj)
get_diagnostics(instance)
get_host_cpu_stats()

Return the current CPU state of the host.

get_host_ip_addr()
get_host_uptime()

Returns the result of calling “uptime”.

get_info(instance)

Retrieve information from libvirt for a specific instance name.

If a libvirt error is encountered during lookup, we might raise a NotFound exception or Error exception depending on how severe the libvirt error is.

get_instance_diagnostics(instance)
get_instance_disk_info(instance, block_device_info=None)
get_serial_console(context, instance)
get_spice_console(context, instance)
get_vnc_console(context, instance)
get_volume_connector(instance)
init_host(host)
inject_network_info(instance, nw_info)
inject_nmi(instance)

Inject an NMI to the specified instance.

instance_exists(instance)

Efficient override of base instance_exists method.

instance_on_disk(instance)
is_supported_fs_format(fs_type)
list_instance_uuids()
list_instances()
live_migration(context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None)

Spawning live_migration operation for distributing high-load.

Parameters:
  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance object instance object that is migrated.
  • dest – destination host
  • post_method – post operation method. expected nova.compute.manager._post_live_migration.
  • recover_method – recovery method when any exception occurs. expected nova.compute.manager._rollback_live_migration.
  • block_migration – if true, do block migration.
  • migrate_data – implementation specific params
manage_image_cache(context, all_instances)

Manage the local cache of images.

migrate_disk_and_power_off(context, instance, dest, flavor, network_info, block_device_info=None, timeout=0, retry_interval=0)
need_legacy_block_device_info
pause(instance)

Pause VM instance.

plug_vifs(instance, network_info)

Plug VIFs into networks.

poll_rebooting_instances(timeout, instances)
post_live_migration(context, instance, block_device_info, migrate_data=None)
post_live_migration_at_destination(context, instance, network_info, block_migration=False, block_device_info=None)

Post operation of live migration at destination host.

Parameters:
  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance object instance object that is migrated.
  • network_info – instance network information
  • block_migration – if true, post operation of block_migration.
post_live_migration_at_source(context, instance, network_info)

Unplug VIFs from networks at source.

Parameters:
  • context – security context
  • instance – instance object reference
  • network_info – instance network information
power_off(instance, timeout=0, retry_interval=0)

Power off the specified instance.

power_on(context, instance, network_info, block_device_info=None)

Power on the specified instance.

pre_live_migration(context, instance, block_device_info, network_info, disk_info, migrate_data=None)

Preparation live migration.

quiesce(context, instance, image_meta)

Freeze the guest filesystems to prepare for snapshot.

The qemu-guest-agent must be setup to execute fsfreeze.

reboot(context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None)

Reboot a virtual machine, given an instance reference.

refresh_instance_security_rules(instance)
refresh_provider_fw_rules()
refresh_security_group_members(security_group_id)
refresh_security_group_rules(security_group_id)
rescue(context, instance, network_info, image_meta, rescue_password)

Loads a VM using rescue images.

A rescue is normally performed when something goes wrong with the primary images and data needs to be corrected/recovered. Rescuing should not edit or over-ride the original image, only allow for data recovery.

resume(context, instance, network_info, block_device_info=None)

resume the specified instance.

resume_state_on_host_boot(context, instance, network_info, block_device_info=None)

resume guest state when a host is booted.

rollback_live_migration_at_destination(context, instance, network_info, block_device_info, destroy_disks=True, migrate_data=None)

Clean up destination node after a failed live migration.

set_admin_password(instance, new_pass)
snapshot(context, instance, image_id, update_task_state)

Create snapshot from a running VM instance.

This command only works with qemu 0.14+

spawn(context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None)
suspend(context, instance)

Suspend the specified instance.

swap_volume(old_connection_info, new_connection_info, instance, mountpoint, resize_to)
unfilter_instance(instance, network_info)

See comments of same method in firewall_driver.

unpause(instance)

Unpause paused VM instance.

unplug_vifs(instance, network_info)
unquiesce(context, instance, image_meta)

Thaw the guest filesystems after snapshot.

unrescue(instance, network_info)

Reboot the VM which is being rescued back into primary images.

volume_snapshot_create(context, instance, volume_id, create_info)

Create snapshots of a Cinder volume via libvirt.

Parameters:
  • instance – VM instance object reference
  • volume_id – id of volume being snapshotted
  • create_info – dict of information used to create snapshots - snapshot_id : ID of snapshot - type : qcow2 / <other> - new_file : qcow2 file created by Cinder which becomes the VM’s active image after the snapshot is complete
volume_snapshot_delete(context, instance, volume_id, snapshot_id, delete_info)
patch_tpool_proxy()

eventlet.tpool.Proxy doesn’t work with old-style class in __str__() or __repr__() calls. See bug #962840 for details. We perform a monkey patch to replace those two instance methods.

Previous topic

The nova.virt.libvirt.designer Module

Next topic

The nova.virt.libvirt.firewall Module

Project Source

This Page