Getting running

The basics of running minimega

The minimega miniclass series

Sandia National Laboratories

Getting started

minimega can be built from latest source or deployed from a release package.
You can follow the instructions here to get up and running: Installing minimega

minimega is designed to be simple to deploy, and fully automated by running minimega scripts (.mm files).

A few optional command line switches are available, no config files!

This allows you to use minimega directly or programmatically. Whatever fits your needs.
More on that in the Using minimega article.

starting minimega

note: KVM requires special permissions and minimega must be run as root unless permissions are modified. All examples shown assume root permissions.

bin/minimega
bin/minimega -nostdin &
bin/minimega -nostdin -context <contextName> -degree 3 &

There are multiple ways to interact with the daemon

bin/minimega -attach
minimega$ disconnect
bin/minimega -e vm config

Stopping minimega

minimega$ quit
sh$ bin/minimega -e quit
pkill minimega
nuke

CLI

Now that you have minimega up and running let's get familiar with the CLI.

minimega$ help
root: Display help on a command. Here is a list of commands:
.alias                   :       create an alias
.annotate                :       enable or disable hostname annotation
.columns                 :       show certain columns from tabular data
.compress                :       enable or disable output compression

Output Rendering

With minimega you can manipulate the way data is printed.

.csv true
.json true
.csv false 
.json false

If you only want to see certain columns or vms you can tell minimega to only print those.

.column name,state,ip vm info

Example Output

minimega:/tmp/minimega/minimega$ host
host   | name   | cpus | load           | memused | memtotal | bandwidth            | vms | vmsall
ubuntu | ubuntu | 1    | 0.00 0.00 0.00 | 190 MB  | 2000 MB  | 0.0/0.0 (rx/tx MB/s) | 0   | 0
minimega:/tmp/minimega/minimega$ .csv true host
host,name,cpus,load,memused,memtotal,bandwidth,vms,vmsall
ubuntu,ubuntu,1,0.00 0.00 0.00,190 MB,2000 MB,0.0/0.0 (rx/tx MB/s),0,0
minimega:/tmp/minimega/minimega$ host
host   | name   | cpus | load           | memused | memtotal | bandwidth            | vms | vmsall
ubuntu | ubuntu | 1    | 0.00 0.00 0.00 | 190 MB  | 2000 MB  | 0.0/0.0 (rx/tx MB/s) | 0   | 0
minimega:/tmp/minimega/minimega$ .csv true
minimega:/tmp/minimega/minimega$ host
host,name,cpus,load,memused,memtotal,bandwidth,vms,vmsall
ubuntu,ubuntu,1,0.00 0.00 0.00,190 MB,2000 MB,0.0/0.0 (rx/tx MB/s),0,0
minimega:/tmp/minimega/minimega$ .csv false
minimega:/tmp/minimega/minimega$ host
host   | name   | cpus | load           | memused | memtotal | bandwidth            | vms | vmsall
ubuntu | ubuntu | 1    | 0.00 0.00 0.00 | 190 MB  | 2000 MB  | 0.0/0.0 (rx/tx MB/s) | 0   | 0
minimega:/tmp/minimega/minimega$ .json true host
[{"Host":"ubuntu","Response":"","Header":["name","cpus","load","memused","memtotal","bandwidth","vms","vmsall"],"Tabular":[["ubuntu","1","0.00 0.00 0.00","190 MB","2000 MB","0.0/0.0 (rx/tx MB/s)","0","0"]],"Error":""}]
minimega:/tmp/minimega/minimega$ .columns memtotal,bandwidth host
host   | memtotal | bandwidth
ubuntu | 2000 MB  | 0.0/0.0 (rx/tx MB/s)

built-in commands

the vm info command is the primary way of seeing information about your VMs. However,
there are many columns of information that get printed by default, and looking through
all of that information can be cumbersome.

minimega has a variety of built-in commands that allow you to shape the output as you need.
Let's look at .column, .filter, .annotate, and .sort and see how you can leverage these
commands individually and in conjunction with each other.

.column

The .column command allows you to specify which columns you would like to see when running vm info

Column names are comma-separated.

For example, to display only the vm name and state, run:

.columns name,state vm info

notice we appended vm info onto the command. .column must be run in conjunction with
vm info or similar command.

.filter

The .filter command filters tabular data based on the value in a particular column.
For example, to search for vms in a particular state use:

.filter state=running vm info

Filters can also be inverted:

.filter state!=running vm info

Filters are case insensitive and may be stacked:

.filter state=RUNNING .filter vcpus=4 vm info

If the column value is a list or an object (i.e. "[...]", "{...}"), then

Substring matching can be specified explicity:

.filter state~run vm info
.filter state!~run vm info

.sort and .annotate

The .sort command allows you to set whether the returned tabular information is
sorted by the value in the first column. .sort does not need to be run in conjunction
with another command, and will affect all subsequent commands:

.sort true

The .annnotate command will hide the host name in output when used.

.annotate false

set to true to see the host name again.

Stacking built-in commands

Built-in commands can be used in conjunction with eachother to further refine output.

For example, to isolate the name and state of the VM and filter by a running state, run

.column name,state .filter state=running vm info

However, these commands are not always interchangeable. For example, the following is
acceptable:

.columns name,state .filter vcpus=4 vm info

While the following is not:

.filter vcpus=4 .columns name,state vm info

This is because .columns strips all columns except for name and state from the
tabular data.

.alias (recommended for interactive mode only)

minimega$ vm info
host   | id | name        | state    | uptime          | type       | uuid                                 | cc_active | pid | vlan | bridge | tap | mac | ip | ip6 | qos | memory | vcpus | disk           | snapshot | initrd | kernel | cdrom | migrate | append | serial-ports | virtio-ports | vnc_port | filesystem | hostname | init | preinit | fifo | volume | console_port | tags
myhost | 0  | kvm1        | BUILDING | 3m30.511919113s | kvm        | 2a270748-9dfd-47ca-8302-b8cc64206e1f | false     | 0   | []   | []     | []  | []  | [] | []  | []  | 2048   | 1     | [mydisk.qcow]  | true     |        |        |       |         | []     | 0            | 0            | 34671    | N/A        | N/A      | N/A  | N/A     | N/A  | N/A    | N/A          | {}

# That's a lot of data!! Let's try to narrow it down:

minimega$ .column host,name,state,type .filter state=building .filter type!=container vm info 
host   | hostname | name | state    | type
myhost | N/A      | kvm1  | BUILDING | kvm

# Better! But that is a bit lengthy to type repeatedly... try aliasing!

minimega$ .alias vms=.column host,name,state,type .filter state=building .filter type!=container vm info
minimega$ vms
host   | hostname | name | state    | type
myhost | N/A      | kvm1  | BUILDING | kvm

# perfect!

Setting and Unsetting Variables

minimega uses variables and they can be set by calling the applicable command and setting the variable.
Notice how the 'Disk Paths' variable is not set:

minimega$ vm config
VM configuration:
...
Disk Paths:         []
...

Let's set it now.

minimega$ vm config disk mydisk.img
minimega$ vm config
VM configuration:
...
Disk Paths:         [mydisk.img]
...

The disk path is now set in the vm configuration. Unset using the clear command.

minimega$ vm config disk
myhost: [mydisk.img]
minimega$ clear vm config disk
minimega$ vm config
VM configuration:
...
Disk Paths:         []
...

Next Up...

Module 2.5: Better vmbetter

Thank you

The minimega miniclass series

Sandia National Laboratories