minimega.emulated_entities

This MC provides the MinimegaEmulatedVM object which has methods for generating a large dictionary of parameters which can be eventually passed to minimega to start the experiment.

Sample Output

The generate_minimega_config() method is used to generate a large dictionary which contains all necessary information to start a minimega experiment. Below is an example dictionary from this method for the host.root.net VM which is created by the tests.router_tree model component.

{
    "aux": {
        "qemu_append": {},
        "control_ip": "",
        "power_state": "running",
        "nic": [
            {
                "name": "nic",
                "id": "if0",
                "switch_name": "switch-host-ospf.root.net",
                "type": "tap",
                "driver": "virtio-net-pci",
                "mac": "00:00:00:00:00:01",
                "qos": {
                    "loss": null,
                    "delay": null,
                    "rate": null
                },
                "ip": "10.0.0.2/24"
            }
        ],
        "disks": [
            {
                "name": "drive",
                "id": "drv0",
                "file": "ubuntu-16.04.4-server-amd64.qcow2",
                "path": "images/ubuntu-16.04.4-server-amd64.qcow2",
                "db_path": "ubuntu-16.04.4-server-amd64.qcow2.xz",
                "interface": "virtio",
                "cache": "writeback"
            }
        ],
        "qemu_append_str": "",
        "qga_config": {
            "name": "serial",
            "id": "minimegaqga",
            "path": "/tmp/minimega/namespaces/firewheel/8c993d3a-2cf7-4429-8e98-75b16c2cd26c/virtio-serial0"
        },
        "minimegaqmp": {
            "name": "qmp",
            "id": "minimegaqmp",
            "path": "/tmp/minimega/namespaces/firewheel/8c993d3a-2cf7-4429-8e98-75b16c2cd26c/qmp"
        },
        "handler_process": {
            "type": "Process",
            "engine": "QemuVM",
            "uuid": "e5dce01d-ce00-4fe4-a84b-3569ef007a57",
            "vm_name": "host.root.net",
            "vm_uuid": "8c993d3a-2cf7-4429-8e98-75b16c2cd26c",
            "binary_name": "/opt/firewheel/src/firewheel/vm_resource_manager/vm_resource_handler.py",
            "path": "/tmp/minimega/namespaces/firewheel/8c993d3a-2cf7-4429-8e98-75b16c2cd26c/virtio-serial0"
        }
    },
    "vm": {
        "uuid": "8c993d3a-2cf7-4429-8e98-75b16c2cd26c",
        "type": "QemuVM",
        "architecture": "x86_64",
        "name": "host.root.net",
        "image": "ubuntu1604server",
        "vcpu_model": "qemu64",
        "smp_name": "smp",
        "smp_id": "smp",
        "smp_sockets": 1,
        "smp_cores": 1,
        "smp_threads": 1,
        "memory": "256",
        "vga_model": "std"
    },
    "coschedule": -1,
    "tags": {}
}

VM Host Distribution

There may be times where the performance of some VMs is particularly important, and resource contention can cause problems with experiments. The number of VMs that share a host with a particular VM can be controlled using the coschedule attribute. Setting this value to 0 means that the VM is run on its own host. Setting this value to -1 (default) means run the default scheduling (no limit on how many other VMs are on the same host).

Available Objects

class minimega.emulated_entities.MinimegaEmulatedEntity[source]

Bases: object

This object adds a UUID to the Vertex.

__init__()[source]

Adding a new UUID and casting it to a string.

class minimega.emulated_entities.MinimegaEmulatedVM(*args, **kwargs)[source]

Bases: object

An object which adds methods to a Vertex to collect all configuration options needed to launch the VM with minimega.

interface_defaults

A dictionary containing default values for interfaces. This includes the type of interface and the required driver.

Type:

dict

drive_defaults

A dictionary containing default values for VM drives. This includes the drive interface and cache type.

Type:

dict

cpu_defaults

A dictionary containing default values for VM CPUs. This includes the model type, and number of sockets, cores, and threads.

Type:

dict

__init__(*args, **kwargs)
_generate_bios_config(config)[source]

Create a finished configuration for the VMs BIOS.

Parameters:

config (dict) – The configuration for the VM.

_generate_drive_configs(config)[source]

Create a finished configuration for each drive.

Note

The first disk is assumed to be the image for the VM.

Parameters:

config (dict) – The configuration for the VM.

Raises:

RuntimeError – If a required configuration key is missing from an interface.

Returns:

A list of drives for the VM.

Return type:

list

_generate_mem_config(config)[source]

Create a finished configuration for the VMs memory.

Parameters:

config (dict) – The configuration for the VM.

_generate_nic_configs(config)[source]

Create a finished configuration for each NIC.

The finished config for a NIC resembles:

{
    "name": "nic",
    "id": "unique",
    "type": "tap",
    "interface": "tap0",
    "driver": "virtio-net-pci",
    "bus": "pci.0",
    "bus_addr": "5",
    "mac": "00:00:00:00:00:00"
}

Where the fields are described as:

  • name - minimega device name. (e.g. "nic").

  • id - Some value unique within the scope of this VM.

  • type - Type of interface. Supported: "tap". This corresponds to both a QEMU type and a mapping to a minimega port object.

  • interface - Name of the tap interface on the underlying host system. This must meet the restrictions placed by Linux on the naming of network interfaces.

  • bus - PCI bus number.

  • bus_addr - PCI bus address.

  • mac - MAC address for this interface.

Parameters:

config (dict) – The configuration for the VM.

Raises:

RuntimeError – If a required configuration key is missing from an interface.

_generate_qemu_append_str(config)[source]

Some QEMU arguments are not natively supported by minimega’s vm config function. To set those arguments, we can use the qemu_append option for the VM config.

In this method, we take all of the qemu_append mappings and parse them into a string to be used by minimega.

For example, BIOS can currently only be set in this way. In _generate_bios_config, we grab the value for BIOS from self.vm and set it in the qemu_append dictionary. Then this parses: {"bios" : "seabios_rel-1.14.0.0"} into -bios seabios_rel-1.14.0.0.

Parameters:

config (dict) – The configuration for the VM.

_generate_vcpu_config(config)[source]

Create a finished configuration for the VMs vCPUs.

Parameters:

config (dict) – The configuration for the VM.

Returns:

A list containing the cpu_config, the smp_config, and the modified VM config.

Return type:

list

_generate_vga_config(config)[source]

Create a finished configuration for the VMs VGA display.

Parameters:

config (dict) – The configuration for the VM.

_generate_vm_resource_handler_communication_config(config, minimega_type)[source]

Create the finished configuration which will be used to enable communication between the VM Resource Handler and the VM.

Parameters:
  • config (dict) – The configuration for the VM.

  • minimega_type (str) – The type of the VM. Currently, there is only one type QemuVM.

Returns:

The qga_config dictionary.

Return type:

dict

_generate_vm_resource_handler_process_config(config)[source]

Create a configuration for launching a VM Resource Handler process for each VM. This method assumes that FIREWHEEL has been installed in the same location on all Compute Nodes.

Parameters:

config (dict) – The configuration for the VM.

Returns:

The configuration to launch a new VM Resource Handler process.

Return type:

dict

cpu_defaults = {'cores': 1, 'model': 'qemu64', 'sockets': 1, 'threads': 1}
drive_defaults = {'cache': 'writeback', 'interface': 'virtio'}
generate_minimega_config()[source]

Generate a minimega VM config based on this Vertex.

Raises:

KeyError – Every VM must define an architecture.

Returns:

The minimega configuration dictionary with all required information.

Return type:

dict

interface_defaults = {'driver': 'virtio-net-pci', 'type': 'tap'}