detection of events in KVM
One of our requirement was to detect the events being occurred in the guest machines of KVM Hypervisor. Like Boot, ShutDown event etc.
While searching a lot of forums, finally I got this link.
https://www.redhat.com/archives/libvir-list/2014-January/msg00126.html
This link discusses exactly my requirement.
The Source Code is available in GIT
https://github.com/virtualopensystems/libvirt/blob/master/examples/object-events/event-test.c
One thing which I found much interesting was this code tracked the following Events ( which I could see )
1. Booting of a VM
2. Shutdown of a VM
3. Graphic Console Access of a VM
( Mentioning Source IP, Source Port, Destination IP, Destination Port )
4. Reboot etc.
In addition to this, some parts of the Code showed like tracking of data in / out.
At some part of the code, certain events were tracked twice. I modified this code to fit our requirement.
The Source Code is here.
One of our requirement was to detect the events being occurred in the guest machines of KVM Hypervisor. Like Boot, ShutDown event etc.
While searching a lot of forums, finally I got this link.
https://www.redhat.com/archives/libvir-list/2014-January/msg00126.html
This link discusses exactly my requirement.
The Source Code is available in GIT
https://github.com/virtualopensystems/libvirt/blob/master/examples/object-events/event-test.c
One thing which I found much interesting was this code tracked the following Events ( which I could see )
1. Booting of a VM
2. Shutdown of a VM
3. Graphic Console Access of a VM
( Mentioning Source IP, Source Port, Destination IP, Destination Port )
4. Reboot etc.
In addition to this, some parts of the Code showed like tracking of data in / out.
At some part of the code, certain events were tracked twice. I modified this code to fit our requirement.
The Source Code is here.
Other than this approach, I followed process based event handling; which will be discussed in the next post.
Sequence ( as far my understanding :) )
- First get a Libvirt Connection
- virInitialize()
- virEventRegisterDefaultImpl
- virConnectOpenAuth
- Register for an Event
- check the return value and loop it infinitely
- At last register with SIGTERM ( CTRL + C )
- sigaction(SIGTERM, &action_stop, NULL);
No comments:
Post a Comment