Thursday, 2 June 2016

Libvirt and event based vm states

Now a days virtualization is one of the most common and fastest growing field in computer science. Basically now world move from physical and costly hardware to software based. Like if we need new machine we go to market and buy the new one, but virtualization made it easy, now we only spawn new machine with just few clicks.

So their is need for some tool to manage virtualization, Libvirt is an opensource daemon used for managing virtualization. It can manage many virtualization technologies like KVM, XEN, VMWARE ESX, QEMU.

Livirt has many use cases. I worked on a use case to detect change in vm states on event bases.
Open stack on back end use libvirt for virtualization. What if we want to detect any change in virtual machine states??? First method is you continuously check your vm by using ssh and polling, but it's bad approach. Libvirt allows you to detect vm current state. Libvirt developers writes a python plugin that detect any change in vm state and show it to you, without polling and any other over head on server. You can get agent from here. It is opensource, so you can modify it as you can.

Libvirt has 5 states for any vm


  • Undefined
  • Defined
  • Runing
  • Paused
  • Saved

The agent get state from libvirt whenever any of these event occurred and show details. Agent register itself in libvirt and get state on every event change. The agent show many details some of them are
  • Name of instance (openstack name, created by openstack)
  • UUID of instance
  • Event name
    • Defined,
    • Undefined
    • Started
    • Suspended
    • Resumed
    • Stopped
    • Shutdown

  • Event Detail (Detail of event to clarify action)
    • Added
    • Updated
    • Removed
    • Booted
    • Migrated
    • Restored
    • Snapshot
    • Wakeup
    • Paused
    • Migrated
    • IOError
    • Watchdog
    • Restored
    • Snapshot
    • Unpaused
    • Migrated
    • Snapshot
    • Shutdown
    • Destroyed
    • Crashed
    • Migrated
    • Saved
    • Failed
    • Snapshot
    • Finished

0 comments:

Post a Comment