Skip to content

Latest commit

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

logo Vmanager

Virtual Manager - To manage KVM based machines

What is it?

It's essentially just a fancy wrapper around iproute2 and qemu for KVM.
It has hooks (functions) for creating virtual harddrives, cd-roms, network interfaces, switches, routers.

It separates each virtual machine into network namespaces, attaches zero or more layer 2 network interfaces to the machine. These network interfaces have two endpoints, one going into the machine and one that you can plug into any network device (virtual or physical).

It also supports snapshotting live running machines, harddrives, dump memory and screenshot machines.
All machines run in a headless mode by default, screenshots can be taken and stored some where, as well as sending keystrokes and mouse actions to the machines.

Documentation

This documentation will be moved to readthedocs or something.

Class/FunctionDescription
vmanager.interfacesA curated list over all physical (hosts) NIC's (Contains: IP's, routes, gateways)
vmanager.routesA list of all physical routes
vmanager.sys_commandRuns a shell command on the host machine
vmanager.InterfaceEach interface gets wrapped in this helper class in order to make life easier, by accessing Interface.ip for instance to get the interface's IP address, or Interface.routes. You can also do Interface.up to bring up a interface.
vmanager.Bond()Used to aggregate multiple NIC's into one logical interface(TODO)
vmanager.SwitchCreates a virtual switch (Currently creates a bridge where other interfaces can be slaved to, in order to emulate a "switch")
vmanager.RouterCreates a router (bridge) interface with one trunk interface and one LAN port. Used to tie together physical interfaces to the virtual realm and give machines access to the outside world.
vmanager.VirtualNicCreates a virtual VETH interface with a port<--->sink setup. If namespace=<name> is given, the sink end of the pipe is moved into a namespace, and is given a macvtap interface that can be used to give to a virtual machine to enable layer2 traffic. Functions such as .up() and .down() are available to bring the interface pair's up/down.
vmanager.CDA wrapper around ISO's, virtual machines uses cd.qemu_string wrapper to get the string representation to give a VM a CD that's useable
vmanager.HarddriveSame as CD, but supports .snapshots, .create, .wipe([snapshots_only=False]) and .resize as well as .qemu_string.
vmanager.MachineThe main class really, it sets up a KVM enabled machine that can use NIC's, HDD's, CD's and other stuff. Use .send() to talk to the QEMU console, for instance .send(b'ctrl-alt-f2') switches to TTY2 on a Unix machine. Full documentation on the different functions can be found below in a separate table for Machine

Machine

This is a work in process library, many of the features are yet not implemented. These are crossed off and strike through is removed as they get implemented.

FunctionsDescription
vmanager.Machine()harddrives= takes Harddrive as a object or a list of objects. nics same thing, but takes int to define how many interfaces or a list of VirtualNic's, cd takes one CD as argument. memory takes a int representing MB in size of RAM allocated. monitor_port will be the TCP port that qemu will listen to in order for you to connect (This automatically happens when setting up the Machine() instance. But you can use it to define a pre-defined port.)
Machine.is_runningReturns weither or not the machine is running.
Machine.start_vmStarts the VM (grabs qemu_string from attached resources.)
Machine.stop_vmStops the VM forcefully.
Machine.freezeFreezes the VM (useful for snapshotting etc)
Machine.unfreezeUnfreezes the VM
Machine.snapshotSnapshots the machine and it's harddrives.
Machine.load_snapshotRestores a previously taken snapshot
Machine.delete_snapshotRemoves a stored snapshot.
Machine.increase_ramTries to resize the RAM and inform the host
Machine.resize_harddriveCalls the Harddrive().resize() function
Machine.change_boot_deviceChanges boot priority, useful right before reboot.
Machine.create_chardevCreates a chardev
Machine.dump_memoryDumps the machines memory.
Machine.ejectCalls CD.eject() in order to eject the CD.
Machine.migrateMigrates the machine to another KVM instance.
Machine.mouse_moveMoves the mouse cursor inside the machine to x, y
Machine.mouse_clickClicks button=1 where the mouse cursor currently is in the machine.
Machine.add_nicAdd another NIC, if the guest supports it, it's hot swapped in.
Machine.del_nicRemoves a NIC.
Machine.deleteDeletes the machine and all it's associated NIC's and namespaces.
Machine.screenshotTakes a screendump of the machine and stores it in filename=<full path>
Machine.send_keySends a key combination to the QEMU console, which sends it into the machine. send_key("ctrl-alt-del") for instance.
Machine.nic_stateTurns the NIC on or off in the QEMU instance, doesn't affect physical link states on the host. If you want to change physical states, do vmanager.interfaces["name"].down() for instance.

Requirements

  • python-iproute2
  • qemu (tools such as qemu-img etc)

Supports

  • Routers (bridge with a outbound interface slaved as trunk, and LAN port is a VETH interface)
  • Switches (normal bridge utility interface)
  • Virtual Hard drives with snapshots (Currently only qcow2 format)

About

Virtual Manager - To manage KVM (Qemu) based machines

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages