Getting running¶
The basics of running minimega
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
-
There are lots of ways to run and interface with minimega!
- on your local machine
- deployed over many nodes in a cluster
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.
- Launch interactively
- Launch daemon (recommended)
- Launch daemon on a cluster (more on this later)
There are multiple ways to interact with the daemon¶
- You can attach to the daemon using minimega's attach flag
- Detach using 'disconnect' or ctrl-d
- Execute a single command with the -e flag
-
Command Port
- There is also a unix domain socket that accepts JSON encoded commands located at
<base>/minimega. - For more information, visit the minimega documentation.
- There is also a unix domain socket that accepts JSON encoded commands located at
Stopping minimega¶
-
minimega can be stopped gracefully using the 'quit' command
- note: when attached to the daemon, you will need to input quit twice
- If minimega proccesses are still running after the console has been killed, use pkill
-
Finally, the minimega api documents a nuke command.
- After a crash, the VM state on the machine can be difficult to recover from. Nuke attempts to kill all instances of QEMU, remove all taps and bridges, and removes the temporary minimega state on the harddisk. This should be run with caution.
CLI¶
Now that you have minimega up and running let's get familiar with the CLI.
- Help - the most important command in minimega
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
- Use
help <command>for more information on particular commands - Tab expansion is your friend!
- Tab expansion also works on local filesystem files
Output Rendering¶
With minimega you can manipulate the way data is printed.
- output in
.csvformat
- output in JSON format
- Set either option to
falseto turn it off
If you only want to see certain columns or vms you can tell minimega to only print those.
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 .columns, .filter, .annotate, and .sort and see how you can leverage these commands individually and in conjunction with each other.
.columns¶
The .columns 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:
notice we appended vm info onto the command. .columns 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:
Filters can also be inverted:
Filters are case insensitive and may be stacked:
If the column value is a list or an object (i.e. "[...]", "{...}"), then
Substring matching can be specified explicity:
.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:
The .annnotate command will hide the host name in output when used.
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
However, these commands are not always interchangeable. For example, the following is acceptable:
While the following is not:
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:
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: []
...
-
The clear command clears the value for any setting in any api:
- clear vm config
- clear cc filter
clear router <vm>- clear tap
- see 'help clear' for more